grpc

package
v0.0.0-...-3458964 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

Counter Example

This example builds a simple key/counter store CLI where the mechanism for storing and retrieving keys is pluggable. However, in this example we don't trust the plugin to do the summation work. We use bi-directional plugins to call back into the main proccess to do the sum of two numbers. To build this example:

# This builds the main CLI
$ go build -o counter

# This builds the plugin written in Go
$ go build -o counter-go-grpc ./plugin-go-grpc

# This tells the Counter binary to use the "counter-go-grpc" binary
$ export COUNTER_PLUGIN="./counter-go-grpc"

# Read and write
$ ./counter put hello 1
$ ./counter put hello 1

$ ./counter get hello
2
Plugin: plugin-go-grpc

This plugin uses gRPC to serve a plugin that is written in Go:

# This builds the plugin written in Go
$ go build -o counter-go-grpc ./plugin-go-grpc

# This tells the KV binary to use the "kv-go-grpc" binary
$ export COUNTER_PLUGIN="./counter-go-grpc"

Updating the Protocol

If you update the protocol buffers file, you can regenerate the file using the following command from this directory. You do not need to run this if you're just trying the example.

$ buf generate

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "SAGOO_PLUGIN",
	MagicCookieValue: "sagoo_plugin",
}

HandshakeConfig 握手配置,插件进程和宿主机进程,都需要保持一致

Functions

func OutJsonRes

func OutJsonRes(code int, message string, data interface{}) string

OutJsonRes 输出json字符串结果

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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