message

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package message contains implementations of types.Message.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMessagePartNotExist = errors.New("target message part does not exist")
	ErrBadMessageBytes     = errors.New("serialised message bytes were in unexpected format")
	ErrBlockCorrupted      = errors.New("serialised messages block was in unexpected format")
)

Errors returned by the message type.

Functions

func GetAllBytes added in v0.23.0

func GetAllBytes(m types.Message) [][]byte

GetAllBytes returns a 2D byte slice representing the raw byte content of the parts of a message.

func Lock

func Lock(msg types.Message, part int) types.Message

Lock wraps a message into a read only type that restricts access to only a single message part, accessible either by index 0 or -1.

func SetAllMetadata added in v0.23.0

func SetAllMetadata(m types.Message, meta types.Metadata)

SetAllMetadata sets the metadata of all message parts to match a provided metadata implementation.

func ToBytes added in v0.23.1

func ToBytes(m types.Message) []byte

ToBytes serialises a message into a single byte array.

Types

type Part added in v0.23.0

type Part struct {
	// contains filtered or unexported fields
}

Part is an implementation of types.Part, containing the contents and metadata of a message part.

func NewPart added in v0.23.0

func NewPart(data []byte) *Part

NewPart initializes a new message part.

func (*Part) Copy added in v0.23.0

func (p *Part) Copy() types.Part

Copy creates a shallow copy of the message part.

func (*Part) DeepCopy added in v0.23.0

func (p *Part) DeepCopy() types.Part

DeepCopy creates a new deep copy of the message part.

func (*Part) Get added in v0.23.0

func (p *Part) Get() []byte

Get returns the body of the message part.

func (*Part) JSON added in v0.23.0

func (p *Part) JSON() (interface{}, error)

JSON attempts to parse the message part as a JSON document and returns the result.

func (*Part) Metadata added in v0.23.0

func (p *Part) Metadata() types.Metadata

Metadata returns the metadata of the message part.

func (*Part) Set added in v0.23.0

func (p *Part) Set(data []byte) types.Part

Set the value of the message part.

func (*Part) SetJSON added in v0.23.0

func (p *Part) SetJSON(jObj interface{}) error

SetJSON attempts to marshal a JSON document into a byte slice and stores the result as the contents of the message part.

func (*Part) SetMetadata added in v0.23.0

func (p *Part) SetMetadata(meta types.Metadata) types.Part

SetMetadata sets the metadata of a message part

type Type

type Type struct {
	// contains filtered or unexported fields
}

Type is the standard implementation of types.Message, containing a multiple part message.

func FromBytes

func FromBytes(b []byte) (*Type, error)

FromBytes deserialises a Message from a byte array.

func New

func New(bslice [][]byte) *Type

New initializes a new message from a 2D byte slice, the slice can be nil.

func (*Type) Append

func (m *Type) Append(b ...types.Part) int

Append adds a new message part to the message.

func (*Type) Copy added in v0.23.0

func (m *Type) Copy() types.Message

Copy creates a new shallow copy of the message. Parts can be re-arranged in the new copy and JSON parts can be get/set without impacting other message copies. However, it is still unsafe to edit the raw content of message parts.

func (*Type) CreatedAt

func (m *Type) CreatedAt() time.Time

CreatedAt returns a timestamp whereby the message was created.

func (*Type) DeepCopy

func (m *Type) DeepCopy() types.Message

DeepCopy creates a new deep copy of the message. This can be considered an entirely new object that is safe to use anywhere.

func (*Type) Get

func (m *Type) Get(index int) types.Part

Get returns a message part at a particular index, indexes can be negative.

func (*Type) Iter

func (m *Type) Iter(f func(i int, p types.Part) error) error

Iter will iterate all parts of the message, calling f for each.

func (*Type) LazyCondition

func (m *Type) LazyCondition(label string, cond types.Condition) bool

LazyCondition resolves a particular condition on the message, if the condition has already been applied to this message the cached result is returned instead. When a message is altered in any way the conditions cache is cleared.

func (*Type) Len

func (m *Type) Len() int

Len returns the length of the message in parts.

func (*Type) SetAll

func (m *Type) SetAll(parts []types.Part)

SetAll changes the entire set of message parts.

Directories

Path Synopsis
Package mapper implements ways of splicing and mapping batches of messages so that their derivative parts can be processed individually and merged back into the original batch.
Package mapper implements ways of splicing and mapping batches of messages so that their derivative parts can be processed individually and merged back into the original batch.
Package metadata contains implementations of types.Metadata.
Package metadata contains implementations of types.Metadata.

Jump to

Keyboard shortcuts

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