example/

directory
v0.0.0-...-74f90a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2021 License: Apache-2.0

README

Generate the files

In order to edit the generated .proto.go files

$ protoc -I example/ example/pb/helloworld.proto --go_out=plugins=grpc:example

Start the gRPC backend

$ go build -o backend ./example/backend
$ ./backend

KrakenD setup

As custom bindings

Check the example/krakend/grpc_bindings.go for examples about how to build the Encoder/Decoder pair, register a client and so on.

With your bindings already defined, just execute the Register

	registerer := new(Registerer)
	registerer.RegisterClients(grpc.RegisterClient)

Build and start the example

$ go build -o krakend ./example/krakend
$ ./krakend -c krakend.json -d -l DEBUG 

As a plugin (dynamic linked bin)

Define your gRPC bindings in a dedicated package, ready to be compiled as a golang plugin (main package with and empty main function)

The plugin loader will lookup a symbol called "Registerer". This symbol must implement the interface plugin.Registerer in order to be loaded properly

As you can see, the example/krakend/plugin/plugin.go is almost a copy of example/krakend/grpc_bindings.go.

Build the plugin and where you put the .so file

$ go build -buildmode=plugin -o gRPC-hello.so

Add a plugin section into the service config file with the path to the folder containing the .so and a pattern to be requested

{
	...
	"plugin":{
		"folder": "./plugins",
		"pattern": ".so"
	},
	...
}

Build and start the example

$ go build -o krakend ./example/krakend
$ ./krakend -c krakend.json -d -l DEBUG -plugin
[KRAKEND] DEBUG: gRPC: total loaded plugins = 0

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL