shared

package
v0.0.0-...-45a0acb Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2017 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "hello",
}

Handshake is a common handshake that is shared by plugin and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	"strategy": &StrategyPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type GRPCClient

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

GRPCClient is an implementation of Strategy that talks over RPC.

func (*GRPCClient) BuyConditions

func (m *GRPCClient) BuyConditions(asset string) bool

func (*GRPCClient) GetProperty

func (m *GRPCClient) GetProperty() map[string]interface{}

func (*GRPCClient) Info

func (m *GRPCClient) Info() proto.Information

func (*GRPCClient) Init

func (m *GRPCClient) Init()

func (*GRPCClient) RankFilter

func (m *GRPCClient) RankFilter(asset string) bool

func (*GRPCClient) SellConditions

func (m *GRPCClient) SellConditions(asset string) bool

func (*GRPCClient) SetProperty

func (m *GRPCClient) SetProperty(property map[string]interface{})

type GRPCServer

type GRPCServer struct {
	// This is the real implementation
	Impl Strategy
}

Here is the gRPC server that GRPCClient talks to.

func (*GRPCServer) BuyConditions

func (m *GRPCServer) BuyConditions(ctx context.Context, asset *proto.Asset) (*proto.Bool, error)

func (*GRPCServer) GetProperty

func (m *GRPCServer) GetProperty(context.Context, *proto.Empty) (*proto.Dictionary, error)

func (*GRPCServer) Info

func (*GRPCServer) Init

func (*GRPCServer) RankFilter

func (m *GRPCServer) RankFilter(ctx context.Context, asset *proto.Asset) (*proto.Bool, error)

func (*GRPCServer) SellConditions

func (m *GRPCServer) SellConditions(ctx context.Context, asset *proto.Asset) (*proto.Bool, error)

func (*GRPCServer) SetProperty

func (m *GRPCServer) SetProperty(context context.Context, property *proto.Dictionary) (*proto.Empty, error)

type Strategy

type Strategy interface {
	Init()
	Info() proto.Information
	GetProperty() map[string]interface{}
	SetProperty(map[string]interface{})

	SellConditions(string) bool
	BuyConditions(string) bool
	RankFilter(string) bool
}

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

type StrategyPlugin

type StrategyPlugin struct {
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Strategy
}

This is the implementation of plugin.Plugin so we can serve/consume this. We also implement GRPCPlugin so that this plugin can be served over gRPC.

func (*StrategyPlugin) Client

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

func (*StrategyPlugin) GRPCClient

func (p *StrategyPlugin) GRPCClient(c *grpc.ClientConn) (interface{}, error)

func (*StrategyPlugin) GRPCServer

func (p *StrategyPlugin) GRPCServer(s *grpc.Server) error

func (*StrategyPlugin) Server

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

Jump to

Keyboard shortcuts

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