oracle

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultServerShutdownTimeout = 3 * time.Second

Variables

View Source
var (
	ErrNilRequest       = errors.New("request cannot be nil")
	ErrOracleNotRunning = errors.New("oracle is not running")
	ErrContextCancelled = errors.New("context cancelled")
)

Functions

func ToReqPrices

func ToReqPrices(prices types.Prices) map[string]string

Types

type OracleServer

type OracleServer struct {
	types.UnimplementedOracleServer

	// closer to handle graceful closures from multiple go-routines
	*sync.Closer
	// contains filtered or unexported fields
}

OracleServer is the base implementation of the service.OracleServer interface, this is meant to serve requests from a remote OracleClient.

func NewOracleServer

func NewOracleServer(o oracle.Oracle, logger *zap.Logger) *OracleServer

NewOracleServer returns a new instance of the OracleServer, given an implementation of the Oracle interface.

func (*OracleServer) Close

func (os *OracleServer) Close() error

Close closes the underlying oracle server, and blocks until all open requests have been satisfied.

func (*OracleServer) Done

func (os *OracleServer) Done() <-chan struct{}

Done returns a channel that is closed when the oracle server is closed.

func (*OracleServer) MarketMap

MarketMap returns the current market map from the Oracle.

func (*OracleServer) Prices

Prices calls the underlying oracle's implementation of GetPrices. It defers to the ctx in the request, and errors if the context is cancelled for any reason, or if the oracle errors.

func (*OracleServer) StartServer

func (os *OracleServer) StartServer(ctx context.Context, host, port string) error

StartServer starts the oracle gRPC server on the given host and port. The server is killed on any errors from the listener, or if ctx is cancelled. This method returns an error via any failure from the listener. This is a blocking call, i.e. until the server is closed or the server errors, this method will block.

func (*OracleServer) Version

Version returns the version of the oracle server.

type OracleService

type OracleService interface {
	types.OracleServer

	Start(context.Context) error
	Stop(context.Context) error
}

OracleService defines the service all clients must implement.

Directories

Path Synopsis
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

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