gomq

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0, MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindServer

func BindServer(s Server, endpoint string) (net.Addr, error)

BindServer accepts a Server interface and an endpoint in the format <proto>://<address>:<port>. It then attempts to bind to the endpoint.

func ConnectClient

func ConnectClient(c Client, endpoint string) error

ConnectClient accepts a Client interface and an endpoint in the format <proto>://<address>:<port>. It then attempts to connect to the endpoint and perform a ZMTP handshake.

func ConnectDealer

func ConnectDealer(d Dealer, endpoint string) error

ConnectDealer accepts a Dealer interface and an endpoint in the format <proto>://<address>:<port>. It then attempts to connect to the endpoint and perform a ZMTP handshake.

Types

type Client

type Client interface {
	ZeroMQSocket
	Connect(endpoint string) error
}

Client is a gomq interface used for client sockets. It implements the Socket interface along with a Connect method for connecting to endpoints.

func NewClient

func NewClient(mechanism zmtp.SecurityMechanism) Client

NewClient accepts a zmtp.SecurityMechanism and returns a ClientSocket as a gomq.Client interface.

type ClientSocket

type ClientSocket struct {
	*Socket
}

ClientSocket is a ZMQ_CLIENT socket type. See: http://rfc.zeromq.org/spec:41

func (*ClientSocket) Connect

func (c *ClientSocket) Connect(endpoint string) error

Connect accepts a zeromq endpoint and connects the client socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

type Connection

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

Connection is a gomq connection. It holds both the net.Conn transport as well as the zmtp connection information.

func NewConnection

func NewConnection(netConn net.Conn, zmtpConn *zmtp.Connection) *Connection

NewConnection accepts a net.Conn, a *zmtp.Connection and returns a *gomq.Connection.

func (*Connection) Send

func (c *Connection) Send(b []byte) error

Send sends a message. FIXME should use a channel.

func (*Connection) SendMultipart

func (c *Connection) SendMultipart(b [][]byte) error

SendMultipart ...

type Dealer

type Dealer interface {
	ZeroMQSocket
	Connect(endpoint string) error
}

Dealer is a gomq interface used for dealer sockets. It implements the Socket interface along with a Connect method for connecting to endpoints.

func NewDealer

func NewDealer(mechanism zmtp.SecurityMechanism, id string) Dealer

NewDealer accepts a zmtp.SecurityMechanism and an ID. It returns a DealerSocket as a gomq.Dealer interface.

type DealerSocket

type DealerSocket struct {
	*Socket
}

DealerSocket is a ZMQ_DEALER socket type. See: https://rfc.zeromq.org/spec:28

func (*DealerSocket) Connect

func (d *DealerSocket) Connect(endpoint string) error

Connect accepts a zeromq endpoint and connects the dealer socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

type ErrBadProto

type ErrBadProto string

func (ErrBadProto) Error

func (e ErrBadProto) Error() string

type PullSocket

type PullSocket struct {
	*Socket
}

PullSocket is a ZMQ_PULL socket type. See: http://rfc.zeromq.org/spec:41

func NewPull

func NewPull(mechanism zmtp.SecurityMechanism) *PullSocket

NewPull accepts a zmtp.SecurityMechanism and returns a PullSocket as a gomq.Pull interface.

func (*PullSocket) Bind

func (s *PullSocket) Bind(endpoint string) (net.Addr, error)

Bind accepts a zeromq endpoint and binds the push socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

func (*PullSocket) Connect

func (c *PullSocket) Connect(endpoint string) error

Connect accepts a zeromq endpoint and connects the pull socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

type PushSocket

type PushSocket struct {
	*Socket
}

PushSocket is a ZMQ_PUSH socket type. See: http://rfc.zeromq.org/spec:41

func NewPush

func NewPush(mechanism zmtp.SecurityMechanism) *PushSocket

NewPush accepts a zmtp.SecurityMechanism and returns a PushSocket as a gomq.Push interface.

func (*PushSocket) Bind

func (s *PushSocket) Bind(endpoint string) (net.Addr, error)

