interlock

package module
v0.0.0-...-e8a7131 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DELIM byte = '\n'

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config NodeConfig
	Conn   Connection
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Close

func (c *Client) Close()
func (c *Client) Link() error

func (*Client) Read

func (c *Client) Read() <-chan DataFrame

func (*Client) Run

func (c *Client) Run()

func (*Client) SetConfig

func (c *Client) SetConfig(nc NodeConfig)

func (*Client) WriteTo

func (c *Client) WriteTo(tg string, kx MSGType, data interface{})

type ConnData

type ConnData struct {
	Conn     net.Conn
	FrameIn  chan DataFrame
	FrameOut chan DataFrame
	// contains filtered or unexported fields
}

func NewConnData

func NewConnData(c net.Conn) ConnData

func (*ConnData) Close

func (cd *ConnData) Close()

func (*ConnData) Deactivate

func (cd *ConnData) Deactivate()

func (*ConnData) Loop

func (cd *ConnData) Loop()

type Connection

type Connection struct {
	ID           string
	LinkID       string
	Conn         ConnData
	Input        chan DataFrame
	Output       chan DataFrame
	PingInterval time.Duration
	LastPing     time.Time
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(c net.Conn) *Connection

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) Ping

func (c *Connection) Ping()

func (*Connection) Run

func (c *Connection) Run()

func (*Connection) Send

func (c *Connection) Send(kx MSGType, dx interface{})

type ConnectionLog

type ConnectionLog struct {
	History map[time.Time]LogEntry
}

func NewLog

func NewLog() ConnectionLog

func (ConnectionLog) Add

func (cl ConnectionLog) Add(df DataFrame)

type DataFrame

type DataFrame struct {
	SrcID   string
	Kind    MSGType
	Content interface{}
	Created time.Time
}

func ParseDataFrame

func ParseDataFrame(raw []byte) *DataFrame

func (*DataFrame) ToBytes

func (df *DataFrame) ToBytes() []byte

type DataPipe

type DataPipe struct {
	Input  chan DataFrame
	Output chan DataFrame
}

func NewDataPipe

func NewDataPipe() *DataPipe

type LinkOp

type LinkOp int64
const (
	Connect LinkOp = 0
	Serve   LinkOp = 1
)

type LogEntry

type LogEntry struct {
	Stamp   time.Time
	Content DataFrame
}

type MSGType

type MSGType int64
const (
	PING       MSGType = 0
	PONG       MSGType = 1
	DATA       MSGType = 2
	CONNECT    MSGType = 3
	DISCONNECT MSGType = 4
)

type Node

type Node interface {
	// Port    int
	// Active  bool
	Link() error
	Run()
	WriteTo(string, MSGType, interface{})
	Read() <-chan DataFrame
	// SetType(nk NodeKind)
	SetConfig(nc NodeConfig)
	Close()
}

func NewNode

func NewNode(kx NodeKind) Node

type NodeConfig

type NodeConfig struct {
	ID      string
	Address string
	Port    int
}

func (NodeConfig) ToString

func (nc NodeConfig) ToString() string

type NodeKind

type NodeKind int64
const (
	Routing      NodeKind = 0
	Fanout       NodeKind = 1
	PubSub       NodeKind = 2
	NodeClient   NodeKind = 3
	PubsubClient NodeKind = 4
)

type Router

type Router struct {
	Connections map[string]*Connection
	Config      NodeConfig
	InputStream chan DataFrame
	LX          net.Listener
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Close

func (r *Router) Close()
func (r *Router) Link() error

func (*Router) Read

func (r *Router) Read() <-chan DataFrame

func (*Router) Run

func (r *Router) Run()

func (*Router) SetConfig

func (r *Router) SetConfig(nc NodeConfig)

func (*Router) WriteTo

func (r *Router) WriteTo(tg string, kx MSGType, data interface{})

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

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