sprawl: github.com/sprawl/sprawl/service Index | Files

package service

import "github.com/sprawl/sprawl/service"

Index

Package Files

channel.go order.go server.go

type ChannelService Uses

type ChannelService struct {
    Storage interfaces.Storage
    P2p     interfaces.P2p
}

ChannelService implements the ChannelHandlerServer service.proto

func (*ChannelService) GetAllChannels Uses

func (s *ChannelService) GetAllChannels(ctx context.Context, in *pb.Empty) (*pb.ChannelListResponse, error)

GetAllChannels fetches all channels from the database

func (*ChannelService) GetChannel Uses

func (s *ChannelService) GetChannel(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Channel, error)

GetChannel fetches a single channel from the database

func (*ChannelService) Join Uses

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 Uses

func (s *ChannelService) Leave(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.GenericResponse, error)

Leave leaves a channel, removing a subscription from libp2p

func (*ChannelService) RegisterP2p Uses

func (s *ChannelService) RegisterP2p(p2p interfaces.P2p)

RegisterP2p registers a p2p service

func (*ChannelService) RegisterStorage Uses

func (s *ChannelService) RegisterStorage(storage interfaces.Storage)

RegisterStorage registers a storage service to store the Channels in

type OrderService Uses

type OrderService struct {
    Logger  interfaces.Logger
    Storage interfaces.Storage
    P2p     interfaces.P2p
}

OrderService implements the OrderService Server service.proto

func (*OrderService) Create Uses

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 Uses

func (s *OrderService) Delete(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.GenericResponse, 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 Uses

func (s *OrderService) GetAllOrders(ctx context.Context, in *pb.Empty) (*pb.OrderListResponse, error)

GetAllOrders fetches all orders from the database

func (*OrderService) GetOrder Uses

func (s *OrderService) GetOrder(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Order, error)

GetOrder fetches a single order from the database

func (*OrderService) Lock Uses

func (s *OrderService) Lock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.GenericResponse, 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 Uses

func (s *OrderService) Receive(buf []byte) error

Receive receives a buffer from p2p and tries to unmarshal it into a struct

func (*OrderService) RegisterP2p Uses

func (s *OrderService) RegisterP2p(p2p interfaces.P2p)

RegisterP2p registers a p2p service

func (*OrderService) RegisterStorage Uses

func (s *OrderService) RegisterStorage(storage interfaces.Storage)

RegisterStorage registers a storage service to store the Orders in

func (*OrderService) Unlock Uses

func (s *OrderService) Unlock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.GenericResponse, 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 Uses

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 Uses

func NewServer(log interfaces.Logger, storage interfaces.Storage, p2p interfaces.P2p) *Server

NewServer returns a server that has connections to p2p and storage

func (*Server) Close Uses

func (server *Server) Close()

Close gracefully shuts down the gRPC server

func (*Server) Run Uses

func (server *Server) Run(port uint)

Run runs the gRPC server

Package service imports 13 packages (graph) and is imported by 1 packages. Updated 2019-12-16. Refresh now. Tools for package owners.