greeter

package module
v0.0.0-...-369e69d Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 7 Imported by: 0

README

This is a very simple test of HashiCorp's go-plugin with bidirectional communication over GRPC.

How to Run

git clone github.com/korylprince/go-plugin-test.git
cd go-plugin-test
cd cmd/greeter-plugin
go build
cd ../greeter/
go run greeter.go "Mr. Anderson"

<snip debug logs>

Yo, what's up Mr. Anderson? <nil>

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "greeter",
}
View Source
var PluginSet = plugin.PluginSet{
	"greeter": &GreeterPlugin{},
}

Functions

This section is empty.

Types

type ClientGreeter

type ClientGreeter struct {
	proto.GreeterClient
}

ClientGreeter is client side of the RPC (e.g. your program)

func (*ClientGreeter) Greet

func (g *ClientGreeter) Greet(ctx context.Context, name string) (string, error)

type Greeter

type Greeter interface {
	Greet(ctx context.Context, name string) (string, error)
}

Greeter is the interface implemented by the plugin

type GreeterPlugin

type GreeterPlugin struct {
	plugin.Plugin
	Greeter
}

GreaterPlugin implements plugin.Plugin

func (*GreeterPlugin) GRPCClient

func (p *GreeterPlugin) GRPCClient(ctx context.Context, _ *plugin.GRPCBroker, client *grpc.ClientConn) (interface{}, error)

func (*GreeterPlugin) GRPCServer

func (p *GreeterPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error

type ServerGreeter

type ServerGreeter struct {
	Greeter
	proto.UnimplementedGreeterServer
}

ServerGreeter is the server side of the RPC (e.g. the plugin)

func (*ServerGreeter) Greet

func (s *ServerGreeter) Greet(ctx context.Context, name *proto.Name) (*proto.Greeting, error)

Directories

Path Synopsis
cmd
greeter command
greeter-plugin command

Jump to

Keyboard shortcuts

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