Documentation ¶
Overview ¶
Package plugin includes helpers for the substrate plugin implementation to extract configuration arguments. WARNING: This is unstable will be removed in later versions.
Package plugin includes helpers for the substrate plugin implementation to extract configuration arguments. WARNING: This is unstable and really should only be used by the underlying substrate implementation. It will be removed in later versions.
Index ¶
- func Connect(user func(Substrate) error, opts ...ConnectOption) error
- func ConnectWithAttachStdamp(attachStdamp io.Writer) func(co *connectOption) error
- func ConnectWithCommand(command string) func(co *connectOption) error
- func ConnectWithLogLevel(level hclog.Level) func(co *connectOption) error
- func NewFailureResponse(code int, message string, data []byte) types.ShiroResponse
- func NewShiroClientBlock(blk *Block) types.Block
- func NewSuccessResponse(result []byte, txID string) types.ShiroResponse
- func PluginArgs(configs []types.Config) pluginArgs
- func PluginAuthToken(p pluginArgs) string
- func PluginCcFetchURLDowngrade(p pluginArgs) bool
- func PluginCcFetchURLProxy(p pluginArgs) *url.URL
- func PluginCreator(p pluginArgs) string
- func PluginCtx(p pluginArgs) context.Context
- func PluginID(p pluginArgs) string
- func PluginLogFields(p pluginArgs) logrus.Fields
- func PluginParams(p pluginArgs) interface{}
- func PluginPhylumVersion(p pluginArgs) string
- func PluginTimestampGenerator(p pluginArgs) func(context.Context) string
- func PluginTransient(p pluginArgs) map[string][]byte
- type ArgsCall
- type ArgsCloseMock
- type ArgsHealthCheck
- type ArgsInit
- type ArgsNewMockFrom
- type ArgsQueryBlock
- type ArgsQueryInfo
- type ArgsSetCreatorWithAttributesMock
- type ArgsSnapshotMock
- type Block
- type ConcreteRequestOptions
- type ConnectOption
- type Error
- type Plugin
- type PluginRPC
- func (g *PluginRPC) Call(tag string, command string, options *ConcreteRequestOptions) (*Response, error)
- func (g *PluginRPC) CloseMock(tag string) error
- func (g *PluginRPC) HealthCheck(nat int) (int, error)
- func (g *PluginRPC) Init(tag string, phylum string, options *ConcreteRequestOptions) error
- func (g *PluginRPC) NewMockFrom(name string, version string, snapshot []byte) (string, error)
- func (g *PluginRPC) QueryBlock(tag string, height uint64, options *ConcreteRequestOptions) (*Block, error)
- func (g *PluginRPC) QueryInfo(tag string, options *ConcreteRequestOptions) (uint64, error)
- func (g *PluginRPC) SetCreatorWithAttributesMock(tag string, creator string, attrs map[string]string) error
- func (g *PluginRPC) SnapshotMock(tag string) ([]byte, error)
- type PluginRPCServer
- func (s *PluginRPCServer) Call(args *ArgsCall, resp *RespCall) error
- func (s *PluginRPCServer) CloseMock(args *ArgsCloseMock, resp *RespCloseMock) error
- func (s *PluginRPCServer) HealthCheck(args *ArgsHealthCheck, resp *RespHealthCheck) error
- func (s *PluginRPCServer) Init(args *ArgsInit, resp *RespInit) error
- func (s *PluginRPCServer) NewMockFrom(args *ArgsNewMockFrom, resp *RespNewMockFrom) error
- func (s *PluginRPCServer) QueryBlock(args *ArgsQueryBlock, resp *RespQueryBlock) error
- func (s *PluginRPCServer) QueryInfo(args *ArgsQueryInfo, resp *RespQueryInfo) error
- func (s *PluginRPCServer) SetCreatorWithAttributesMock(args *ArgsSetCreatorWithAttributesMock, resp *RespSetCreatorWithAttributesMock) error
- func (s *PluginRPCServer) SnapshotMock(args *ArgsSnapshotMock, resp *RespSnapshotMock) error
- type RespCall
- type RespCloseMock
- type RespHealthCheck
- type RespInit
- type RespNewMockFrom
- type RespQueryBlock
- type RespQueryInfo
- type RespSetCreatorWithAttributesMock
- type RespSnapshotMock
- type Response
- type Substrate
- type SubstrateConnection
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(user func(Substrate) error, opts ...ConnectOption) error
Connect connects to a plugin synchronously; all operations on the Substrate interface must be performed from within the passed closure.
func ConnectWithAttachStdamp ¶
ConnectWithAttachStdamp specifies an io.Writer to receive stdio output from the plugin
func ConnectWithCommand ¶
ConnectWithCommand specifies the path to the plugin (the default is "")
func ConnectWithLogLevel ¶
ConnectWithLogLevel specifies the log level to use (the default is Debug)
func NewFailureResponse ¶
func NewFailureResponse(code int, message string, data []byte) types.ShiroResponse
NewFailureResponse is used by the plugin to return failure ShiroResponse.
func NewShiroClientBlock ¶
NewShiroClientBlock is used by the plugin to return transaction details.
func NewSuccessResponse ¶
func NewSuccessResponse(result []byte, txID string) types.ShiroResponse
NewSuccessResponse is used by the plugin to return success ShiroResponse.
func PluginArgs ¶
func PluginAuthToken ¶
func PluginAuthToken(p pluginArgs) string
func PluginCcFetchURLDowngrade ¶
func PluginCcFetchURLDowngrade(p pluginArgs) bool
func PluginCcFetchURLProxy ¶
func PluginCreator ¶
func PluginCreator(p pluginArgs) string
func PluginLogFields ¶
func PluginParams ¶
func PluginParams(p pluginArgs) interface{}
func PluginPhylumVersion ¶
func PluginPhylumVersion(p pluginArgs) string
func PluginTransient ¶
Types ¶
type ArgsCall ¶
type ArgsCall struct { Tag string Command string Options *ConcreteRequestOptions }
ArgsCall encodes the arguments to Call
type ArgsCloseMock ¶
type ArgsCloseMock struct {
Tag string
}
ArgsCloseMock encodes the arguments to CloseMock
type ArgsHealthCheck ¶
type ArgsHealthCheck struct {
Nat int
}
ArgsHealthCheck encodes the arguments to HealthCheck
type ArgsInit ¶
type ArgsInit struct { Tag string Phylum string Options *ConcreteRequestOptions }
ArgsInit encodes the arguments to Init
type ArgsNewMockFrom ¶
ArgsNewMockFrom encodes the arguments to NewMockFrom
type ArgsQueryBlock ¶
type ArgsQueryBlock struct { Tag string Height uint64 Options *ConcreteRequestOptions }
ArgsQueryBlock encodes the arguments to QueryBlock
type ArgsQueryInfo ¶
type ArgsQueryInfo struct { Tag string Options *ConcreteRequestOptions }
ArgsQueryInfo encodes the arguments to QueryInfo
type ArgsSetCreatorWithAttributesMock ¶
ArgsSetCreatorWithAttributesMock encodes the arguments to SetCreatorWithAttributesMock
type ArgsSnapshotMock ¶
type ArgsSnapshotMock struct {
Tag string
}
ArgsSnapshotMock encodes the arguments to SnapshotMock
type Block ¶
type Block struct { Hash string Transactions []*Transaction }
Block represents summary information about a block.
type ConcreteRequestOptions ¶
type ConcreteRequestOptions struct { Headers map[string]string Endpoint string ID string AuthToken string Params []byte Transient map[string][]byte Timestamp string MSPFilter []string MinEndorsers int Creator string DependentTxID string DisableWritePolling bool CCFetchURLDowngrade bool CCFetchURLProxy string PhylumVersion string DependentBlock string }
ConcreteRequestOptions is a variant of RequestOptions that is "flattened" to pure data.
type ConnectOption ¶
type ConnectOption func(co *connectOption) error
ConnectOption represents the type of a builder action for connectOption
type Plugin ¶
type Plugin struct { // Impl Injection Impl Substrate }
Plugin is the implementation of plugin.Plugin so we can serve/consume this.
Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.
type PluginRPC ¶
type PluginRPC struct {
// contains filtered or unexported fields
}
PluginRPC is an implementation that talks over RPC
func (*PluginRPC) Call ¶
func (g *PluginRPC) Call(tag string, command string, options *ConcreteRequestOptions) (*Response, error)
Call forwards the call
func (*PluginRPC) HealthCheck ¶
HealthCheck forwards the call
func (*PluginRPC) Init ¶
func (g *PluginRPC) Init(tag string, phylum string, options *ConcreteRequestOptions) error
Init forwards the call
func (*PluginRPC) NewMockFrom ¶
NewMockFrom forwards the call
func (*PluginRPC) QueryBlock ¶
func (g *PluginRPC) QueryBlock(tag string, height uint64, options *ConcreteRequestOptions) (*Block, error)
QueryBlock forwards the call
func (*PluginRPC) QueryInfo ¶
func (g *PluginRPC) QueryInfo(tag string, options *ConcreteRequestOptions) (uint64, error)
QueryInfo forwards the call
type PluginRPCServer ¶
type PluginRPCServer struct { // This is the real implementation Impl Substrate }
PluginRPCServer is the RPC server that PluginRPC talks to, conforming to the requirements of net/rpc
func (*PluginRPCServer) Call ¶
func (s *PluginRPCServer) Call(args *ArgsCall, resp *RespCall) error
Call forwards the call
func (*PluginRPCServer) CloseMock ¶
func (s *PluginRPCServer) CloseMock(args *ArgsCloseMock, resp *RespCloseMock) error
CloseMock forwards the call
func (*PluginRPCServer) HealthCheck ¶
func (s *PluginRPCServer) HealthCheck(args *ArgsHealthCheck, resp *RespHealthCheck) error
HealthCheck forwards the call
func (*PluginRPCServer) Init ¶
func (s *PluginRPCServer) Init(args *ArgsInit, resp *RespInit) error
Init forwards the call
func (*PluginRPCServer) NewMockFrom ¶
func (s *PluginRPCServer) NewMockFrom(args *ArgsNewMockFrom, resp *RespNewMockFrom) error
NewMockFrom forwards the call
func (*PluginRPCServer) QueryBlock ¶
func (s *PluginRPCServer) QueryBlock(args *ArgsQueryBlock, resp *RespQueryBlock) error
QueryBlock forwards the call
func (*PluginRPCServer) QueryInfo ¶
func (s *PluginRPCServer) QueryInfo(args *ArgsQueryInfo, resp *RespQueryInfo) error
QueryInfo forwards the call
func (*PluginRPCServer) SetCreatorWithAttributesMock ¶
func (s *PluginRPCServer) SetCreatorWithAttributesMock(args *ArgsSetCreatorWithAttributesMock, resp *RespSetCreatorWithAttributesMock) error
SetCreatorWithAttributesMock forwards the call
func (*PluginRPCServer) SnapshotMock ¶
func (s *PluginRPCServer) SnapshotMock(args *ArgsSnapshotMock, resp *RespSnapshotMock) error
SnapshotMock forwards the call
type RespCloseMock ¶
type RespCloseMock struct {
Err *Error
}
RespCloseMock encodes the response from CloseMock
type RespHealthCheck ¶
type RespHealthCheck struct {
Suc int
}
RespHealthCheck encodes the response from HealthCheck
type RespNewMockFrom ¶
RespNewMockFrom encodes the response from NewMockFrom
type RespQueryBlock ¶
RespQueryBlock encodes the response from QueryBlock
type RespQueryInfo ¶
RespQueryInfo encodes the response from QueryInfo
type RespSetCreatorWithAttributesMock ¶
type RespSetCreatorWithAttributesMock struct {
Err *Error
}
RespSetCreatorWithAttributesMock encodes the response from SetCreatorWithAttributesMock
type RespSnapshotMock ¶
RespSnapshotMock encodes the response from SnapshotMock
type Response ¶
type Response struct { ResultJSON []byte HasError bool ErrorCode int ErrorMessage string ErrorJSON []byte TransactionID string }
Response represents a shiroclient response.
func (*Response) UnmarshalTo ¶
UnmarshalTo unmarshals the response's result to dst.
type Substrate ¶
type Substrate interface { HealthCheck(int) (int, error) NewMockFrom(string, string, []byte) (string, error) SetCreatorWithAttributesMock(string, string, map[string]string) error SnapshotMock(string) ([]byte, error) CloseMock(string) error Init(string, string, *ConcreteRequestOptions) error Call(string, string, *ConcreteRequestOptions) (*Response, error) QueryInfo(string, *ConcreteRequestOptions) (uint64, error) QueryBlock(string, uint64, *ConcreteRequestOptions) (*Block, error) }
Substrate is the interface that we're exposing as a plugin.
type SubstrateConnection ¶
type SubstrateConnection struct {
// contains filtered or unexported fields
}
SubstrateConnection interacts with the underlying plugin.
func NewSubstrateConnection ¶
func NewSubstrateConnection(opts ...ConnectOption) (*SubstrateConnection, error)
NewSubstrateConnection connects to a plugin in the background.
func (*SubstrateConnection) Close ¶
func (s *SubstrateConnection) Close() error
Close closes a connection.
func (*SubstrateConnection) GetSubstrate ¶
func (s *SubstrateConnection) GetSubstrate() Substrate
GetSubstrate returns the Substrate interface associated with a connection.