README

zebou

Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(ctx context.Context, msg *pb.SyncMessage) error

func Send

func Send(ctx context.Context, msg *pb.SyncMessage) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(address string, config *tls.Config) *Client

func (*Client) GetMessage

func (c *Client) GetMessage() (*pb.SyncMessage, error)

func (*Client) Send

func (c *Client) Send(msgType string, name string, o interface{}) error

func (*Client) SendMsg

func (c *Client) SendMsg(msg *pb.SyncMessage) error

func (*Client) SetConnectionSateHandler

func (c *Client) SetConnectionSateHandler(h ConnectionStateHandler)

func (*Client) Stop

func (c *Client) Stop() error

type ConnectionStateHandler

type ConnectionStateHandler interface {
	ConnectionState(active bool)
}

type ConnectionStateHandlerFunc

type ConnectionStateHandlerFunc func(bool)

func (ConnectionStateHandlerFunc) ConnectionState

func (f ConnectionStateHandlerFunc) ConnectionState(active bool)

type HandleMessageFunc

type HandleMessageFunc func(msg *pb.SyncMessage)

type Handler

type Handler interface {
	NewClient(ctx context.Context, info *PeerInfo)
	ClientQuit(ctx context.Context, info *PeerInfo)
	OnMessage(ctx context.Context, msg *pb.SyncMessage)
}

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func Serve

func Serve(l net.Listener, handler Handler) (*Hub, error)

func (*Hub) Broadcast

func (s *Hub) Broadcast(ctx context.Context, msg *pb.SyncMessage)

func (*Hub) Stop

func (s *Hub) Stop() error

func (*Hub) Sync

func (s *Hub) Sync(stream pb.Nodes_SyncServer) error

type MessageHandler

type MessageHandler interface {
	Handle(message *pb.SyncMessage)
}

type PeerInfo

type PeerInfo struct {
	ID      string
	Address string
}

func Peer

func Peer(ctx context.Context) *PeerInfo

type Sender

type Sender interface {
	Send(message *pb.SyncMessage) error
}

Directories

Path Synopsis
proto