shiroclient

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-3-Clause Imports: 9 Imported by: 2

Documentation

Overview

Package shiroclient provides the ShiroClient interface and one implementations - a mode that connects to a JSON-RPC/HTTP gateway.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePhylumBytes

func EncodePhylumBytes(decoded []byte) string

EncodePhylumBytes takes decoded phylum (lisp code) and encodes it for use with the Init() method.

func IsTimeoutError

func IsTimeoutError(err error) bool

IsTimeoutError inspects an error returned from shiroclient and returns true if it's a timeout.

func UnmarshalProto added in v0.4.1

func UnmarshalProto(src []byte, dst interface{}) error

UnmarshalProto attempts to unmarshal protobuf bytes with backwards compatability.

Types

type Block

type Block = types.Block

Block has summary information about a block.

type Config

type Config = types.Config

Config is a type for a function that can mutate a types.RequestOptions object.

func WithAuthToken

func WithAuthToken(token string) Config

WithAuthToken passes authorization for the transaction issuer with a request.

func WithCCFetchURLDowngrade

func WithCCFetchURLDowngrade(downgrade bool) Config

WithCCFetchURLDowngrade allows controlling https -> http downgrade, typically useful before proxying for ccfetchurl library.

func WithCCFetchURLProxy

func WithCCFetchURLProxy(proxy *url.URL) Config

WithCCFetchURLProxy sets the proxy for ccfetchurl library.

func WithCreator

func WithCreator(creator string) Config

WithCreator allows specifying the creator. Only has effect in mock mode. Also works in gateway mock mode.

func WithDependentBlock added in v0.5.0

func WithDependentBlock(block string) Config

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

func WithDependentTxID(txID string) Config

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

func WithDisableWritePolling(disable bool) Config

WithDisableWritePolling allows disabling polling for full consensus after a write is committed.

func WithEndpoint

func WithEndpoint(endpoint string) Config

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

func WithHTTPClient(client *http.Client) Config

WithHTTPClient allows specifying an overriding client for HTTP requests. This is helpful for testing.

func WithHeader

func WithHeader(key string, value string) Config

WithHeader allows specifying an additional HTTP header.

func WithID

func WithID(id string) Config

WithID allows specifying the request ID. If the request ID is not specified, a randomly-generated UUID will be used.

func WithLog

func WithLog(log *logrus.Logger) Config

WithLog allows specifying the logger to use.

func WithLogField

func WithLogField(key string, value interface{}) Config

WithLogField allows specifying a log field to be included.

func WithLogrusFields

func WithLogrusFields(fields logrus.Fields) Config

WithLogrusFields allows specifying multiple log fields to be included.

func WithMSPFilter

func WithMSPFilter(mspFilter []string) Config

WithMSPFilter allows specifying the MSP filter. Has no effect in mock mode.

func WithMinEndorsers

func WithMinEndorsers(minEndorsers int) Config

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

func WithPhylumVersion(phylumVersion string) Config

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 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

func WithTargetEndpoints(nameOrURL []string) Config

WithTargetEndpoints allows specifying which exact peers will be used to process the transaction. Specifcy a name or URL of the peer.

func WithTimestampGenerator

func WithTimestampGenerator(timestampGenerator func(context.Context) string) Config

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

func WithTransientData(key string, val []byte) Config

WithTransientData allows specifying a single "transient data" key-value pair.

func WithTransientDataMap

func WithTransientDataMap(data map[string][]byte) Config

WithTransientDataMap allows specifying multiple "transient data" key-value pairs.

type Error

type Error types.Error

Error is a generic application error.

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.

func NewMock

func NewMock(clientConfigs []Config, opts ...mock.Option) (MockShiroClient, error)

NewMock creates a new mock ShiroClient with the given set of base configs that will be applied to all commands.

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 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.

Jump to

Keyboard shortcuts

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