codec

package
v0.0.0-...-1d97044 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodecI

type CodecI interface {
	ReaderI
	WriterI
	Close() error
	String() string
}

Codec encodes/decodes various types of messages used within go-micro. ReadHeader and ReadBody are called in pairs to read requests/responses from the connection. Close is called when finished with the connection. ReadBody may be called with a nil argument to force the body to be read and discarded.

type Marshaler

type Marshaler interface {
	Marshal(interface{}) ([]byte, error)
	Unmarshal([]byte, interface{}) error
	String() string
}

Marshaler is a simple encoding interface used for the broker/transport where headers are not supported by the underlying implementation.

type Message

type Message struct {
	Id       string
	Type     MessageType
	Target   string
	Method   string
	Endpoint string
	Error    string

	// The values read from the socket
	Header map[string]string
	Body   []byte
}

Message represents detailed information about the communication, likely followed by the body. In the case of an error, body may be nil.

type MessageType

type MessageType int32

MessageType x ENUM( Error Request Response Event Unknown )

const (
	// MessageTypeError is a MessageType of type Error
	MessageTypeError MessageType = iota
	// MessageTypeRequest is a MessageType of type Request
	MessageTypeRequest
	// MessageTypeResponse is a MessageType of type Response
	MessageTypeResponse
	// MessageTypeEvent is a MessageType of type Event
	MessageTypeEvent
	// MessageTypeUnknown is a MessageType of type Unknown
	MessageTypeUnknown
)

func ParseMessage

func ParseMessage(name string) (MessageType, *errorAVA.Error)

ParseMessage attempts to convert a string to a Message

func (MessageType) MarshalText

func (x MessageType) MarshalText() ([]byte, *errorAVA.Error)

MarshalText implements the text marshaller method

func (MessageType) String

func (x MessageType) String() string

String implements the Stringer interface.

func (MessageType) UnmarshalText

func (x MessageType) UnmarshalText(text []byte) (MessageType, *errorAVA.Error)

UnmarshalText implements the text unmarshaller method

type NewCodec

type NewCodec func(io.ReadWriteCloser) CodecI

Takes in a connection/buffer and returns a new Codec

type ReaderI

type ReaderI interface {
	ReadHeader(*Message, MessageType) error
	ReadBody(interface{}) error
}

type WriterI

type WriterI interface {
	Write(*Message, interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL