Contains examples for using go-grpc
- greeter - A greeter example
- gateway - A grpc gateway example
- sidecar - Using the micro sidecar for http
Check out the greeter example using go-grpc
import "github.com/micro/go-grpc"
service := grpc.NewService()
What if you want to add grpc to a pre-existing service? Use the build pattern for plugins but swap out the client/server.
package main
import (
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/server"
cli "github.com/micro/go-plugins/client/grpc"
srv "github.com/micro/go-plugins/server/grpc"
)
func init() {
// set the default client
client.DefaultClient = cli.NewClient()
// set the default server
server.DefaultServer = srv.NewServer()
}
// For local use
go build -i -o service ./main.go ./plugins.go
Because the default client/server have been replaced we can just run as usual
./service