Documentation
¶
Overview ¶
Package server contains the order book service implementation.
Index ¶
- Variables
- func GetOrderBookBackend(book *core.OrderBook) core.OrderBookBackend
- func LogOrderBookSummary(ctx context.Context, logger zerolog.Logger, book *core.OrderBook, ...)
- func RegisterOrderBookService(grpcServer *grpc.Server, service *GRPCOrderBookService)
- type GRPCOrderBookService
- func (s *GRPCOrderBookService) CancelOrder(ctx context.Context, req *proto.CancelOrderRequest) (*emptypb.Empty, error)
- func (s *GRPCOrderBookService) CreateOrder(ctx context.Context, req *proto.CreateOrderRequest) (*proto.OrderResponse, error)
- func (s *GRPCOrderBookService) CreateOrderBook(ctx context.Context, req *proto.CreateOrderBookRequest) (*proto.OrderBookResponse, error)
- func (s *GRPCOrderBookService) DeleteOrderBook(ctx context.Context, req *proto.DeleteOrderBookRequest) (*emptypb.Empty, error)
- func (s *GRPCOrderBookService) GetOrder(ctx context.Context, req *proto.GetOrderRequest) (*proto.OrderResponse, error)
- func (s *GRPCOrderBookService) GetOrderBook(ctx context.Context, req *proto.GetOrderBookRequest) (*proto.OrderBookResponse, error)
- func (s *GRPCOrderBookService) GetOrderBookState(ctx context.Context, req *proto.GetOrderBookStateRequest) (*proto.OrderBookStateResponse, error)
- func (s *GRPCOrderBookService) ListOrderBooks(ctx context.Context, req *proto.ListOrderBooksRequest) (*proto.ListOrderBooksResponse, error)
- type OrderBookExt
- type OrderBookInfo
- type OrderBookManager
- func (m *OrderBookManager) Close()
- func (m *OrderBookManager) CreateMemoryOrderBook(ctx context.Context, name string) (*OrderBookInfo, error)
- func (m *OrderBookManager) CreateRedisOrderBook(ctx context.Context, name string, options map[string]string) (*OrderBookInfo, error)
- func (m *OrderBookManager) DeleteOrderBook(ctx context.Context, name string) error
- func (m *OrderBookManager) GetOrderBook(ctx context.Context, name string) (*core.OrderBook, *OrderBookInfo, error)
- func (m *OrderBookManager) ListOrderBooks(ctx context.Context) []*OrderBookInfo
- func (m *OrderBookManager) UpdateOrderBookInfo(ctx context.Context, name string, orderCount int) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrOrderBookExists is returned when trying to create an order book that already exists ErrOrderBookExists = errors.New("order book with this name already exists") // ErrOrderBookNotFound is returned when trying to access a non-existent order book ErrOrderBookNotFound = errors.New("order book not found") )
Functions ¶
func GetOrderBookBackend ¶
func GetOrderBookBackend(book *core.OrderBook) core.OrderBookBackend
GetBackend returns the backend of the order book
func LogOrderBookSummary ¶
func LogOrderBookSummary(ctx context.Context, logger zerolog.Logger, book *core.OrderBook, info *OrderBookInfo)
LogOrderBookSummary logs summary information about an order book
func RegisterOrderBookService ¶
func RegisterOrderBookService(grpcServer *grpc.Server, service *GRPCOrderBookService)
RegisterOrderBookService registers the order book service with the provided gRPC server
Types ¶
type GRPCOrderBookService ¶
type GRPCOrderBookService struct {
proto.UnimplementedOrderBookServiceServer
// contains filtered or unexported fields
}
GRPCOrderBookService implements the OrderBookService gRPC interface
func NewGRPCOrderBookService ¶
func NewGRPCOrderBookService(manager *OrderBookManager) *GRPCOrderBookService
NewGRPCOrderBookService creates a new GRPCOrderBookService
func (*GRPCOrderBookService) CancelOrder ¶
func (s *GRPCOrderBookService) CancelOrder(ctx context.Context, req *proto.CancelOrderRequest) (*emptypb.Empty, error)
CancelOrder cancels an order in the specified order book
func (*GRPCOrderBookService) CreateOrder ¶
func (s *GRPCOrderBookService) CreateOrder(ctx context.Context, req *proto.CreateOrderRequest) (*proto.OrderResponse, error)
CreateOrder submits a new order to the specified order book
func (*GRPCOrderBookService) CreateOrderBook ¶
func (s *GRPCOrderBookService) CreateOrderBook(ctx context.Context, req *proto.CreateOrderBookRequest) (*proto.OrderBookResponse, error)
CreateOrderBook implements the CreateOrderBook RPC method
func (*GRPCOrderBookService) DeleteOrderBook ¶
func (s *GRPCOrderBookService) DeleteOrderBook(ctx context.Context, req *proto.DeleteOrderBookRequest) (*emptypb.Empty, error)
DeleteOrderBook deletes an order book
func (*GRPCOrderBookService) GetOrder ¶
func (s *GRPCOrderBookService) GetOrder(ctx context.Context, req *proto.GetOrderRequest) (*proto.OrderResponse, error)
GetOrder retrieves information about a specific order
func (*GRPCOrderBookService) GetOrderBook ¶
func (s *GRPCOrderBookService) GetOrderBook(ctx context.Context, req *proto.GetOrderBookRequest) (*proto.OrderBookResponse, error)
GetOrderBook retrieves information about an order book
func (*GRPCOrderBookService) GetOrderBookState ¶
func (s *GRPCOrderBookService) GetOrderBookState(ctx context.Context, req *proto.GetOrderBookStateRequest) (*proto.OrderBookStateResponse, error)
GetOrderBookState retrieves the current state of an order book
func (*GRPCOrderBookService) ListOrderBooks ¶
func (s *GRPCOrderBookService) ListOrderBooks(ctx context.Context, req *proto.ListOrderBooksRequest) (*proto.ListOrderBooksResponse, error)
ListOrderBooks lists all available order books
type OrderBookExt ¶
OrderBookExt provides extension methods for OrderBook
type OrderBookInfo ¶
OrderBookInfo contains metadata about an order book
type OrderBookManager ¶
type OrderBookManager struct {
// contains filtered or unexported fields
}
OrderBookManager manages multiple order books
func NewOrderBookManager ¶
func NewOrderBookManager() *OrderBookManager
NewOrderBookManager creates a new OrderBookManager
func (*OrderBookManager) Close ¶
func (m *OrderBookManager) Close()
Close closes all resources used by the manager
func (*OrderBookManager) CreateMemoryOrderBook ¶
func (m *OrderBookManager) CreateMemoryOrderBook(ctx context.Context, name string) (*OrderBookInfo, error)
CreateMemoryOrderBook creates a new order book with in-memory backend
func (*OrderBookManager) CreateRedisOrderBook ¶
func (m *OrderBookManager) CreateRedisOrderBook(ctx context.Context, name string, options map[string]string) (*OrderBookInfo, error)
CreateRedisOrderBook creates a new order book with Redis backend
func (*OrderBookManager) DeleteOrderBook ¶
func (m *OrderBookManager) DeleteOrderBook(ctx context.Context, name string) error
DeleteOrderBook removes an order book
func (*OrderBookManager) GetOrderBook ¶
func (m *OrderBookManager) GetOrderBook(ctx context.Context, name string) (*core.OrderBook, *OrderBookInfo, error)
GetOrderBook retrieves an order book by name
func (*OrderBookManager) ListOrderBooks ¶
func (m *OrderBookManager) ListOrderBooks(ctx context.Context) []*OrderBookInfo
ListOrderBooks returns information about all order books
func (*OrderBookManager) UpdateOrderBookInfo ¶
func (m *OrderBookManager) UpdateOrderBookInfo(ctx context.Context, name string, orderCount int) error
UpdateOrderBookInfo updates the order count for an order book