zmqutil

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2017 License: ISC Imports: 12 Imported by: 2

Documentation

Overview

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)

disconnect old addresses and close all

func MakeKeyPair

func MakeKeyPair(publicKeyFileName string, privateKeyFileName string) error

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)

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

func NewServerSocket

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

create a socket suitable for a server side connection

func NewSignalPair

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

return a pair of connected push/pull sockets for shutdown signalling

func ReadKeyFile

func ReadKeyFile(keyFileName string) ([]byte, bool, error)

read a public key from a file returning it as a 32 byte string

func ReadPrivateKeyFile

func ReadPrivateKeyFile(keyFileName string) ([]byte, error)

read a private key from a file returning it as a 32 byte string

func ReadPublicKeyFile

func ReadPublicKeyFile(keyFileName string) ([]byte, error)

read a public key from a file returning it as a 32 byte string

func StartAuthentication

func StartAuthentication() error

initilaise the ZMQ security subsystem

Types

type Client

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

structure to hold a client connection

func ClientFromSocket added in v0.3.23

func ClientFromSocket(socket *zmq.Socket) *Client

find the client corresponding to a socket

func NewClient

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

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

func (*Client) BeginPolling added in v0.3.23

func (client *Client) BeginPolling(poller *Poller, events zmq.State) *zmq.Socket

add poller to client

func (*Client) Close

func (client *Client) Close() error

disconnect old address and close

func (*Client) Connect

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

disconnect old address and connect to new

func (*Client) IsConnected

func (client *Client) IsConnected() bool

check if connected to a node

func (*Client) IsConnectedTo

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

check if connected to a specific node

func (*Client) Receive

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

receive a reply

func (*Client) Reconnect

func (client *Client) Reconnect() error

close and reopen the connection

func (*Client) ReconnectReturningSocket added in v0.3.23

func (client *Client) ReconnectReturningSocket() (*zmq.Socket, error)

close and reopen the connection

func (*Client) Send

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

send a message

func (Client) String added in v0.3.16

func (client Client) String() string

to string

type Poller added in v0.3.23

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

structure to hold a poller

func NewPoller added in v0.3.23

func NewPoller() *Poller

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 a socket to a poller

func (*Poller) Poll added in v0.3.23

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

perform a poll

func (*Poller) Remove added in v0.3.23

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

remove a socket from a poller

Jump to

Keyboard shortcuts

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