client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOracleServiceFromConfig

func NewOracleServiceFromConfig(cfg config.Config, l log.Logger) (service.OracleService, error)

NewOracleServiceFromConfig reads a config and instantiates either a grpc-client / local-client from a config and returns a new OracleService.

Types

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

GRPCClient defines an implementation of a gRPC oracle client. This client can be used in ABCI++ calls where the application wants the oracle process to be run out-of-process. The client must be started upon app construction and stopped upon app shutdown/cleanup.

func NewGRPCClient

func NewGRPCClient(addr string, t time.Duration) *GRPCClient

NewGRPCClient creates a new grpc client of the oracle service, given the address of the oracle server and a timeout for the client.

func (*GRPCClient) Prices

Prices returns the prices from the remote oracle service. This method blocks for the timeout duration configured on the client, otherwise it returns the response from the remote oracle.

func (*GRPCClient) Start

func (c *GRPCClient) Start(ctx context.Context) error

Start starts the GRPC client. This method dials the remote oracle-service and errors if the connection fails.

func (*GRPCClient) Stop

func (c *GRPCClient) Stop(ctx context.Context) error

Stop stops the GRPC client. This method closes the connection to the remote.

type LocalClient

type LocalClient struct {
	// contains filtered or unexported fields
}

LocalClient defines an implementation of a local, i.e. in-process, oracle client. This client can be used in ABCI++ calls where the application wants the oracle process to be run in-process. The client must be started upon app construction and stopped upon app shutdown/cleanup.

func NewLocalClient

func NewLocalClient(o types.Oracle, t time.Duration) *LocalClient

NewLocalClient returns a new instance of the LocalClient, given an implementation of the Oracle interface and a timeout. Requests to the client will timeout after timeout or if the provided context is cancelled.

func (*LocalClient) Prices

Prices returns the current prices from the oracle. This method blocks until the oracle returns a response or the context is cancelled (via timeout or by caller). This method errors if the oracle is not running, or if the request is nil.

func (*LocalClient) Start

func (c *LocalClient) Start(ctx context.Context) error

Note: Start(ctx) is a blocking call, so the caller will need to run it in a goroutine. This method blocks until the underlying oracle is stopped.

func (*LocalClient) Stop

func (c *LocalClient) Stop(_ context.Context) error

Stop stops the underlying oracle. This method blocks until the underlying oracle is stopped.

Jump to

Keyboard shortcuts

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