Skip to content

Instantly share code, notes, and snippets.

@xmlking
Last active May 16, 2020 19:44
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save xmlking/b507ff9dcefd97069e69334bb3037406 to your computer and use it in GitHub Desktop.
go-micro: you can also use Unix Domain Sockets (UDS) as address
package main
import (
"net"
"github.com/micro/go-micro/v2"
"github.com/xmlking/logger/log"
sgrpc "github.com/micro/go-micro/v2/server/grpc"
)
func main() {
// you can also use Unix domain socket
lis, err := net.Listen("unix", "/tmp/greeter.sock")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
println(lis.Addr().String())
// New Service
service := micro.NewService(
micro.Name(serviceName),
micro.Server(sgrpc.NewServer(sgrpc.Listener(lis))),
)
// Run service
if err := service.Run(); err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment