example

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Greeter

type Greeter interface {
	Greet() string
}

Greeter is the interface that we're exposing as a plugin.

type GreeterPlugin

type GreeterPlugin struct {
	// Impl Injection
	Impl Greeter
}

This is the implementation of plugin.Plugin so we can serve/consume this

This has two methods: Server must return an RPC server for this plugin type. We construct a GreeterRPCServer for this.

Client must return an implementation of our interface that communicates over an RPC client. We return GreeterRPC for this.

Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.

func (GreeterPlugin) Client

func (GreeterPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*GreeterPlugin) Server

func (p *GreeterPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type GreeterRPC

type GreeterRPC struct {
	// contains filtered or unexported fields
}

Here is an implementation that talks over RPC

func (*GreeterRPC) Greet

func (g *GreeterRPC) Greet() string

type GreeterRPCServer

type GreeterRPCServer struct {
	// This is the real implementation
	Impl Greeter
}

Here is the RPC server that GreeterRPC talks to, conforming to the requirements of net/rpc

func (*GreeterRPCServer) Greet

func (s *GreeterRPCServer) Greet(args interface{}, resp *string) error

Jump to

Keyboard shortcuts

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