messages

package
v1.0.6-1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes map[string]string

Attributes representation as key/value

func (Attributes) MarshalJSON

func (attr Attributes) MarshalJSON() ([]byte, error)

MarshalJSON generates json string for Attributes type

type Message

type Message struct {
	ID      string     `json:"messageId,omitempty"`
	Attr    Attributes `json:"attributes,omitempty"`  // used to hold attribute key/value store
	Data    string     `json:"data"`                  // base64 encoded data payload
	PubTime string     `json:"publishTime,omitempty"` // publish timedate of message
}

Message struct used to hold message information

func LoadMsgJSON

func LoadMsgJSON(input []byte) (Message, error)

LoadMsgJSON creates a new Message from a json string represenatation

func New

func New(data string) Message

New creates a new Message based on data string provided

func (*Message) AttrExists

func (msg *Message) AttrExists(key string) (bool, string)

AttrExists checks if an attribute exists based on key. Returns also a boolean if the attribute exists

func (*Message) ExportJSON

func (msg *Message) ExportJSON() (string, error)

ExportJSON exports whole Message Structure as a json string

func (*Message) GetAttribute

func (msg *Message) GetAttribute(key string) (string, error)

GetAttribute takes a key and return attribute value if exists (based on key)

func (*Message) GetDecoded

func (msg *Message) GetDecoded() string

GetDecoded returns the base64 payload in it's original form

func (*Message) InsertAttribute

func (msg *Message) InsertAttribute(key string, value string) error

InsertAttribute takes a key/value item and appends it in Message's attributes

func (*Message) RemoveAttribute

func (msg *Message) RemoveAttribute(key string) error

RemoveAttribute takes a key and removes attribute if exists (based on key)

func (Message) Size

func (msg Message) Size() int64

Size returns the messages size in bytes

func (*Message) UpdateAttribute

func (msg *Message) UpdateAttribute(key string, value string) error

UpdateAttribute updates an existing attribute based on key and new value

type MsgIDs

type MsgIDs struct {
	IDs []string `json:"messageIds"`
}

MsgIDs utility struct

func (*MsgIDs) ExportJSON

func (msgIDs *MsgIDs) ExportJSON() (string, error)

ExportJSON exports whole msgId Structure as a json string

type MsgList

type MsgList struct {
	Msgs []Message `json:"messages"`
}

MsgList is used to hold a list of messages

func LoadMsgListJSON

func LoadMsgListJSON(input []byte) (MsgList, error)

LoadMsgListJSON creates a MsgList from a json definition

func (*MsgList) ExportJSON

func (msgList *MsgList) ExportJSON() (string, error)

ExportJSON exports whole MsgList as a json string

func (MsgList) TotalSize

func (msgL MsgList) TotalSize() int64

TotalSize returns the total bytesize of a message list

type PushMsg

type PushMsg struct {
	Msg Message `json:"message"`
	Sub string  `json:"subscription"`
}

PushMsg contains structure for push messages

func (*PushMsg) ExportJSON

func (pMsg *PushMsg) ExportJSON() (string, error)

ExportJSON exports whole Message Structure as a json string

type RecList

type RecList struct {
	RecMsgs []RecMsg `json:"receivedMessages"`
}

RecList holds the array of the receivedMessages - subscription related

func (*RecList) ExportJSON

func (recList *RecList) ExportJSON() (string, error)

ExportJSON exports whole msgId Structure as a json string

func (RecList) TotalSize

func (msgL RecList) TotalSize() int64

TotalSize returns the total bytesize of a message list

type RecMsg

type RecMsg struct {
	AckID string  `json:"ackId,omitempty"`
	Msg   Message `json:"message"`
}

RecMsg holds info for a received message

Jump to

Keyboard shortcuts

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