Last active
May 16, 2020 19:44
-
-
Save xmlking/b507ff9dcefd97069e69334bb3037406 to your computer and use it in GitHub Desktop.
go-micro: you can also use Unix Domain Sockets (UDS) as address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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