Server¶
Configuration¶
rpc:
server:
test:
desc: "test service"
address:
- url: ":9000"
version: "1.0"
write_timeout: 10s
heartbeat: 30s
Create¶
type TestService struct {
}
func (TestService) Hello(ctx context.Context, name string) string {
return "Hello, " + name
}
func main() {
s := rpc.Listen(transport.Address{URL: ":9000"})
s.Match(json.Matcher, "json")
s.RegisterService("Test", TestService{})
s.RegisterFunc("Test", "Ping", func() string {
return "pong"
})
log.Fatal(s.Serve())
}
Port multiplexing¶
auxo support host multiple protocols on the same port.
s.Match(json.Matcher, "json")
s.Match(http.Matcher, "http")
s.Match(rpc.Any, "proto")