protocol

package
v0.0.0-...-83e654d Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 7 Imported by: 29

Documentation

Index

Constants

View Source
const (
	CmdSend    = ">"
	CmdReceive = "+"
	CmdCancel  = "-"
)

Valid command names

View Source
const (
	SUCCESS_CONNECTED     = "connected"
	SUCCESS_SEND          = "send"
	SUCCESS_FETCH_START   = "fetch-start"
	SUCCESS_FETCH_END     = "fetch-end"
	SUCCESS_SUBSCRIBED_TO = "subscribed-to"
	SUCCESS_CANCELED      = "canceled"
	ERROR_SUBSCRIBED_TO   = "error-subscribed-to"
	ERROR_BAD_REQUEST     = "error-bad-request"
	ERROR_INTERNAL_SERVER = "error-server-internal"
)

Valid constants for the NotificationMessage.Name

Variables

This section is empty.

Functions

func Decode

func Decode(message []byte) (interface{}, error)

Decode decodes a message, sent from the server to the client. The decoded messages can have one of the types: *Message or *NotificationMessage

func PanicLogger

func PanicLogger()

Types

type Cmd

type Cmd struct {

	// The name of the command
	Name string

	// The argument line, following the commandName
	Arg string

	// The header line, if the command has one
	HeaderJSON string

	// The command payload, if the command has such
	Body []byte
}

Cmd is a representation of a command, which the client sends to the server

func ParseCmd

func ParseCmd(message []byte) (*Cmd, error)

ParseCmd parses a slice of bytes and return a *Cmd

func (*Cmd) Bytes

func (cmd *Cmd) Bytes() []byte

Bytes serializes the the command into a byte slice

type Message

type Message struct {

	// The sequenceId of the message, which is given by the
	// server an is strictly monotonically increasing at least within a root topic.
	ID uint64

	// The topic path
	Path Path

	// The user id of the message sender
	UserID string

	// The id of the sending application
	ApplicationID string

	// Filters applied to this message. The message will be sent only to the
	// routes that match the filters
	Filters map[string]string

	// The time of publishing, as Unix Timestamp date
	Time int64

	// The header line of the message (optional). If set, then it has to be a valid JSON object structure.
	HeaderJSON string

	// The message payload
	Body []byte

	// Used in cluster mode to identify a guble node
	NodeID uint8
}

Message is a struct that represents a message in the guble protocol, as the server sends it to the client.

func ParseMessage

func ParseMessage(message []byte) (*Message, error)

func (*Message) BodyAsString

func (msg *Message) BodyAsString() string

func (*Message) Bytes

func (msg *Message) Bytes() []byte

Bytes serializes the message into a byte slice

func (*Message) Metadata

func (msg *Message) Metadata() string

Metadata returns the first line of a serialized message, without the newline

func (*Message) SetFilter

func (msg *Message) SetFilter(key, value string)

func (*Message) String

func (msg *Message) String() string

type MessageDeliveryCallback

type MessageDeliveryCallback func(*Message)

type NotificationMessage

type NotificationMessage struct {

	// The name of the message
	Name string

	// The argument line, following the messageName
	Arg string

	// The optional json data supplied with the message
	Json string

	// Flag which indicates, if the notification is an error
	IsError bool
}

NotificationMessage is a representation of a status messages or error message, sent from the server

func (*NotificationMessage) Bytes

func (msg *NotificationMessage) Bytes() []byte

Bytes serializes the notification message into a byte slice

type Path

type Path string

Path is the path of a topic

func (Path) Partition

func (path Path) Partition() string

Partition returns the parsed partition from the path.

func (Path) RemovePrefixSlash

func (path Path) RemovePrefixSlash() string

Jump to

Keyboard shortcuts

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