Documentation ¶
Overview ¶
Package shm provides a shared memory transport implementation.
The messages in this transport are delivered by native Go channels.
Typical usage of a connection:
cfg := NewConnection() // Initialises a shared memory connection s, c := cfg.Endpoints() // Equivalent to cfg.Accept(), cfg.Connect() defer func(s *IOChan){ if err := s.Close(); err != nil { // handle errors }(s) } ... defer func(c *IOChan){ if err := c.Close(); err != nil { // handle errors }(c) }
Client c and Server s can then be used as I/O streams implementing io.Reader and io.Writer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelNotReadyError ¶
type ChannelNotReadyError struct {
// contains filtered or unexported fields
}
ChannelNotReadyError is the kind of error where a channel is not ready to be used (e.g. uninitialised).
func (ChannelNotReadyError) Error ¶
func (e ChannelNotReadyError) Error() string
type ConnCfg ¶
type ConnCfg struct {
// contains filtered or unexported fields
}
ConnCfg is a connection configuration, contains the details required to establish a connection.
func NewBufferedConnection ¶
NewBufferedConnection is a convenient wrapper for an in-memory connection and can be used as either server-side or client-side.
func NewConnection ¶
func NewConnection() ConnCfg
NewConnection is a convenient wrapper for an in-memory connection and can be used as either server-side or client-side.
func (ConnCfg) Accept ¶
Accept listens for and accepts connection from a TCP socket using details from cfg, and returns the TCP stream as a ReadWriteCloser.
Accept blocks while waiting for connection to be accepted.
type IOChan ¶
type IOChan struct {
// contains filtered or unexported fields
}
IOChan is a connected shared memory connection, and wraps a pair of read/write Go channels for communication.
IOChan implements ReadWriteCloser and can be used as it. Messages are delimited by the data type boundary as they are passed as pointers. No serialisation are defined for IOChan.