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
- type BusSocket
- type Domain
- type Endpoint
- type PairSocket
- type Protocol
- type PubSocket
- type PullSocket
- type PushSocket
- type RepSocket
- type ReqSocket
- type RespondentSocket
- type Socket
- func (s *Socket) Bind(addr string) (*Endpoint, error)
- func (s *Socket) Close() error
- func (s *Socket) Connect(addr string) (*Endpoint, error)
- func (s *Socket) Domain() (Domain, error)
- func (s *Socket) Linger() (time.Duration, error)
- func (s *Socket) Protocol() (Protocol, error)
- func (s *Socket) Recv(flags int) ([]byte, error)
- func (s *Socket) RecvFd() (uintptr, error)
- func (s *Socket) RecvTimeout() (time.Duration, error)
- func (s *Socket) Send(b []byte, flags int) (int, error)
- func (s *Socket) SendFd() (uintptr, error)
- func (s *Socket) SendPrio() (int, error)
- func (s *Socket) SendTimeout() (time.Duration, error)
- func (s *Socket) SetLinger(time.Duration) error
- func (s *Socket) SetRecvTimeout(d time.Duration) error
- func (s *Socket) SetSendPrio(int) error
- func (s *Socket) SetSendTimeout(d time.Duration) error
- func (s *Socket) Shutdown(*Endpoint) error
- type SubSocket
- type SurveyorSocket
Constants ¶
const ( AF_SP = Domain(0) AF_SP_RAW = Domain(1) )
Constants for socket type.
const ( PUSH = Protocol(mangos.ProtoPush) PULL = Protocol(mangos.ProtoPull) PUB = Protocol(mangos.ProtoPub) SUB = Protocol(mangos.ProtoSub) REQ = Protocol(mangos.ProtoReq) REP = Protocol(mangos.ProtoRep) SURVEYOR = Protocol(mangos.ProtoSurveyor) RESPONDENT = Protocol(mangos.ProtoRespondent) BUS = Protocol(mangos.ProtoBus) PAIR = Protocol(mangos.ProtoPair) )
Constants for protocols.
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.
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.
type PairSocket ¶
type PairSocket struct {
*Socket
}
PairSocket is a socket associated with the PAIR protocol.
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.
type PullSocket ¶
type PullSocket struct {
*Socket
}
PullSocket is a socket associated with the PULL protocol.
type PushSocket ¶
type PushSocket struct {
*Socket
}
PushSocket is a socket associated with the PUSH protocol.
type RepSocket ¶
type RepSocket struct {
*Socket
}
RepSocket is a socket associated with the REP protocol.
type ReqSocket ¶
type ReqSocket struct {
*Socket
}
ReqSocket is a socket associated with the REQ protocol.
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 ¶
NewSocket allocates a new Socket. The Socket is the handle used to access the underlying library.
func (*Socket) Bind ¶
Bind creates sets up to receive incoming connections from remote peers. This wraps around mangos' Listen() socket interface.
func (*Socket) Connect ¶
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) Protocol ¶
Protocol returns the numeric value of the sockets protocol, such as REQ, REP, SUB, PUB, etc.
func (*Socket) Recv ¶
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) RecvTimeout ¶
RecvTimeout retrieves the receive timeout. Negative values indicate an infinite timeout.
func (*Socket) Send ¶
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) SendPrio ¶
SendPrio is intended to set send priorities. Mangos does not support send priorities at present.
func (*Socket) SendTimeout ¶
SendTimeout retrieves the send timeout. Negative values indicate an infinite timeout.
func (*Socket) SetRecvTimeout ¶
SetRecvTimeout sets a timeout for receive operations. The Recv() function will return an error if no message is received within this time.
func (*Socket) SetSendTimeout ¶
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.
type SubSocket ¶
type SubSocket struct {
*Socket
}
SubSocket is a socket associated with the SUB protocol.
func (*SubSocket) Unsubscribe ¶
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.