Skip to content
Branch: master
Find file History
bvwells Remove dead link to sidecar example
Remove dead link to sidecar example.
Latest commit 97e3a62 Mar 18, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
gateway update for proto changes Mar 24, 2018
greeter protoc-gen-micro was updated Apr 25, 2018
README.md

README.md

GRPC

Contains examples for using go-grpc

New service

Check out the greeter example using go-grpc

Import go-grpc

import "github.com/micro/go-grpc"

Create micro.Service

service := grpc.NewService()

Pre-existing Service

What if you want to add grpc to a pre-existing service? Use the build pattern for plugins but swap out the client/server.

Create a plugin file

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()
}

Build the binary

// For local use
go build -i -o service ./main.go ./plugins.go

Run

Because the default client/server have been replaced we can just run as usual

./service
You can’t perform that action at this time.