broker

package
v0.0.0-...-7a3d942 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyExists error which indicates that entry already exists in stroe
	ErrAlreadyExists = errors.New("entry already exists in store")
)

Functions

This section is empty.

Types

type Broker

type Broker struct {
	ClientStore *ClientStore
	// contains filtered or unexported fields
}

Broker ...

func New

func New(cfg Config) (Broker, error)

New ...

func (*Broker) ListenTCP

func (b *Broker) ListenTCP() error

ListenTCP starts listening to incoming requests, this function is blocking

type Client

type Client struct {
	ID        string
	IPAddress net.Addr
}

Client ...

type ClientStore

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

ClientStore ...

func NewClientStore

func NewClientStore() *ClientStore

NewClientStore creates store of clients

func (*ClientStore) Add

func (l *ClientStore) Add(c Client) error

Add adds new client

func (*ClientStore) Get

func (l *ClientStore) Get(clientID string) (Client, bool)

Get retreives client from store

type Config

type Config struct {
	// Hostname of where broker should listen
	//
	// Default: "0.0.0.0"
	Hostname string

	// Port of where broker should listen
	//
	// Default: "997"
	Port uint32

	// Ed25519 Private key
	//
	// Required
	PrivateKey ed25519.PrivateKey

	// Ed25519 Public key
	//
	// Required
	PublicKey ed25519.PublicKey
}

Config ...

func (Config) Parse

func (cfg Config) Parse() Config

Parse parses options and set defaults

Jump to

Keyboard shortcuts

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