Documentation ¶
Overview ¶
Package shiroclient provides the ShiroClient interface and one implementations - a mode that connects to a JSON-RPC/HTTP gateway.
Index ¶
- func EncodePhylumBytes(decoded []byte) string
- func IsTimeoutError(err error) bool
- func UnmarshalProto(src []byte, dst interface{}) error
- type Block
- type Config
- func WithAuthToken(token string) Config
- func WithCCFetchURLDowngrade(downgrade bool) Config
- func WithCCFetchURLProxy(proxy *url.URL) Config
- func WithCreator(creator string) Config
- func WithDependentBlock(block string) Config
- func WithDependentTxID(txID string) Config
- func WithDisableWritePolling(disable bool) Config
- func WithEndpoint(endpoint string) Config
- func WithHTTPClient(client *http.Client) Config
- func WithHeader(key string, value string) Config
- func WithID(id string) Config
- func WithLog(log *logrus.Logger) Config
- func WithLogField(key string, value interface{}) Config
- func WithLogrusFields(fields logrus.Fields) Config
- func WithMSPFilter(mspFilter []string) Config
- func WithMinEndorsers(minEndorsers int) Config
- func WithParams(params interface{}) Config
- func WithPhylumVersion(phylumVersion string) Config
- func WithResponse(target *interface{}) Config
- func WithResponseReceiver(get func(resp ShiroResponse)) Config
- func WithSingleton() Config
- func WithTargetEndpoints(nameOrURL []string) Config
- func WithTimestampGenerator(timestampGenerator func(context.Context) string) Config
- func WithTransientData(key string, val []byte) Config
- func WithTransientDataMap(data map[string][]byte) Config
- func WithoutTargetEndpoints(nameOrURL []string) Config
- type Error
- type HealthCheck
- type HealthCheckReport
- type MockShiroClient
- type ShiroClient
- type ShiroResponse
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodePhylumBytes ¶
EncodePhylumBytes takes decoded phylum (lisp code) and encodes it for use with the Init() method.
func IsTimeoutError ¶
IsTimeoutError inspects an error returned from shiroclient and returns true if it's a timeout.
func UnmarshalProto ¶ added in v0.4.1
UnmarshalProto attempts to unmarshal protobuf bytes with backwards compatability.
Types ¶
type Config ¶
Config is a type for a function that can mutate a types.RequestOptions object.
func WithAuthToken ¶
WithAuthToken passes authorization for the transaction issuer with a request.
func WithCCFetchURLDowngrade ¶
WithCCFetchURLDowngrade allows controlling https -> http downgrade, typically useful before proxying for ccfetchurl library.
func WithCCFetchURLProxy ¶
WithCCFetchURLProxy sets the proxy for ccfetchurl library.
func WithCreator ¶
WithCreator allows specifying the creator. Only has effect in mock mode. Also works in gateway mock mode.
func WithDependentBlock ¶ added in v0.5.0
WithDependentBlock allows specifying a dependency on a block. If set, the client will poll for the presence of that block before simulating the request on the peer with the block.
func WithDependentTxID ¶
WithDependentTxID allows specifying a dependency on a transaction ID. If set, the client will poll for the presence of that transaction before simulating the request on the peer with the transaction.
func WithDisableWritePolling ¶
WithDisableWritePolling allows disabling polling for full consensus after a write is committed.
func WithEndpoint ¶
WithEndpoint allows specifying the endpoint to target. The RPC implementation will not work if an endpoint is not specified.
func WithHTTPClient ¶ added in v0.5.0
WithHTTPClient allows specifying an overriding client for HTTP requests. This is helpful for testing.
func WithHeader ¶
WithHeader allows specifying an additional HTTP header.
func WithID ¶
WithID allows specifying the request ID. If the request ID is not specified, a randomly-generated UUID will be used.
func WithLogField ¶
WithLogField allows specifying a log field to be included.
func WithLogrusFields ¶
WithLogrusFields allows specifying multiple log fields to be included.
func WithMSPFilter ¶
WithMSPFilter allows specifying the MSP filter. Has no effect in mock mode.
func WithMinEndorsers ¶
WithMinEndorsers allows specifying the minimum number of endorsing peers. Has no effect in mock mode.
func WithParams ¶
func WithParams(params interface{}) Config
WithParams allows specifying the phylum "parameters" argument. This must be set to something that json.Marshal accepts.
func WithPhylumVersion ¶ added in v0.5.0
WithPhylumVersion allows set a specific version of the phylum to simulate the transaction on. This overrides the default version set in the gateway.
func WithResponse ¶
func WithResponse(target *interface{}) Config
WithResponse allows capturing the RPC response for futher analysis.
func WithResponseReceiver ¶ added in v0.12.0
func WithResponseReceiver(get func(resp ShiroResponse)) Config
WithResponseReceiver allows retrieving the shiro response directly.
func WithSingleton ¶ added in v0.4.1
func WithSingleton() Config
WithSingleton is useful for creating new config types.Options that do not take arguments.
func WithTargetEndpoints ¶ added in v0.9.0
WithTargetEndpoints allows specifying which exact peers will be used to process the transaction. Specifcy a name or URL of the peer.
func WithTimestampGenerator ¶
WithTimestampGenerator allows specifying a function that will be invoked at every Init or Call whose output is used to set the substrate "now" timestamp in mock mode. Has no effect outside of mock mode.
func WithTransientData ¶
WithTransientData allows specifying a single "transient data" key-value pair.
func WithTransientDataMap ¶
WithTransientDataMap allows specifying multiple "transient data" key-value pairs.
func WithoutTargetEndpoints ¶ added in v0.10.0
WithoutTargetEndpoints allows specifying which exact peers will not be used to process the transaction. Specifcy a name or URL of the peer.
type HealthCheck ¶ added in v0.2.0
type HealthCheck = rpc.HealthCheck
HealthCheck is a collection of reports detailing connectivity and health of system components (e.g. phylum, RPC gateway, etc). See RemoteHealthCheck.
func RemoteHealthCheck ¶ added in v0.2.0
func RemoteHealthCheck(ctx context.Context, client ShiroClient, services []string, configs ...Config) (HealthCheck, error)
RemoteHealthCheck checks connectivity between the SDK client (e.g. oracle service) and upstream services including the phylum itself. If the list of upstream services is empty the behavior of RemoteHealthCheck depends on client's implementation. Clients created with NewMock do not support upstream service enumeration and will always invoke the mock phylum "healthcheck" endpoint.
For clients that support RemoteHealthCheck service enumeration, like those created with NewRPC, services should be specified using canonical names
phylum shiroclient_gateway fabric_peer ...
Unrecognized service names are ignored, though may still be sent to upstream gateways.
NOTE: An RPC gateway must be a recent enough version to support specification of upstream services or it will otherwise fallback to invoking the phylum healthcheck endpoint.
type HealthCheckReport ¶ added in v0.2.0
type HealthCheckReport = rpc.HealthCheckReport
HealthCheckReport details the connectivity/health of an individual system component as part of a HealthCheck. When inspecting HealthCheckReports a service should only be considered operational if its reported status is "UP". Any other status indicates a potential service interruption.
for _, report := range healthcheck { if report.Status != "UP" { ringAlarm(report) } }
type MockShiroClient ¶
type MockShiroClient = imock.MockShiroClient
MockShiroClient is an abstraction for a ShiroClient that is backed by an in-process lightweight ledger. This uses the hashicorp plugin.
type ShiroClient ¶
type ShiroClient = types.ShiroClient
ShiroClient interfaces with blockchain-based smart contract execution engine. Currently, the "phylum" code must be written in a LISP dialect known as ELPS.
func NewRPC ¶
func NewRPC(clientConfigs []Config) ShiroClient
NewRPC creates a new RPC ShiroClient with the given set of base configs that will be applied to all commands.
type ShiroResponse ¶
type ShiroResponse = types.ShiroResponse
ShiroResponse is a wrapper for a response from a shiro chaincode. Even if the chaincode was invoked successfully, it may have signaled an error.
type Transaction ¶
type Transaction types.Transaction
Transaction has summary information about a transaction.
Directories ¶
Path | Synopsis |
---|---|
Package batch allows registering callbacks to handle requests issued by the substrate batching mechanism.
|
Package batch allows registering callbacks to handle requests issued by the substrate batching mechanism. |
Package mock provides utilities for configuring a mock (in-memory) shiroclient.
|
Package mock provides utilities for configuring a mock (in-memory) shiroclient. |
Package phylum provides a simple way to interact with shiroclient.
|
Package phylum provides a simple way to interact with shiroclient. |
Package private enables the secure processing of PII data within substrate.
|
Package private enables the secure processing of PII data within substrate. |
Package update manages phylum versions installed on substrate.
|
Package update manages phylum versions installed on substrate. |