1 Component connectivity
The field srv declared in an artifact is used to describe the connectivity of a component, that is, the set of channels it exposes.
This field follows the Links type alias definition:
alias Links struct {
client? struct open[Client]
server? struct open[Server]
duplex? struct open[Server]
}
alias Channel "udp" | "tcp" | "http" | "grpc"
alias Client Channel
alias Server Channel | struct { protocol channel, port number }
1.1 Duplex channels
In addition to client and server channels, an artifact’s srv section can also define a duplex channel. Conceptually, duplex channels code both a client and a server channel. They are designed to model endpoints used to initiate requests as well as serve them. Duplex channels are useful in scenarios where a group of instances must carry out complex coordination protocols (e.g., consensus), and each one of those instances plays both a “client” and a “server” role.
1.2 Examples
A full example of an artifact defining client, server and duplex channels is as follows:
component MyComponent {
srv {
client {
httpChannel "http"
grpcChannel "grpc"
}
server {
api {
protocol "http"
port 8080
}
tcpChannel "tcp"
}
duplex {
dupHttpChannel "http"
dupGrpcChannel "grpc"
}
}
[...]
}