Listener is an interface to the underlying listener for a transport
and address.
type Message struct {
Header []byte
Body []byte
Pipe Pipe
Message encapsulates the messages that we exchange back and forth. The
meaning of the Header and Body fields, and where the splits occur, will
vary depending on the protocol. Note however that any headers applied by
transport layers (including TCP/ethernet headers, and SP protocol
independent length headers), are *not* included in the Header.
func NewMessage(sz int) *Message
NewMessage is the supported way to obtain a new Message. This makes
use of a "cache" which greatly reduces the load on the garbage collector.
func (m *Message) Clone()
Clone bumps the reference count on the message, allowing it to be
shared. Callers of this MUST ensure that the message is never modified.
If a read-only copy needs to be made "unique", callers can do so by
using the Uniq function.
func (m *Message) Dup() *Message
Dup creates a "duplicate" message. The message is made as a
deep copy, so the resulting message is safe to modify.
func (m *Message) Free()
Free releases the message to the pool from which it was allocated.
While this is not strictly necessary thanks to GC, doing so allows
for the resources to be recycled without engaging GC. This can have
rather substantial benefits for performance.
func (m *Message) MakeUnique() *Message
MakeUnique ensures that the message is not shared. If the reference
count on the message is one, then the message is returned as is.
Otherwise a new copy of hte message is made, and the reference count
on the original is dropped. Note that it is an error for the caller
to use the original message after this function; the caller should
always do `m = m.MakeUnique()`. This function should be called whenever
the message is leaving the control of the caller, such as when passing
it to a user program.
Note that transports always should call this on their transmit path
if they are going to modify the message. (Most do not.)
ID() uint32
Address() string
GetOption(name string) (interface{}, error)
Listener() Listener
Dialer() Dialer
Close() error
Pipe represents the high level interface to a low level communications
channel. There is one of these associated with a given TCP connection,
for example. This interface is intended for application use.
Note that applications cannot send or receive data on a Pipe directly.
type PipeEventHook func(PipeEvent, Pipe)
PipeEventHook is an application supplied function to be called when
events occur relating to a Pipe.
AddPipe(ProtocolPipe) error
RemovePipe(ProtocolPipe)
OpenContext() (ProtocolContext, error)
ProtocolBase provides the protocol-specific handling for sockets.
This is the new style API for sockets, and is how protocols provide
their specific handling.
SendMsg(*Message) error
RecvMsg() (*Message, error)
GetOption(string) (interface{}, error)
SetOption(string, interface{}) error
ProtocolContext is a "context" for a protocol, which contains the
various stateful operations such as timers, etc. necessary for
running the protocol. This is separable from the protocol itself
as the protocol may permit the creation of multiple contexts.
type ProtocolPipe interface {
ID() uint32
Close() error
SendMsg(*Message) error
RecvMsg() *Message
SetPrivate(interface{})
GetPrivate() interface{}
ProtocolPipe represents the handle that a Protocol implementation has
to the underlying stream transport. It can be thought of as one side
of a TCP, IPC, or other type of connection.
type Socket interface {
Info() ProtocolInfo
Close() error
Send([]byte) error
Recv() ([]byte, error)
SendMsg(*Message) error
RecvMsg() (*Message, error)
Dial(addr string) error
DialOptions(addr string, options map[string]interface{}) error
NewDialer(addr string, options map[string]interface{}) (Dialer, error)
Listen(addr string) error
ListenOptions(addr string, options map[string]interface{}) error
NewListener(addr string, options map[string]interface{}) (Listener, error)
GetOption(name string) (interface{}, error)
SetOption(name string, value interface{}) error
OpenContext() (Context, error)
SetPipeEventHook(PipeEventHook) PipeEventHook
Socket is the main access handle applications use to access the SP
system. It is an abstraction of an application's "connection" to a
messaging topology. Applications can have more than one Socket open
at a time.
type TranDialer interface {
Dial() (TranPipe, error)
SetOption(name string, value interface{}) error
GetOption(name string) (value interface{}, err error)
TranDialer represents the client side of a connection. Clients initiate
the connection.
TranDialer is only intended for use by transport implementors, and should
not be directly used in applications.
type TranListener interface {
Listen() error
Accept() (TranPipe, error)
Close() error
SetOption(name string, value interface{}) error
GetOption(name string) (value interface{}, err error)
Address() string
TranListener represents the server side of a connection. Servers respond
to a connection request from clients.
TranListener is only intended for use by transport implementors, and should
not be directly used in applications.
type TranPipe interface {
Send(*Message) error
Recv() (*Message, error)
Close() error
GetOption(string) (interface{}, error)
TranPipe behaves like a full-duplex message-oriented connection between two
peers. Callers may call operations on a Pipe simultaneously from
different goroutines. (These are different from net.Conn because they
provide message oriented semantics.)
Pipe is only intended for use by transport implementors, and should
not be directly used in applications.
type Transport interface {
Scheme() string
NewDialer(url string, sock Socket) (TranDialer, error)
NewListener(url string, sock Socket) (TranListener, error)
Transport is the interface for transport suppliers to implement.
Package errors just defines some constant error codes, and is intended to be directly imported.
Package errors just defines some constant error codes, and is intended to be directly imported.
context implements a request/reply server that utilizes a pool of worker goroutines to service multiple requests simultaneously.
context implements a request/reply server that utilizes a pool of worker goroutines to service multiple requests simultaneously.
pair implements a pair example.
pair implements a pair example.
pipeline
pipeline implements a one way pipe example.
pipeline implements a one way pipe example.
pubsub
pubsub implements a publish/subscribe example.
pubsub implements a publish/subscribe example.
raw implements an example concurrent request/reply server, using the raw server socket.
raw implements an example concurrent request/reply server, using the raw server socket.
reqrep
reqprep implements a request/reply example.
reqprep implements a request/reply example.
survey
survey implements a survey example.
survey implements a survey example.
websocket
websocket implements a simple websocket server for mangos, demonstrating how to use multiplex multiple sockets on a single HTTP server instance.
websocket implements a simple websocket server for mangos, demonstrating how to use multiplex multiple sockets on a single HTTP server instance.
Package pull implements the PULL protocol, which is the read side of the pipeline pattern.
Package pull implements the PULL protocol, which is the read side of the pipeline pattern.
Package push implements the PUSH protocol, which is the write side of the pipeline pattern.
Package push implements the PUSH protocol, which is the write side of the pipeline pattern.
Package rep implements the REP protocol, which is the response side of the request/response pattern.
Package rep implements the REP protocol, which is the response side of the request/response pattern.
Package req implements the REQ protocol, which is the request side of the request/response pattern.
Package req implements the REQ protocol, which is the request side of the request/response pattern.
respondent
Package respondent implements the RESPONDENT protocol, which is the response side of the survey pattern.
Package respondent implements the RESPONDENT protocol, which is the response side of the survey pattern.
Package star implements a new, experimental protocol called "STAR".
Package star implements a new, experimental protocol called "STAR".
Package sub implements the SUB protocol.
Package sub implements the SUB protocol.
surveyor
Package surveyor implements the SURVEYOR protocol.
Package surveyor implements the SURVEYOR protocol.
Package xbus implements the BUS protocol.
Package xbus implements the BUS protocol.
xpair
Package xpair implements the PAIR protocol.
Package xpair implements the PAIR protocol.
xpair1
Package xpair1 implements the PAIRv1 protocol in monogamous mode only.
Package xpair1 implements the PAIRv1 protocol in monogamous mode only.
Package xpub implements the PUB protocol.
Package xpub implements the PUB protocol.
xpull
Package xpull implements the PULL protocol.
Package xpull implements the PULL protocol.
xpush
Package xpush implements the raw PUSH protocol.
Package xpush implements the raw PUSH protocol.
Package xrep implements the raw REP protocol, which is the response side of the request/response pattern.
Package xrep implements the raw REP protocol, which is the response side of the request/response pattern.
Package xreq implements the raw REQ protocol, which is the request side of the request/response pattern.
Package xreq implements the raw REQ protocol, which is the request side of the request/response pattern.
xrespondent
Package xrespondent implements the raw RESPONDENT protocol, which is the response side of survey pattern.
Package xrespondent implements the raw RESPONDENT protocol, which is the response side of survey pattern.
xstar
Package xstar implements the experimental star protocol.
Package xstar implements the experimental star protocol.
Package xsub implements the raw SUB protocol.
Package xsub implements the raw SUB protocol.
xsurveyor
Package xsurveyor implements the SURVEYOR protocol.
Package xsurveyor implements the SURVEYOR protocol.
go.dev uses cookies from Google to deliver and enhance the quality of its services and to
analyze traffic.
Learn more.