abcicli

package
v100.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(*types.Request, *types.Response)

type Client

type Client interface {
	service.Service
	types.Application

	// TODO: remove as each method now returns an error
	Error() error
	// TODO: remove as this is not implemented
	Flush(ctx context.Context) error
	Echo(ctx context.Context, echo string) (*types.EchoResponse, error)

	// FIXME: All other operations are run synchronously and rely
	// on the caller to dictate concurrency (i.e. run a go routine),
	// with the exception of `CheckTxAsync` which we maintain
	// for the v0 mempool. We should explore refactoring the
	// mempool to remove this vestige behavior.
	//
	// SetResponseCallback is not used anymore. The callback was invoked only by the mempool on
	// CheckTx responses, only during rechecking. Now the responses are handled by the callback of
	// the *ReqRes struct returned by CheckTxAsync. This callback is more flexible as it allows to
	// pass other information such as the sender.
	//
	// Deprecated: Do not use.
	SetResponseCallback(cb Callback)
	CheckTxAsync(ctx context.Context, req *types.CheckTxRequest) (*ReqRes, error)
}

Client defines the interface for an ABCI client.

NOTE these are client errors, eg. ABCI socket connectivity issues. Application-related errors are reflected in response via ABCI error codes and (potentially) error response.

func NewClient

func NewClient(addr, transport string, mustConnect bool) (client Client, err error)

NewClient returns a new ABCI client of the specified transport type. It returns an error if the transport is not "socket" or "grpc".

func NewGRPCClient

func NewGRPCClient(addr string, mustConnect bool) Client

func NewLocalClient

func NewLocalClient(mtx *cmtsync.Mutex, app types.Application) Client

NewLocalClient creates a local client, which wraps the application interface that Comet as the client will call to the application as the server.

Concurrency control in each client instance is enforced by way of a single mutex. If a mutex is not supplied (i.e. if mtx is nil), then one will be created.

func NewSocketClient

func NewSocketClient(addr string, mustConnect bool) Client

NewSocketClient creates a new socket client, which connects to a given address. If mustConnect is true, the client will return an error upon start if it fails to connect else it will continue to retry.

func NewUnsyncLocalClient

func NewUnsyncLocalClient(app types.Application) Client

NewUnsyncLocalClient creates a local client, which wraps the application interface that Comet as the client will call to the application as the server.

This differs from NewLocalClient in that it returns a client that only maintains a mutex over the callback used by CheckTxAsync and not over the application, leaving it up to the proxy to handle all concurrency. If the proxy does not impose any concurrency restrictions, it is then left up to the application to implement its own concurrency for the relevant group of calls.

type ErrUnexpectedResponse

type ErrUnexpectedResponse struct {
	Response types.Response
	Reason   string
}

func (ErrUnexpectedResponse) Error

func (e ErrUnexpectedResponse) Error() string

type ErrUnknownAbciTransport

type ErrUnknownAbciTransport struct {
	Transport string
}

ErrUnknownAbciTransport is returned when trying to create a client with an invalid transport option.

func (ErrUnknownAbciTransport) Error

func (e ErrUnknownAbciTransport) Error() string

type ReqRes

type ReqRes struct {
	*types.Request
	*sync.WaitGroup
	*types.Response // Not set atomically, so be sure to use WaitGroup.
	// contains filtered or unexported fields
}

func NewReqRes

func NewReqRes(req *types.Request) *ReqRes

func (*ReqRes) GetCallback

func (r *ReqRes) GetCallback() func(*types.Response)

GetCallback returns the configured callback of the ReqRes object which may be nil. Note, it is not safe to concurrently call this in cases where it is marked done and SetCallback is called before calling GetCallback as that will invoke the callback twice and create a potential race condition.

ref: https://github.com/tendermint/tendermint/issues/5439

func (*ReqRes) InvokeCallback

func (r *ReqRes) InvokeCallback()

InvokeCallback invokes a thread-safe execution of the configured callback if non-nil.

func (*ReqRes) SetCallback

func (r *ReqRes) SetCallback(cb func(res *types.Response))

Sets sets the callback. If reqRes is already done, it will call the cb immediately. Note, reqRes.cb should not change if reqRes.done and only one callback is supported.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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