Documentation ¶
Overview ¶
Package goentangle provides the Entangle runtime library for Go.
Index ¶
- Variables
- func DeserializeBinary(input interface{}) ([]byte, error)
- func DeserializeBool(input interface{}) (bool, error)
- func DeserializeFloat32(input interface{}) (float32, error)
- func DeserializeFloat64(input interface{}) (float64, error)
- func DeserializeInt16(input interface{}) (int16, error)
- func DeserializeInt32(input interface{}) (int32, error)
- func DeserializeInt64(input interface{}) (int64, error)
- func DeserializeInt8(input interface{}) (int8, error)
- func DeserializeString(input interface{}) (string, error)
- func DeserializeUint16(input interface{}) (uint16, error)
- func DeserializeUint32(input interface{}) (uint32, error)
- func DeserializeUint64(input interface{}) (uint64, error)
- func DeserializeUint8(input interface{}) (uint8, error)
- type ClientConnHandler
- type CompressionMethod
- type Conn
- func (c *Conn) AcknowledgeNotification(responseTo Message) error
- func (c *Conn) Close()
- func (c *Conn) Description() string
- func (c *Conn) RaiseException(exception error, responseTo Message, trace Trace) error
- func (c *Conn) Receive() (msg Message, err error)
- func (c *Conn) Respond(result interface{}, responseTo Message, trace Trace) error
- func (c *Conn) SendNotification(method string, arguments []interface{}) (MessageId, error)
- func (c *Conn) SendRequest(method string, arguments []interface{}, trace bool) (MessageId, error)
- type Exception
- type ExceptionDefinition
- type ExceptionMessage
- type Message
- type MessageId
- type NotificationAcknowledgementMessage
- type NotificationMessage
- type Opcode
- type RequestMessage
- type ResponseMessage
- type Server
- type Trace
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidMessageData = errors.New("invalid message data received") ErrInvalidMessageOpcode = errors.New("invalid message opcode received") ErrInvalidMessageId = errors.New("invalid message ID received") ErrBadMessage = errors.New("bad message received") )
var ( // Bad message error definition. BadMessageError = NewExceptionDefinition("entangle", "BadMessage") // Internal server error. InternalServerError = NewExceptionDefinition("entangle", "InternalServerError") // Unknown method. UnknownMethodError = NewExceptionDefinition("entangle", "UnknownMethod") // Unknown exception. UnknownExceptionError = NewExceptionDefinition("entangle", "UnknownException") )
var (
ErrDeserializationError = errors.New("deserialization error")
)
var ErrShutdown = errors.New("connection is shut down")
Client connection is shut down.
Functions ¶
func DeserializeBinary ¶
Deserialize a binary.
Returns ErrDeserializationError if deserialization failed.
func DeserializeBool ¶
Deserialize a boolean.
Returns ErrDeserializationError if deserialization failed.
func DeserializeFloat32 ¶
Deserialize a 32-bit floating point number.
Returns ErrDeserializationError if deserialization failed.
func DeserializeFloat64 ¶
Deserialize a 64-bit floating point number.
Returns ErrDeserializationError if deserialization failed.
func DeserializeInt16 ¶
Deserialize a signed 16-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeInt32 ¶
Deserialize a signed 32-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeInt64 ¶
Deserialize a signed 64-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeInt8 ¶
Deserialize a signed 8-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeString ¶
Deserialize a string.
Returns ErrDeserializationError if deserialization failed.
func DeserializeUint16 ¶
Deserialize an unsigned 16-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeUint32 ¶
Deserialize an unsigned 32-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeUint64 ¶
Deserialize an unsigned 64-bit integer.
Returns ErrDeserializationError if deserialization failed.
func DeserializeUint8 ¶
Deserialize an unsigned 8-bit integer.
Returns ErrDeserializationError if deserialization failed.
Types ¶
type ClientConnHandler ¶
type ClientConnHandler struct {
// contains filtered or unexported fields
}
Client connection handler.
Convenience type for handling requests and responses for clients.
func NewClientConnHandler ¶
func NewClientConnHandler(conn *Conn) (h *ClientConnHandler)
New client connection handler.
type CompressionMethod ¶
type CompressionMethod uint8
Compression method.
const ( // Snappy. SnappyCompression CompressionMethod = iota )
Compression methods.
func DeserializeCompressionMethod ¶
func DeserializeCompressionMethod(input interface{}) (m CompressionMethod, ok bool)
Deserialize a compression method.
func (CompressionMethod) Compress ¶
func (m CompressionMethod) Compress(input []byte) (output []byte, err error)
Compress.
func (CompressionMethod) Decompress ¶
func (m CompressionMethod) Decompress(input []byte) (output []byte, err error)
Decompress.
func (CompressionMethod) String ¶
func (m CompressionMethod) String() string
func (CompressionMethod) Valid ¶
func (m CompressionMethod) Valid() bool
Test if a compression method is valid.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Connection.
Reading is only safe from one goroutine while writing is safe in a blocking manner form any number of goroutines.
func (*Conn) AcknowledgeNotification ¶
Acknowledge a notification.
func (*Conn) RaiseException ¶
Raise an exception.
func (*Conn) Receive ¶
Receive a message.
The returned error can be either io.EOF, ErrInvalidMessageData, ErrInvalidMessageOpcode or ErrInvalidMessageId, all of which are unrecoverable, or ErrBadMessage which doesn't prohibit the connection from continuing.
func (*Conn) SendNotification ¶
Send a notification.
type ExceptionDefinition ¶
type ExceptionDefinition interface { // New error. New(description string) Exception // New formatted error. // // Behaves like fmt.Printf. Newf(format string, a ...interface{}) Exception }
Entangle exception definition.
Exception definition that can produce an exception of a specific type.
func NewExceptionDefinition ¶
func NewExceptionDefinition(definition, name string) ExceptionDefinition
New error definition.
type ExceptionMessage ¶
type ExceptionMessage struct { // Definition. Definition string // Name. Name string // Description. Description string // Trace. Trace Trace // contains filtered or unexported fields }
Exception message.
func (*ExceptionMessage) MessageId ¶
func (m *ExceptionMessage) MessageId() MessageId
func (*ExceptionMessage) Serialize ¶
func (m *ExceptionMessage) Serialize() []interface{}
type Message ¶
type Message interface { // Message ID. MessageId() MessageId // Serialize the message. Serialize() []interface{} }
Message.
type NotificationAcknowledgementMessage ¶
type NotificationAcknowledgementMessage struct {
// contains filtered or unexported fields
}
Notification acknowledgement message.
func (*NotificationAcknowledgementMessage) MessageId ¶
func (m *NotificationAcknowledgementMessage) MessageId() MessageId
func (*NotificationAcknowledgementMessage) Serialize ¶
func (m *NotificationAcknowledgementMessage) Serialize() []interface{}
type NotificationMessage ¶
type NotificationMessage struct { // Method. Method string // Arguments. Arguments []interface{} // contains filtered or unexported fields }
Notification message.
func (*NotificationMessage) MessageId ¶
func (m *NotificationMessage) MessageId() MessageId
func (*NotificationMessage) Serialize ¶
func (m *NotificationMessage) Serialize() []interface{}
type Opcode ¶
type Opcode uint8
Opcode.
const ( // Request opcode. RequestOpcode Opcode = iota // Notification opcode. NotificationOpcode // Response opcode. ResponseOpcode // Exception opcode. ExceptionOpcode // Notification acknowledgement opcode. NotificationAcknowledgementOpcode // Compressed message opcode. CompressedMessageOpcode = 0x7f )
Opcodes.
type RequestMessage ¶
type RequestMessage struct { // Method. Method string // Arguments. Arguments []interface{} // Trace. Trace bool // contains filtered or unexported fields }
Request message.
func (*RequestMessage) MessageId ¶
func (m *RequestMessage) MessageId() MessageId
func (*RequestMessage) Serialize ¶
func (m *RequestMessage) Serialize() []interface{}
type ResponseMessage ¶
type ResponseMessage struct { // Result. Result interface{} // Trace. Trace Trace // contains filtered or unexported fields }
Response message.
func (*ResponseMessage) MessageId ¶
func (m *ResponseMessage) MessageId() MessageId
func (*ResponseMessage) Serialize ¶
func (m *ResponseMessage) Serialize() []interface{}
type Server ¶
type Server interface { // Accept accepts connections on the listener and serves requests for each // incoming connection. // // Accept blocks; the caller typically invokes it in a go statement. Accept(l net.Listener) error // Serve connections until the listener is closed. Serve(l net.Listener) error // ServeConn runs the server on a single connection. // // ServeConn blocks, serving the connection until the client hangs up. The // caller typically invokes ServeConn in a go statement. ServeConn(conn *Conn) // Wait for all connections to finish. // // Only valid when using Serve. Wait() }
Server.