nanomsg

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package nanomsg is a compatibility wrapper. It attempts to offer an a minimal replacement for the same API as github.com/op/go-nanomsg, but does so using the mangos package underneath. The intent is to to facilitate converting existing applications to mangos.

Only the synchronous API is supported -- the Poller/PollItem API is not present here. Applications are encouraged to use Go's native support for goroutines and channels to build such features if needed.

New applications should be developed with mangos API directly, rather than using this compatibility shim. Additionally, note that this API lacks a number of the performance improvements in the mangos API; very specifically it does not support message reuse, which means that a busy consumer is going to thrash the garbage collector in Go pretty hard.

Only a subset of the mangos capabilities are exported through this API; to get the full feature set (e.g. TLS over TCP) the mangos API should be used directly.

Index

Constants

View Source
const (
	AF_SP     = Domain(0)
	AF_SP_RAW = Domain(1)
)

Constants for socket type.

Constants for protocols.

View Source
const DontWait = 1

DontWait is an (unsupported!) flag option.

Variables

This section is empty.

Functions

This section is empty.

Types

type BusSocket

type BusSocket struct {
	*Socket
}

BusSocket is a socket associated with the BUS protocol.

func NewBusSocket

func NewBusSocket() (*BusSocket, error)

NewBusSocket creates a BUS socket.

type Domain

type Domain int

Domain is the socket domain or address family. We use it to indicate either normal or raw mode sockets.

type Endpoint

type Endpoint struct {
	Address string
}

Endpoint is a structure that holds the peer address for now.

func (*Endpoint) String

func (ep *Endpoint) String() string

String just returns the endpoint address for now.

type PairSocket

type PairSocket struct {
	*Socket
}

PairSocket is a socket associated with the PAIR protocol.

func NewPairSocket

func NewPairSocket() (*PairSocket, error)

NewPairSocket creates a PAIR socket.

type Protocol

type Protocol int

Protocol is the numeric abstraction to the various protocols or patterns that Mangos supports.

type PubSocket

type PubSocket struct {
	*Socket
}

PubSocket is a socket associated with the PUB protocol.

func NewPubSocket

func NewPubSocket() (*PubSocket, error)

NewPubSocket creates a PUB socket.

type PullSocket

type PullSocket struct {
	*Socket
}

PullSocket is a socket associated with the PULL protocol.

func NewPullSocket

func NewPullSocket() (*PullSocket, error)

NewPullSocket creates a PULL socket.

type PushSocket

type PushSocket struct {
	*Socket
}

PushSocket is a socket associated with the PUSH protocol.

func NewPushSocket

func NewPushSocket() (*PushSocket, error)

NewPushSocket creates a PUSH socket.

type RepSocket

type RepSocket struct {
	*Socket
}

RepSocket is a socket associated with the REP protocol.

func NewRepSocket

func NewRepSocket() (*RepSocket, error)

NewRepSocket creates a REP socket.

type ReqSocket

type ReqSocket struct {
	*Socket
}

ReqSocket is a socket associated with the REQ protocol.

func NewReqSocket

func NewReqSocket() (*ReqSocket, error)

NewReqSocket creates a REQ socket.

type RespondentSocket

type RespondentSocket struct {
	*Socket
}

RespondentSocket is a socket associated with the RESPONDENT protocol.

func NewRespondentSocket

func NewRespondentSocket() (*RespondentSocket, error)

NewRespondentSocket creates a RESPONDENT socket.

type Socket

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

Socket is the main connection to the underlying library.

func NewSocket

func NewSocket(d Domain, p Protocol) (*Socket, error)

NewSocket allocates a new Socket. The Socket is the handle used to access the underlying library.

func (*Socket) Bind

func (s *Socket) Bind(addr string) (*Endpoint, error)

Bind creates sets up to receive incoming connections from remote peers. This wraps around mangos' Listen() socket interface.

func (*Socket) Close

func (s *Socket) Close() error

Close shuts down the socket.

