Jolie面向微服务的编程语言
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 服务器进行编程
评论