Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOracleServiceFromConfig ¶
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 ¶
func (c *GRPCClient) Prices(ctx context.Context, req *service.QueryPricesRequest) (*service.QueryPricesResponse, error)
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.
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 ¶
func (c *LocalClient) Prices(ctx context.Context, req *service.QueryPricesRequest) (*service.QueryPricesResponse, error)
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.