abciclient

package
v1.2.0-dev.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package abciclient provides an ABCI implementation in Go.

There are 3 clients available:

  1. socket (unix or TCP)
  2. local (in memory)
  3. gRPC

## Socket client

The client blocks for enqueuing the request, for enqueuing the Flush to send the request, and for the Flush response to return.

## Local client

The global mutex is locked during each call

## gRPC client

The client waits for all calls to complete.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	service.Service
	types.Application

	Error() error
	Flush(context.Context) error
	Echo(context.Context, string) (*types.ResponseEcho, 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(logger log.Logger, cfg config.AbciConfig, mustConnect bool) (Client, 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(logger log.Logger, addr string, concurrency map[string]uint16, mustConnect bool) Client

NewGRPCClient creates a gRPC client, which will connect to addr upon the start. Note Client#Start returns an error if connection is unsuccessful and mustConnect is true.

func NewLocalClient

func NewLocalClient(logger log.Logger, app types.Application) Client

NewLocalClient creates a local client, which will be directly calling the methods of the given app.

The client methods ignore their context argument.

func NewRoutedClient added in v1.0.0

func NewRoutedClient(logger log.Logger, defaultClient Client, routing Routing) (Client, error)

NewRoutedClient returns a new ABCI client that routes requests to the appropriate underlying client based on the request type.

Arguments

  • `logger` - The logger to use for the client.
  • `defaultClient` - The default client to use when no specific client is configured for a request type.
  • `routing` - The clients to route requests to.

See docs of routedClient.delegate() for more details about implemented logic.

func NewRoutedClientWithAddr added in v1.0.0

func NewRoutedClientWithAddr(logger log.Logger, addr string, mustConnect bool) (Client, error)

NewRoutedClientWithAddr returns a new ABCI client that routes requests to multiple underlying clients based on the request type.

It takes a comma-separated list of routing rules, consisting of colon-separated: request type, transport, address. Special request type "*" is used for default client.

Example:

```

"Info:socket:unix:///tmp/socket.1,Info:socket:unix:///tmp/socket.2,CheckTx:socket:unix:///tmp/socket.1,*:socket:unix:///tmp/socket.3"

```

Arguments

  • `logger` - The logger to use for the client.
  • `addr` - comma-separated list of routing rules, consisting of request type, transport name and client address separated with colon. Special request type "*" is used for default client.

func NewSocketClient

func NewSocketClient(logger log.Logger, 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.

type ClientInfo added in v1.0.0

type ClientInfo struct {
	Client
	// ClientID is an unique, human-readable, client identifier
	ClientID string
}

type RequestType added in v1.0.0

type RequestType string

type Routing added in v1.0.0

type Routing map[RequestType][]ClientInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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