interfaces

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelService

type ChannelService interface {
	RegisterStorage(db Storage)
	RegisterP2p(p2p P2p)
	Join(ctx context.Context, in *pb.JoinRequest) (*pb.JoinResponse, error)
	Leave(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Empty, error)
	GetChannel(ctx context.Context, in *pb.ChannelSpecificRequest) (*pb.Channel, error)
	GetAllChannels(ctx context.Context, in *pb.Empty) (*pb.ChannelList, error)
}

ChannelService is an interface to the Channel endpoints in sprawl.proto

type Config

type Config interface {
	ReadConfig(configPath string)
	GetDatabasePath() string
	GetExternalIP() string
	GetLogLevel() string
	GetLogFormat() string
	GetP2PPort() string
	GetRPCPort() string
	GetWebsocketPort() string
	GetWebsocketEnable() bool
	GetInMemoryDatabaseSetting() bool
	GetNATPortMapSetting() bool
	GetRelaySetting() bool
	GetAutoRelaySetting() bool
	GetDebugSetting() bool
	GetStackTraceSetting() bool
	GetIPFSPeerSetting() bool
}

Config is an interface to viper

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger is an interface to viper

type NodeService

type NodeService interface {
	RegisterP2p(p2p P2p)
	GetAllPeers(ctx context.Context, in *pb.Empty) (*pb.PeerListResponse, error)
	BlacklistPeer(ctx context.Context, in *pb.Peer) (*pb.Empty, error)
}

type OrderService

type OrderService interface {
	RegisterStorage(db Storage)
	RegisterP2p(p2p P2p)
	RegisterWebsocket(websocket WebsocketService)
	Create(ctx context.Context, in *pb.CreateRequest) (*pb.CreateResponse, error)
	Receive(data []byte, from peer.ID) error
	Delete(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
	Lock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
	Unlock(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Empty, error)
	GetOrder(ctx context.Context, in *pb.OrderSpecificRequest) (*pb.Order, error)
	GetAllOrders(ctx context.Context, in *pb.Empty) (*pb.OrderList, error)
}

OrderService is an interface to the Order endpoints in sprawl.proto

type P2p

type P2p interface {
	GetHostID() peer.ID
	GetHostIDString() string
	AddReceiver(receiver Receiver)
	Send(message *pb.WireMessage)
	Subscribe(channel *pb.Channel) (context.Context, error)
	Unsubscribe(channel *pb.Channel)
	GetAllPeers() []peer.ID
	BlacklistPeer(peerID *pb.Peer)
	OpenStream(peerID peer.ID) (Stream, error)
	CloseStream(peerID peer.ID) error
	Run()
	Close()
}

P2p is a general p2p connection handler

type Prefix

type Prefix string

Prefix is a type used to prefix all entries in Storage

const (
	// OrderPrefix is the prefix used to signify all orders in Storage
	OrderPrefix Prefix = "order-"
	// ChannelPrefix is the prefix used to signify all channels in Storage
	ChannelPrefix Prefix = "channel-"
)

type Receiver

type Receiver interface {
	Receive(data []byte, from peer.ID) error
}

Receiver receives and parses all Wiremessages from p2p

type Storage

type Storage interface {
	SetDbPath(dbPath string)
	Run() error
	Close()
	Has(key []byte) (bool, error)
	Get(key []byte) ([]byte, error)
	Put(key []byte, data []byte) error
	Delete(key []byte) error
	GetAll() (map[string]string, error)
	GetAllWithPrefix(prefix string) (map[string]string, error)
	DeleteAll() error
	DeleteAllWithPrefix(prefix string) error
}

Storage defines a database interface that works with Sprawl

type Stream

type Stream interface {
	WriteToStream(data []byte) error
}

Stream is a single stream instance between two peers

type WebsocketService

type WebsocketService interface {
	Start()
	Close()
	PushToWebsockets(message *pb.WireMessage)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL