zmqutil

package
v0.11.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: ISC Imports: 14 Imported by: 2

Documentation

Overview

Package zmqutil - various comm ZMq routines shared be all commands

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseClients

func CloseClients(clients []*Client)

CloseClients - disconnect old addresses and close all

func MakeKeyPair

func MakeKeyPair(publicKeyFileName string, privateKeyFileName string) error

MakeKeyPair - create a new public/private keypair and write them to separate files

func NewBind

func NewBind(log *logger.L, socketType zmq.Type, zapDomain string, privateKey []byte, publicKey []byte, listen []*util.Connection) (*zmq.Socket, *zmq.Socket, error)

NewBind - bind socket to a list of addresses creates up to 2 sockets for separate IPv4 and IPv6 traffic

func NewMonitor added in v0.7.3

func NewMonitor(socket *zmq.Socket, connection string, event zmq.Event) (*zmq.Socket, error)

NewMonitor - return a socket connection to the monitoring channel of another socket for connection state signalling a unique inproc://name must be provided for each use

func NewServerSocket

func NewServerSocket(socketType zmq.Type, zapDomain string, privateKey []byte, publicKey []byte, v6 bool) (*zmq.Socket, error)

NewServerSocket - create a socket suitable for a server side connection

func NewSignalPair

func NewSignalPair(signal string) (receiver *zmq.Socket, sender *zmq.Socket, err error)

NewSignalPair -return a pair of connected PAIR sockets for shutdown signalling

func ParseKey added in v0.9.0

func ParseKey(data string) ([]byte, bool, error)

ParseKey - parse hexadecimal key strings

func ReadPrivateKey added in v0.9.0

func ReadPrivateKey(key string) ([]byte, error)

ReadPrivateKey - extract the private key from a string returning it as a 32 byte string

func ReadPublicKey added in v0.9.0

func ReadPublicKey(key string) ([]byte, error)

ReadPublicKey - extract the public key from a string returning it as a 32 byte string

func StartAuthentication

func StartAuthentication() error

StartAuthentication - initialise the ZMQ security subsystem

Types

type Client

type Client struct {
	ClientIntf

	sync.Mutex
	// contains filtered or unexported fields
}

Client - structure to hold a client connection

prefix:

REQ socket this adds an item before send
SUB socket this adds/changes subscription

func NewClient

func NewClient(
	socketType zmq.Type,
	privateKey []byte,
	publicKey []byte,
	timeout time.Duration,
	events zmq.Event,
) (*Client, <-chan Event, error)

NewClient - create a client socket ususlly of type zmq.REQ or zmq.SUB

func (*Client) Close

func (client *Client) Close() error

Close - disconnect old address and close

func (*Client) Connect

func (client *Client) Connect(conn *util.Connection, serverPublicKey []byte, prefix string) error

Connect - disconnect old address and connect to new

func (*Client) ConnectedTo added in v0.6.0

func (client *Client) ConnectedTo() *Connected

ConnectedTo - return representation of client connection

func (*Client) GoString added in v0.11.0

func (client *Client) GoString() string

GoString - return a basic information string for debugging purposes

func (*Client) IsConnected

func (client *Client) IsConnected() bool

IsConnected - check if connected to a node

func (*Client) IsConnectedTo

func (client *Client) IsConnectedTo(serverPublicKey []byte) bool

IsConnectedTo - check if connected to a specific node

func (*Client) Receive

func (client *Client) Receive(flags zmq.Flag) ([][]byte, error)

Receive - receive a reply

func (*Client) Reconnect

func (client *Client) Reconnect() error

Reconnect - close and reopen the connection

func (*Client) Send

func (client *Client) Send(items ...interface{}) error

Send - send a message

func (*Client) ServerPublicKey added in v0.11.0

func (client *Client) ServerPublicKey() []byte

ServerPublicKey - return server's public key

func (*Client) String added in v0.3.16

func (client *Client) String() string

String - return a string description of a client

type ClientIntf added in v0.11.0

type ClientIntf interface {
	Close() error
	Connect(conn *util.Connection, serverPublicKey []byte, prefix string) error
	ConnectedTo() *Connected
	GoString() string
	IsConnected() bool
	IsConnectedTo(serverPublicKey []byte) bool
	Reconnect() error
	Receive(flags zmq.Flag) ([][]byte, error)
	Send(items ...interface{}) error
	ServerPublicKey() []byte
	String() string
}

type Connected added in v0.6.0

type Connected struct {
	Address string `json:"address"`
	Server  string `json:"server"`
}

Connected - representation of a connected server

type Event added in v0.11.0

type Event struct {
	Event   zmq.Event
	Address string
	Value   int
}

type Poller added in v0.3.23

type Poller struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Poller - structure to hold a poller

func NewPoller added in v0.3.23

func NewPoller() *Poller

NewPoller - create a poller this is just to encapsulate the zmq poller to allow removal of a socket from a socket

func (*Poller) Add added in v0.3.23

func (poller *Poller) Add(socket *zmq.Socket, events zmq.State)

Add - adds a socket to a poller

func (*Poller) Poll added in v0.3.23

func (poller *Poller) Poll(timeout time.Duration) ([]zmq.Polled, error)

Poll - perform a poll

func (*Poller) Remove added in v0.3.23

func (poller *Poller) Remove(socket *zmq.Socket)

Remove - removes a socket from a poller

Jump to

Keyboard shortcuts

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