message

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultType string = "grav.default"
)

DefaultType and other represent message consts

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	// Unique ID for this message
	UUID() string
	// ID of the parent event or request, such as HTTP request
	ParentID() string
	// The UUID of the message being responded to, if any
	ResponseTo() string
	// Type of message (application-specific)
	Type() string
	// Time the message was emitted
	Timestamp() time.Time
	// Raw data of message
	Data() []byte
	// Encoded Message object
	Marshal() ([]byte, error)
	// Unmarshal encoded Message into object
	Unmarshal([]byte) error
}

Message represents a message

func New

func New(msgType string, data []byte) Message

New creates a new Message with the built-in `_message` type

func NewFromBytes added in v0.0.2

func NewFromBytes(bytes []byte) (Message, error)

NewFromBytes returns a default _message that has been unmarshalled from bytes. Should only be used if the default _message type is being used.

func NewFromRequest added in v0.0.2

func NewFromRequest(r *http.Request) (Message, error)

NewFromRequest extracts an encoded Message from an HTTP request

func NewResponseTo

func NewResponseTo(msgType, responseTo string, data []byte) Message

NewResponseTo creates a new message in response to a previous message

func NewWithParentID

func NewWithParentID(msgType, parentID string, data []byte) Message

NewWithParentID returns a new message with the provided parent ID

type MsgChan

type MsgChan chan Message

MsgChan is a channel that accepts a message

type MsgFunc

type MsgFunc func(Message) error

MsgFunc is a callback function that accepts a message and returns an error

Jump to

Keyboard shortcuts

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