Documentation
¶
Index ¶
- Constants
- Variables
- func ToReqPrices(prices types.Prices) map[string]string
- type OracleServer
- func (os *OracleServer) Close() error
- func (os *OracleServer) Done() <-chan struct{}
- func (os *OracleServer) MarketMap(_ context.Context, _ *types.QueryMarketMapRequest) (*types.QueryMarketMapResponse, error)
- func (os *OracleServer) Prices(ctx context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error)
- func (os *OracleServer) StartServer(ctx context.Context, host, port string) error
- func (os *OracleServer) StartServerWithListener(ctx context.Context, ln net.Listener) error
- func (os *OracleServer) Version(_ context.Context, _ *types.QueryVersionRequest) (*types.QueryVersionResponse, error)
- type OracleService
Constants ¶
const DefaultServerShutdownTimeout = 3 * time.Second
Variables ¶
Functions ¶
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 ¶
func (os *OracleServer) MarketMap(_ context.Context, _ *types.QueryMarketMapRequest) (*types.QueryMarketMapResponse, error)
MarketMap returns the current market map from the Oracle.
func (*OracleServer) Prices ¶
func (os *OracleServer) Prices(ctx context.Context, req *types.QueryPricesRequest) (*types.QueryPricesResponse, error)
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) StartServerWithListener ¶
StartServerWithListener starts the oracle gRPC server with a given listener. 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 ¶
func (os *OracleServer) Version(_ context.Context, _ *types.QueryVersionRequest) (*types.QueryVersionResponse, error)
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.