Documentation
¶
Index ¶
- type ChannelService
- func (s *ChannelService) GetAllChannels(ctx context.Context, in *pb.Empty) (*pb.ChannelList, error)
- func (s *ChannelService) GetChannel(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Channel, error)
- func (s *ChannelService) Join(ctx context.Context, in *pb.JoinRequest) (*pb.JoinResponse, error)
- func (s *ChannelService) Leave(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Empty, error)
- func (s *ChannelService) RegisterP2p(p2p interfaces.P2p)
- func (s *ChannelService) RegisterStorage(storage interfaces.Storage)
- type NodeService
- type OrderService
- func (s *OrderService) Create(ctx context.Context, in *pb.CreateRequest) (*pb.CreateResponse, error)
- func (s *OrderService) Delete(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
- func (s *OrderService) GetAllOrders(ctx context.Context, in *pb.Empty) (*pb.OrderList, error)
- func (s *OrderService) GetOrder(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Order, error)
- func (s *OrderService) GetSyncState() SyncState
- func (s *OrderService) Lock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
- func (s *OrderService) Receive(buf []byte, from peer.ID) error
- func (s *OrderService) RegisterP2p(p2p interfaces.P2p)
- func (s *OrderService) RegisterStorage(storage interfaces.Storage)
- func (s *OrderService) RegisterWebsocket(websocket interfaces.WebsocketService)
- func (s *OrderService) SetSyncState(syncState SyncState)
- func (s *OrderService) Unlock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
- type Server
- type SyncState
- type WebsocketService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelService ¶
type ChannelService struct { Storage interfaces.Storage P2p interfaces.P2p }
ChannelService implements the ChannelHandlerServer service.proto
func (*ChannelService) GetAllChannels ¶
func (s *ChannelService) GetAllChannels(ctx context.Context, in *pb.Empty) (*pb.ChannelList, error)
GetAllChannels fetches all channels from the database
func (*ChannelService) GetChannel ¶
func (s *ChannelService) GetChannel(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Channel, error)
GetChannel fetches a single channel from the database
func (*ChannelService) Join ¶
func (s *ChannelService) Join(ctx context.Context, in *pb.JoinRequest) (*pb.JoinResponse, error)
Join joins a channel, subscribing to new topic in libp2p
func (*ChannelService) Leave ¶
func (s *ChannelService) Leave(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Empty, error)
Leave leaves a channel, removing a subscription from libp2p
func (*ChannelService) RegisterP2p ¶
func (s *ChannelService) RegisterP2p(p2p interfaces.P2p)
RegisterP2p registers a p2p service
func (*ChannelService) RegisterStorage ¶
func (s *ChannelService) RegisterStorage(storage interfaces.Storage)
RegisterStorage registers a storage service to store the Channels in
type NodeService ¶
type NodeService struct {
P2p interfaces.P2p
}
NodeService is a gRPC service for p2p operations.
func (*NodeService) BlacklistPeer ¶
BlacklistPeer blacklists a peer from connecting to this node
func (*NodeService) GetAllPeers ¶
func (s *NodeService) GetAllPeers(ctx context.Context, in *pb.Empty) (*pb.PeerListResponse, error)
GetAllPeers fetches all connected peers from NodeService.P2p
func (*NodeService) RegisterP2p ¶
func (s *NodeService) RegisterP2p(p2p interfaces.P2p)
RegisterP2p registers a p2p interface with NodeService
type OrderService ¶
type OrderService struct { Logger interfaces.Logger Storage interfaces.Storage P2p interfaces.P2p // contains filtered or unexported fields }
OrderService implements the OrderService Server service.proto
func (*OrderService) Create ¶
func (s *OrderService) Create(ctx context.Context, in *pb.CreateRequest) (*pb.CreateResponse, error)
Create creates an Order, storing it locally and broadcasts the Order to all other nodes on the channel
func (*OrderService) Delete ¶
func (s *OrderService) Delete(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
Delete removes the Order with the specified ID locally, and broadcasts the same request to all other nodes on the channel
func (*OrderService) GetAllOrders ¶
GetAllOrders fetches all orders from the database
func (*OrderService) GetOrder ¶
func (s *OrderService) GetOrder(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Order, error)
GetOrder fetches a single order from the database
func (*OrderService) GetSyncState ¶
func (s *OrderService) GetSyncState() SyncState
func (*OrderService) Lock ¶
func (s *OrderService) Lock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
Lock locks the given Order if the Order is created by this node, broadcasts the lock to other nodes on the channel.
func (*OrderService) Receive ¶
func (s *OrderService) Receive(buf []byte, from peer.ID) error
Receive receives a buffer from p2p and tries to unmarshal it into a struct
func (*OrderService) RegisterP2p ¶
func (s *OrderService) RegisterP2p(p2p interfaces.P2p)
RegisterP2p registers a p2p service
func (*OrderService) RegisterStorage ¶
func (s *OrderService) RegisterStorage(storage interfaces.Storage)
RegisterStorage registers a storage service to store the Orders in
func (*OrderService) RegisterWebsocket ¶
func (s *OrderService) RegisterWebsocket(websocket interfaces.WebsocketService)
RegisterWebsocket registers a websocket service to enable websocket connections between client and node
func (*OrderService) SetSyncState ¶
func (s *OrderService) SetSyncState(syncState SyncState)
func (*OrderService) Unlock ¶
func (s *OrderService) Unlock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
Unlock unlocks the given Order if it's created by this node, broadcasts the unlocking operation to other nodes on the channel.
type Server ¶
type Server struct { Orders *OrderService Channels *ChannelService Logger interfaces.Logger // contains filtered or unexported fields }
Server contains services for both Orders and Channels
func NewServer ¶
func NewServer(log interfaces.Logger, storage interfaces.Storage, p2p interfaces.P2p, websocket interfaces.WebsocketService) *Server
NewServer returns a server that has connections to p2p and storage
type SyncState ¶
type SyncState int
SyncState is a latch that defines if orders have been synced or not
type WebsocketService ¶
type WebsocketService struct { Connections []*websocket.Conn Logger interfaces.Logger Port uint // contains filtered or unexported fields }
func (*WebsocketService) Close ¶
func (ws *WebsocketService) Close()
func (*WebsocketService) PushToWebsockets ¶
func (ws *WebsocketService) PushToWebsockets(message *pb.WireMessage)
func (*WebsocketService) Start ¶
func (ws *WebsocketService) Start()