您现在的位置是:首页 > 文章详情

Jolie —— 面向微服务的编程语言

日期:2021-05-26点击:670

Jolie 是面向微服务、为微服务开发设计的编程语言,旨在为微服务的开发提供原生抽象 (native abstraction)。

type HelloRequest {
	name:string
}

interface HelloInterface {
requestResponse:
	hello( HelloRequest )( string )
}

service HelloService {
	execution: concurrent

	inputPort HelloService {
		location: "socket://localhost:9000"
		protocol: http { format = "json" }
		interfaces: HelloInterface
	}

	main {
		hello( request )( response ) { 
			response = "Hello " + request.name
		}
	}
}

主要特性

  • 专为微服务和 API 设计
type GetProfileRequestType {
	id:int
}
type GetProfileResponseType {
	name:string
	surname:string
	email:string( regex(".*@.*\\..*") )
	accounts[0,*] {
		nickname:string
		service_url:string
		enabled:bool
	}
	ranking:int( ranges( [1,5] ) )
}

type SendMessageRequestType {
	id:int
	message:string( length( [0,250] ) )
}

interface ProfileInterface {
requestResponse: // Synchronous RPC
	getProfile( GetProfileRequestType )( GetProfileResponseType )

oneWay: // Asynchronous
	sendMessage( SendMessageRequestType )
}
  • 专为网络时代而构建

  • 协议无关

  • 结构化工作流
  • 针对并行代码的动态错误处理
include "console.iol"
include "time.iol"

main
{
    scope( grandFather )
    {
        install( this => println@Console( "recovering grandFather" )() );
        scope( father )
        {
            install( this => println@Console( "recovering father" )() );
            scope ( son )
            {
                install( this => println@Console( "recovering son" )() );
                sleep@Time( 500 )();
                println@Console( "Son's code block" )()
            }
        }
    }
    |
    throw( a_fault )
}
  • 支持直接对 Web 服务器进行编程

原文链接:https://www.oschina.net/p/jolie
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章