Bind accepts a zeromq endpoint and binds the push socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

func (*PushSocket) Connect

func (s *PushSocket) Connect(endpoint string) error

Connect accepts a zeromq endpoint and connects the client socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

type Server

type Server interface {
	ZeroMQSocket
	Bind(endpoint string) (net.Addr, error)
}

Server is a gomq interface used for server sockets. It implements the Socket interface along with a Bind method for binding to endpoints.

func NewServer

func NewServer(mechanism zmtp.SecurityMechanism) Server

NewServer accepts a zmtp.SecurityMechanism and returns a ServerSocket as a gomq.Server interface.

type ServerSocket

type ServerSocket struct {
	*Socket
}

ServerSocket is a ZMQ_SERVER socket type. See: http://rfc.zeromq.org/spec:41

func (*ServerSocket) Bind

func (s *ServerSocket) Bind(endpoint string) (net.Addr, error)

Bind accepts a zeromq endpoint and binds the server socket to it. Currently the only transport supported is TCP. The endpoint string should be in the format "tcp://<address>:<port>".

type Socket

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

Socket is the base GoMQ socket type. It should probably not be used directly. Specifically typed sockets such as ClientSocket, ServerSocket, etc embed this type.

func NewSocket

func NewSocket(asServer bool, sockType zmtp.SocketType, sockID zmtp.SocketIdentity, mechanism zmtp.SecurityMechanism) *Socket

NewSocket accepts an asServer boolean, zmtp.SocketType, a socket identity and a zmtp.SecurityMechanism and returns a *Socket.

func (*Socket) AddConnection

func (s *Socket) AddConnection(conn *Connection)

AddConnection adds a gomq.Connection to the socket. It is goroutine safe.

func (*Socket) Close

func (s *Socket) Close()

Close closes all underlying transport connections for the socket.

func (*Socket) GetConnection

func (s *Socket) GetConnection(uuid string) (*Connection, error)

GetConnection returns the connection by identity

func (*Socket) Recv

func (s *Socket) Recv() ([]byte, error)

Recv receives a message from the Socket's message channel and returns it.

func (*Socket) RecvChannel

func (s *Socket) RecvChannel() chan *zmtp.Message

RecvChannel returns the Socket's receive channel used for receiving messages.

func (*Socket) RecvMultipart

func (s *Socket) RecvMultipart() ([][]byte, error)

func (*Socket) RemoveConnection

func (s *Socket) RemoveConnection(uuid string)

RemoveConnection accepts the uuid of a connection and removes that gomq.Connection from the socket if it exists. FIXME will bomb if uuid does not exist in map

func (*Socket) RetryInterval

func (s *Socket) RetryInterval() time.Duration

RetryInterval returns the retry interval used for asyncronous bind / connect.

func (*Socket) SecurityMechanism

func (s *Socket) SecurityMechanism() zmtp.SecurityMechanism

SecurityMechanism returns the Socket's zmtp.SecurityMechanism.

func (*Socket) Send

func (s *Socket) Send(b []byte) error

Send sends to all conn a message. FIXME should use a channel.

func (*Socket) SendMultipart

func (s *Socket) SendMultipart(b [][]byte) error

func (*Socket) SocketIdentity

func (s *Socket) SocketIdentity() zmtp.SocketIdentity

SocketIdentity returns the Socket's zmtp.SocketIdentity.

func (*Socket) SocketType

func (s *Socket) SocketType() zmtp.SocketType

SocketType returns the Socket's zmtp.SocketType.

type ZeroMQSocket

type ZeroMQSocket interface {
	Recv() ([]byte, error)
	Send([]byte) error
	RetryInterval() time.Duration
	SocketType() zmtp.SocketType
	SocketIdentity() zmtp.SocketIdentity
	SecurityMechanism() zmtp.SecurityMechanism
	AddConnection(*Connection)
	RemoveConnection(string)
	RecvChannel() chan *zmtp.Message

	SendMultipart([][]byte) error
	RecvMultipart() ([][]byte, error)

	Close()
}

ZeroMQSocket is the base gomq interface.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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