func (*Socket) Connect

func (s *Socket) Connect(addr string) (*Endpoint, error)

Connect establishes (asynchronously) a client side connection to a remote peer. The client will attempt to keep reconnecting. This wraps around mangos' Dial() socket inteface.

func (*Socket) Domain

func (s *Socket) Domain() (Domain, error)

Domain returns the socket domain, either AF_SP or AF_SP_RAW.

func (*Socket) Linger

func (s *Socket) Linger() (time.Duration, error)

Linger should set the TCP linger time, but at present is not supported.

func (*Socket) Protocol

func (s *Socket) Protocol() (Protocol, error)

Protocol returns the numeric value of the sockets protocol, such as REQ, REP, SUB, PUB, etc.

func (*Socket) Recv

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

Recv receives a message. For AF_SP_RAW messages the header data will be included at he start of the returned byte slice (otherwise it will be stripped). At this time no flags are supported.

func (*Socket) RecvFd

func (s *Socket) RecvFd() (uintptr, error)

RecvFd is not supported.

func (*Socket) RecvTimeout

func (s *Socket) RecvTimeout() (time.Duration, error)

RecvTimeout retrieves the receive timeout. Negative values indicate an infinite timeout.

func (*Socket) Send

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

Send sends a message. For AF_SP_RAW messages the header must be included in the argument. At this time, no flags are supported.

func (*Socket) SendFd

func (s *Socket) SendFd() (uintptr, error)

SendFd is not supported.

func (*Socket) SendPrio

func (s *Socket) SendPrio() (int, error)

SendPrio is intended to set send priorities. Mangos does not support send priorities at present.

func (*Socket) SendTimeout

func (s *Socket) SendTimeout() (time.Duration, error)

SendTimeout retrieves the send timeout. Negative values indicate an infinite timeout.

func (*Socket) SetLinger

func (s *Socket) SetLinger(time.Duration) error

SetLinger is not supported.

func (*Socket) SetRecvTimeout

func (s *Socket) SetRecvTimeout(d time.Duration) error

SetRecvTimeout sets a timeout for receive operations. The Recv() function will return an error if no message is received within this time.

func (*Socket) SetSendPrio

func (s *Socket) SetSendPrio(int) error

SetSendPrio is not supported.

func (*Socket) SetSendTimeout

func (s *Socket) SetSendTimeout(d time.Duration) error

SetSendTimeout sets the send timeout. Negative values indicate an infinite timeout. The Send() operation will return an error if a message cannot be sent within this time.

func (*Socket) Shutdown

func (s *Socket) Shutdown(*Endpoint) error

Shutdown should shut down a particular endpoint. Mangos lacks the underlying functionality to support this at present.

type SubSocket

type SubSocket struct {
	*Socket
}

SubSocket is a socket associated with the SUB protocol.

func NewSubSocket

func NewSubSocket() (*SubSocket, error)

NewSubSocket creates a SUB socket.

func (*SubSocket) Subscribe

func (s *SubSocket) Subscribe(topic string) error

Subscribe registers interest in a topic.

func (*SubSocket) Unsubscribe

func (s *SubSocket) Unsubscribe(topic string) error

Unsubscribe unregisters interest in a topic.

type SurveyorSocket

type SurveyorSocket struct {
	*Socket
}

SurveyorSocket is a socket associated with the SURVEYOR protocol.

func NewSurveyorSocket

func NewSurveyorSocket() (*SurveyorSocket, error)

NewSurveyorSocket creates a SURVEYOR socket.

func (*SurveyorSocket) Deadline

func (s *SurveyorSocket) Deadline() (time.Duration, error)

Deadline returns the survey deadline on the socket. After this time, responses from a survey will be discarded.

func (*SurveyorSocket) SetDeadline

func (s *SurveyorSocket) SetDeadline(d time.Duration) error

SetDeadline sets the survey deadline on the socket. After this time, responses from a survey will be discarded.

Jump to

Keyboard shortcuts

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