Documentation ¶
Overview ¶
Package api contains code for running the gRPC server.
In order to add a new gRPC endpoint, add proto content (rpc call, request and response messages), then add the endpoint function implementation in `api/somefile.go`. Example:
func (s *tradingService) SomeNewEndpoint( ctx context.Context, req *protoapi.SomeNewEndpointRequest, ) (*protoapi.SomeNewEndpointResponse, error) { /* Implementation goes here */ return &protoapi.SomeNewEndpointResponse{/* ... */}, nil }
Add a test for the newly created endpoint in `api/trading_test.go`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChainNotConnected signals to the user that he cannot access a given endpoint // which require the chain, but the chain is actually offline. ErrChainNotConnected = errors.New("chain not connected") // ErrChannelClosed signals that the channel streaming data is closed. ErrChannelClosed = errors.New("channel closed") // ErrEmptyMissingMarketID signals to the caller that the request expected a // market id but the field is missing or empty. ErrEmptyMissingMarketID = errors.New("empty or missing market ID") // ErrEmptyMissingOrderID signals to the caller that the request expected an // order id but the field is missing or empty. ErrEmptyMissingOrderID = errors.New("empty or missing order ID") // ErrEmptyMissingOrderReference signals to the caller that the request expected an // order reference but the field is missing or empty. ErrEmptyMissingOrderReference = errors.New("empty or missing order reference") // ErrEmptyMissingPartyID signals to the caller that the request expected a // party id but the field is missing or empty. ErrEmptyMissingPartyID = errors.New("empty or missing party ID") // ErrEmptyMissingSinceTimestamp signals to the caller that the request expected a // timestamp but the field is missing or empty. ErrEmptyMissingSinceTimestamp = errors.New("empty or missing since-timestamp") // ErrServerShutdown signals to the client that the server is shutting down. ErrServerShutdown = errors.New("server shutdown") // ErrStreamClosed signals to the users that the grpc stream is closing. ErrStreamClosed = errors.New("stream closed") // ErrStreamInternal signals to the users that the grpc stream has an internal problem. ErrStreamInternal = errors.New("internal stream failure") // ErrNotMapped is when an error cannot be found in the current error map/lookup table. ErrNotMapped = errors.New("error not found in error lookup table") // ErrInvalidMarketID signals that the market ID does not exists. ErrInvalidMarketID = errors.New("invalid market ID") // ErrMissingOrder signals that the actual payload is expected to contains an order. ErrMissingOrder = errors.New("missing order in request payload") // ErrMissingPartyID signals that the payload is expected to contain a party id. ErrMissingPartyID = errors.New("missing party id") // ErrMalformedRequest signals that the request was malformed. ErrMalformedRequest = errors.New("malformed request") // ErrMissingAsset signals that an asset was required but not specified. ErrMissingAsset = errors.New("missing asset") // ErrSubmitOrder is returned when submitting an order fails for some reason. ErrSubmitOrder = errors.New("submit order failure") // ErrAmendOrder is returned when amending an order fails for some reason. ErrAmendOrder = errors.New("amend order failure") // ErrCancelOrder is returned when cancelling an order fails for some reason. ErrCancelOrder = errors.New("cancel order failure") // OrderService... ErrOrderServiceGetByMarket = errors.New("failed to get orders for market") ErrOrderServiceGetByMarketAndID = errors.New("failed to get orders for market and ID") ErrOrderServiceGetByParty = errors.New("failed to get orders for party") ErrOrderServiceGetByReference = errors.New("failed to get orders for reference") ErrMissingOrderIDParameter = errors.New("missing orderID parameter") ErrOrderNotFound = errors.New("order not found") // TradeService... ErrTradeServiceGetByParty = errors.New("failed to get trades for party") ErrTradeServiceGetByMarket = errors.New("failed to get trades for market") ErrTradeServiceGetPositionsByParty = errors.New("failed to get positions for party") ErrTradeServiceGetByOrderID = errors.New("failed to get trades for order ID") // MarketService... ErrMarketServiceGetMarkets = errors.New("failed to get markets") ErrMarketServiceGetByID = errors.New("failed to get market for ID") ErrMarketServiceGetDepth = errors.New("failed to get market depth") ErrMarketServiceGetMarketData = errors.New("failed to get market data") // AccountService... ErrAccountServiceListAccounts = errors.New("failed to get accounts") ErrAccountServiceGetMarketAccounts = errors.New("failed to get market accounts") // AccountService... ErrAccountServiceGetFeeInfrastructureAccounts = errors.New("failed to get fee infrastructure accounts") ErrAccountServiceGetGlobalRewardPoolAccounts = errors.New("failed to get global reward pool accounts") ErrAccountServiceGetPartyAccounts = errors.New("failed to get party accounts") // RiskService... ErrRiskServiceGetMarginLevelsByID = errors.New("failed to get margin levels") ErrInvalidOrderSide = errors.New("invalid order side") // CandleService... ErrCandleServiceGetCandleData = errors.New("failed to get candle data") ErrCandleServiceSubscribeToCandles = errors.New("failed to subscribe to candle data") ErrCandleServiceGetCandlesForMarket = errors.New("failed to get candles for market") // PartyService... ErrPartyServiceGetAll = errors.New("failed to get parties") ErrPartyServiceGetByID = errors.New("failed to get party for ID") // TimeService... ErrTimeServiceGetTimeNow = errors.New("failed to get time now") // Blockchain... ErrBlockchainBacklogLength = errors.New("failed to get backlog length from blockchain") ErrBlockchainNetworkInfo = errors.New("failed to get network info from blockchain") ErrBlockchainGenesisTime = errors.New("failed to get genesis time from blockchain") ErrBlockchainChainID = errors.New("failed to get chain ID from blockchain") // ErrMissingProposalID returned if proposal with this id is missing. ErrMissingProposalID = errors.New("missing proposal id") // ErrMissingProposalReference returned if proposal with this reference is not found. ErrMissingProposalReference = errors.New("failed to find proposal with the reference") // ErrMissingWithdrawalID is returned when the withdrawal ID is missing from the request. ErrMissingWithdrawalID = errors.New("missing withdrawal ID") // ErrMissingOracleSpecID is returned when the ID is missing from the request. ErrMissingOracleSpecID = errors.New("missing oracle spec ID") // ErrMissingDepositID is returned when the deposit ID is missing from the request. ErrMissingDepositID = errors.New("missing deposit ID") // ErrMissingAssetID is returned when the Asset ID is missing from the request. ErrMissingAssetID = errors.New("missing asset ID") // Network Limits... ErrGetNetworkLimits = errors.New("failed to get network limits") // Rewards. ErrGetRewards = errors.New("failed to get rewards") )
API Errors and descriptions.
Functions ¶
Types ¶
type Config ¶
type Config struct { Level encoding.LogLevel `long:"log-level"` Timeout encoding.Duration `long:"timeout"` Port int `long:"port"` WebUIPort int `long:"web-ui-port"` WebUIEnabled encoding.Bool `long:"web-ui-enabled"` Reflection encoding.Bool `long:"reflection"` IP string `long:"ip"` StreamRetries int `long:"stream-retries"` CoreNodeIP string `long:"core-node-ip"` CoreNodeGRPCPort int `long:"core-node-grpc-port"` }
Config represents the configuration of the api package.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
type CoreServiceClient ¶
type CoreServiceClient interface { protoapi.CoreServiceClient }
CoreServiceClient ...
type EventService ¶
type EventService interface {
ObserveEvents(ctx context.Context, retries int, eTypes []events.Type, batchSize int, filters ...subscribers.EventFilter) (<-chan []*eventspb.BusEvent, chan<- int)
}
EventService ...
type GRPCServer ¶
type GRPCServer struct { Config // contains filtered or unexported fields }
GRPCServer represent the grpc api provided by the vega node.
func NewGRPCServer ¶
func NewGRPCServer( log *logging.Logger, config Config, coreServiceClient CoreServiceClient, eventService *subscribers.Service, orderService *service.Order, networkLimitsService *service.NetworkLimits, marketDataService *service.MarketData, tradeService *service.Trade, assetService *service.Asset, accountService *service.Account, rewardService *service.Reward, marketsService *service.Markets, delegationService *service.Delegation, epochService *service.Epoch, depositService *service.Deposit, withdrawalService *service.Withdrawal, governanceService *service.Governance, riskFactorService *service.RiskFactor, riskService *service.Risk, networkParameterService *service.NetworkParameter, blockService *service.Block, checkpointService *service.Checkpoint, partyService *service.Party, candleService *candlesv2.Svc, oracleSpecService *service.OracleSpec, oracleDataService *service.OracleData, liquidityProvisionService *service.LiquidityProvision, positionService *service.Position, transferService *service.Transfer, stakeLinkingService *service.StakeLinking, notaryService *service.Notary, multiSigService *service.MultiSig, keyRotationService *service.KeyRotations, ethereumKeyRotationService *service.EthereumKeyRotation, nodeService *service.Node, marketDepthService *service.MarketDepth, ledgerService *service.Ledger, ) *GRPCServer
NewGRPCServer create a new instance of the GPRC api for the vega node.
func (*GRPCServer) ReloadConf ¶
func (g *GRPCServer) ReloadConf(cfg Config)
ReloadConf update the internal configuration of the GRPC server.