zmqutil

package
v0.15.7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: ISC Imports: 15 Imported by: 2

Documentation

Overview

Package zmqutil - various comm ZMq routines shared be all commands

Index

Constants

View Source
const (
	EVENT_CONNECTED       = zmq.EVENT_CONNECTED
	EVENT_CONNECT_DELAYED = zmq.EVENT_CONNECT_DELAYED
	EVENT_CONNECT_RETRIED = zmq.EVENT_CONNECT_RETRIED
	EVENT_LISTENING       = zmq.EVENT_LISTENING
	EVENT_BIND_FAILED     = zmq.EVENT_BIND_FAILED
	EVENT_ACCEPTED        = zmq.EVENT_ACCEPTED
	EVENT_ACCEPT_FAILED   = zmq.EVENT_ACCEPT_FAILED
	EVENT_CLOSED          = zmq.EVENT_CLOSED
	EVENT_CLOSE_FAILED    = zmq.EVENT_CLOSE_FAILED
	EVENT_DISCONNECTED    = zmq.EVENT_DISCONNECTED
	EVENT_MONITOR_STOPPED = zmq.EVENT_MONITOR_STOPPED
	EVENT_ALL             = zmq.EVENT_ALL
	// ***** FIX THIS: not defined by zmq
	EVENT_HANDSHAKE_FAILED_NO_DETAIL = 0x0800
	EVENT_HANDSHAKE_SUCCEEDED        = 0x1000
	EVENT_HANDSHAKE_FAILED_PROTOCOL  = 0x2000
	EVENT_HANDSHAKE_FAILED_AUTH      = 0x4000
)

re-export zmq constants

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 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
}

Client - structure to hold a client connection

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

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
}

Jump to

Keyboard shortcuts

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