vplugin

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package vplugin contains the generic and externalized plugin interface for PAM. This allows closed source implementations to be used with valkyrie as plugins.

Index

Constants

View Source
const (
	RPCSystem  = "net/rpc"
	RPCService = "vplugin.PluginPAM"
)

Variables

View Source
var (
	MagicCookieKey = "BASIC_VPLUGIN"
	// MagicCookieValue is not sensitive, it's used to do a basic handshake between
	// a plugin and host. If the handshake fails, a user-friendly error is shown.
	// It is a UX feature, not a security feature.
	MagicCookieValue = "ff912fb194609a432cfe8d504951f133a0a21b18"
)
View Source
var PluginConfig func(string, string) plugin.ClientConfig = func(name, path string) plugin.ClientConfig {
	return plugin.ClientConfig{
		HandshakeConfig: plugin.HandshakeConfig{
			ProtocolVersion:  1,
			MagicCookieKey:   MagicCookieKey,
			MagicCookieValue: MagicCookieValue,
		},
		Plugins: map[string]plugin.Plugin{
			name: &VPlugin{},
		},
		Cmd:    exec.Command(path),
		Logger: NewZerologAdapter(),
	}
}

Functions

func NewZerologAdapter added in v0.4.0

func NewZerologAdapter() *zerologAdapter

func RegisterGobs

func RegisterGobs()

Types

type PAM

type PAM interface {
	// GetSession Return session
	GetSession(pam.GetSessionRequest) *pam.SessionResponse
	// RefreshSession returns a new session token
	RefreshSession(pam.RefreshSessionRequest) *pam.SessionResponse
	// GetBalance get balance from PAM
	GetBalance(pam.GetBalanceRequest) *pam.BalanceResponse
	// GetTransactions get transactions from pam
	GetTransactions(pam.GetTransactionsRequest) *pam.GetTransactionsResponse
	// AddTransaction returns transactionId and balance. When transaction fails balance
	// can still be returned. On failure error will be returned
	AddTransaction(pam.AddTransactionRequest) *pam.AddTransactionResponse
	// GetGameRound gets gameRound from PAM
	GetGameRound(pam.GetGameRoundRequest) *pam.GameRoundResponse
	// GetTransactionSupplier return the type of transaction supplier the PAM supports
	GetTransactionSupplier() pam.TransactionSupplier
	PluginControl
}

PamClient Interface describing available PAM operations. The implementing plugins are expected to fulfill this interface.

type PluginControl

type PluginControl interface {
	// Init passes configuration to plugins which are expected to report
	// any startup issues as errors.
	Init(PluginInitConfig) error
}

type PluginInitConfig

type PluginInitConfig = map[string]any

PluginInitConfig is passed to the plugin at startup

type PluginPAM added in v0.5.0

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

func Create

func Create(ctx context.Context, cfg configs.PamConf) (*PluginPAM, error)

func (*PluginPAM) AddTransaction added in v0.5.0

func (*PluginPAM) GetBalance added in v0.5.0

func (vp *PluginPAM) GetBalance(rm pam.GetBalanceRequestMapper) (*pam.Balance, error)

func (*PluginPAM) GetGameRound added in v0.5.0

func (vp *PluginPAM) GetGameRound(rm pam.GetGameRoundRequestMapper) (*pam.GameRound, error)

func (*PluginPAM) GetSession added in v0.5.0

func (vp *PluginPAM) GetSession(rm pam.GetSessionRequestMapper) (*pam.Session, error)

func (*PluginPAM) GetTransactionSupplier added in v0.6.0

func (vp *PluginPAM) GetTransactionSupplier() pam.TransactionSupplier

func (*PluginPAM) GetTransactions added in v0.5.0

func (vp *PluginPAM) GetTransactions(rm pam.GetTransactionsRequestMapper) ([]pam.Transaction, error)

func (*PluginPAM) RefreshSession added in v0.5.0

func (vp *PluginPAM) RefreshSession(rm pam.RefreshSessionRequestMapper) (*pam.Session, error)

type VPlugin

type VPlugin struct {
	Impl PAM
}

func (VPlugin) Client

func (VPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client func is part of plugin.Plugin interface

func (*VPlugin) Server

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

type VPluginRPC added in v0.5.0

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

func (*VPluginRPC) AddTransaction added in v0.5.0

func (*VPluginRPC) GetBalance added in v0.5.0

func (vp *VPluginRPC) GetBalance(req pam.GetBalanceRequest) *pam.BalanceResponse

func (*VPluginRPC) GetGameRound added in v0.5.0

func (vp *VPluginRPC) GetGameRound(req pam.GetGameRoundRequest) *pam.GameRoundResponse

func (*VPluginRPC) GetSession added in v0.5.0

func (vp *VPluginRPC) GetSession(req pam.GetSessionRequest) *pam.SessionResponse

func (*VPluginRPC) GetTransactionSupplier added in v0.6.0

func (vp *VPluginRPC) GetTransactionSupplier() pam.TransactionSupplier

func (*VPluginRPC) GetTransactions added in v0.5.0

func (*VPluginRPC) Init added in v0.5.0

func (vp *VPluginRPC) Init(cfg PluginInitConfig) error

func (*VPluginRPC) RefreshSession added in v0.5.0

func (vp *VPluginRPC) RefreshSession(req pam.RefreshSessionRequest) *pam.SessionResponse

type VPluginRPCServer added in v0.5.0

type VPluginRPCServer struct {
	Impl PAM
}

func (*VPluginRPCServer) AddTransaction added in v0.5.0

func (pp *VPluginRPCServer) AddTransaction(args any, resp *pam.AddTransactionResponse) error

func (*VPluginRPCServer) GetBalance added in v0.5.0

func (pp *VPluginRPCServer) GetBalance(args any, response *pam.BalanceResponse) error

func (*VPluginRPCServer) GetGameRound added in v0.5.0

func (pp *VPluginRPCServer) GetGameRound(args any, resp *pam.GameRoundResponse) error

func (*VPluginRPCServer) GetSession added in v0.5.0

func (pp *VPluginRPCServer) GetSession(args any, resp *pam.SessionResponse) error

func (*VPluginRPCServer) GetTransactionSupplier added in v0.6.0

func (pp *VPluginRPCServer) GetTransactionSupplier(args any, resp *pam.TransactionSupplier) error

func (*VPluginRPCServer) GetTransactions added in v0.5.0

func (pp *VPluginRPCServer) GetTransactions(args any, resp *pam.GetTransactionsResponse) error

func (*VPluginRPCServer) Init added in v0.5.0

func (pp *VPluginRPCServer) Init(args any, resp *any) error

func (*VPluginRPCServer) RefreshSession added in v0.5.0

func (pp *VPluginRPCServer) RefreshSession(args any, resp *pam.SessionResponse) error

Jump to

Keyboard shortcuts

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