grpc

command
v0.0.0-...-1b94cb7 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 8 Imported by: 0

README

GRPC Plugins

Loading Go and Python plugins over GRPC.

Getting Started

Building and running the Go GRPC plugin:

go build main.go && ./main

Generating Proto Files

For Go:

# In create-fullstack/core
protoc -I=proto --go_out=. --go-grpc_out=. proto/aug.proto

For Python:

# In this directory
python -m grpc_tools.protoc -I ../../core/proto/ --python_out=./plugin-python/ --grpc_python_out=./plugin-python/ ../../core/proto/aug.proto

Key Points

The Plugins map sent to:

main.go

	client := plugin.NewClient(&plugin.ClientConfig{
		HandshakeConfig: cfsplugin.AugmentPluginHandshake,
		Plugins:         cfsplugin.AugmentorManager.Plugins(),
		Cmd:             exec.Command(filepath.Join("build", meta.Id)),
		Logger:          logger,
		AllowedProtocols: []plugin.Protocol{
			plugin.ProtocolGRPC,
		},
	})

and

plugin-go/main.go

// In
// err := cfsplugin.ServeAugmentor(augmentor, logger)
	plugin.Serve(&plugin.ServeConfig{
		HandshakeConfig: AugmentPluginHandshake,
		Plugins:         AugmentorManager.Plugins(),
		Logger:          hcLogger,
		// A non-nil value here enables gRPC serving for this plugin...
		GRPCServer: plugin.DefaultGRPCServer,
	})

DO NOT need to be the same reference to a map.

Instead, they must contain the same keys. The only difference is that the host process' cfsplugin.AugmentorPluginManager.Plugins() contains an empty implementation of the plugin, while the plugin provides a plugin with the implemented struct.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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