gozmq

package module
v0.0.0-...-d20a764 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 9 Imported by: 41

README

gozmq

GoZMQ is a pure Go ZMQ pubsub client implementation.

Only a very limited subset of ZMQ is implemented: NULL security, SUB socket.

Usage

Please visit https://godoc.org/github.com/tstranex/gozmq for the full documentation.

Installation

To install, run:

go get github.com/tstranex/gozmq

Example

See example/main.go for a full example.

c, err := gozmq.Subscribe("127.0.0.1:1234", []string{""})
for {
  msg, err := c.Receive()
  // Process message
}

Documentation

Overview

Package gozmq provides a ZMQ pubsub client.

It implements the protocol described here: http://rfc.zeromq.org/spec:23/ZMTP/

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxBodySize is the maximum frame size we're willing to accept.
	// The maximum size of a Bitcoin message is 32MiB.
	MaxBodySize uint64 = 0x02000000
)

Functions

This section is empty.

Types

type Conn

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

Conn is a connection to a ZMQ server.

func Subscribe

func Subscribe(addr string, topics []string, timeout time.Duration) (*Conn, error)

Subscribe connects to a publisher server and subscribes to the given topics.

func (*Conn) Close

func (c *Conn) Close() error

Close the underlying connection. Any further operations will fail.

func (*Conn) Receive

func (c *Conn) Receive(bufs [][]byte) ([][]byte, error)

Receive a message from the publisher. Messages can be composed of multiple sub-messages. They are read into the provided buffers. Each buffer should be of sufficient length to successfully read messages. If none are provided, then buffers will be allocated for each sub-message. It blocks until a new message is received. If the connection times out and it was not explicitly terminated, then a timeout error is returned. Otherwise, if it was explicitly terminated, then io.EOF is returned.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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