Documentation ¶
Index ¶
- type Command
- type Connection
- func (c *Connection) Prepare(mechanism SecurityMechanism, socketType SocketType, asServer bool, ...) (map[string]string, error)
- func (c *Connection) Recv(messageOut chan<- *Message)
- func (c *Connection) SendCommand(commandName string, body []byte) error
- func (c *Connection) SendFrame(body []byte) error
- type Message
- type MessageType
- type SecurityMechanism
- type SecurityMechanismType
- type SecurityNull
- type Socket
- type SocketType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a ZMTP level connection
func NewConnection ¶
func NewConnection(rw io.ReadWriter) *Connection
NewConnection accepts an io.ReadWriter and creates a new ZMTP connection
func (*Connection) Prepare ¶
func (c *Connection) Prepare(mechanism SecurityMechanism, socketType SocketType, asServer bool, applicationMetadata map[string]string) (map[string]string, error)
Prepare performs a ZMTP handshake over a Connection's readWriter
func (*Connection) Recv ¶
func (c *Connection) Recv(messageOut chan<- *Message)
Recv starts listening to the ReadWriter and passes *Message to a channel
func (*Connection) SendCommand ¶
func (c *Connection) SendCommand(commandName string, body []byte) error
SendCommand sends a ZMTP command over a Connection
func (*Connection) SendFrame ¶
func (c *Connection) SendFrame(body []byte) error
SendFrame sends a ZMTP frame over a Connection
type Message ¶
type Message struct { Index int Name string Body []byte Err error MessageType MessageType }
Message represents a ZMTP message
type MessageType ¶
type MessageType int
MessageType represents a "type" of ZMTP message (User, Command, Error)
const ( // UserMessage is a ZMTP message sent by a user UserMessage MessageType = iota // CommandMessage is a ZMTP command CommandMessage // ErrorMessage is.. an error message ErrorMessage )
type SecurityMechanism ¶
type SecurityMechanism interface { Type() SecurityMechanismType Handshake() error Encrypt([]byte) []byte }
SecurityMechanism is an interface for ZMTP security mechanisms
type SecurityMechanismType ¶
type SecurityMechanismType string
SecurityMechanismType denotes types of ZMTP security mechanisms
const ( // NullSecurityMechanismType is an empty security mechanism // that does no authentication nor encryption. NullSecurityMechanismType SecurityMechanismType = "NULL" // PlainSecurityMechanismType is a security mechanism that uses // plaintext passwords. It is a reference implementation and // should not be used to anything important. PlainSecurityMechanismType SecurityMechanismType = "PLAIN" // CurveSecurityMechanismType uses ZMQ_CURVE for authentication // and encryption. CurveSecurityMechanismType SecurityMechanismType = "CURVE" )
type SecurityNull ¶
type SecurityNull struct{}
SecurityNull implements the NullSecurityMechanismType
func NewSecurityNull ¶
func NewSecurityNull() *SecurityNull
NewSecurityNull returns a SecurityNull mechanism
func (*SecurityNull) Encrypt ¶
func (s *SecurityNull) Encrypt(data []byte) []byte
Encrypt encrypts a []byte
func (*SecurityNull) Handshake ¶
func (s *SecurityNull) Handshake() error
Handshake performs the ZMTP handshake for this security mechanism
func (*SecurityNull) Type ¶
func (s *SecurityNull) Type() SecurityMechanismType
Type returns the security mechanisms type
type Socket ¶
type Socket interface { Type() SocketType IsSocketTypeCompatible(socketType SocketType) bool IsCommandTypeValid(name string) bool }
Socket is a ZMTP socket
func NewSocket ¶
func NewSocket(socketType SocketType) (Socket, error)
NewSocket returns a new ZMTP socket
type SocketType ¶
type SocketType string
SocketType is a ZMTP socket type
const ( // ClientSocketType is a ZMQ_CLIENT socket ClientSocketType SocketType = "CLIENT" // ServerSocketType is a ZMQ_SERVER socket ServerSocketType SocketType = "SERVER" // PullSocketType is a ZMQ_PULL socket PullSocketType SocketType = "PULL" // PushSocketType is a ZMQ_PUSH socket PushSocketType SocketType = "PUSH" )