package shared

import "github.com/hashicorp/go-plugin/examples/basic/shared"

Index

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

Source Files

greeter_interface.go

Version
v1.6.3 (latest)
Published
Jan 23, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
4 days ago

Tools for package owners.