Documentation ¶
Index ¶
- Constants
- type Envelope
- func (msg *Envelope) WithExtra(extra interface{}) *Envelope
- func (msg *Envelope) WithFields(fields string) *Envelope
- func (msg *Envelope) WithHeaders(headers *Headers) *Envelope
- func (msg *Envelope) WithPath(path string) *Envelope
- func (msg *Envelope) WithRevision(revision int64) *Envelope
- func (msg *Envelope) WithStatus(status int) *Envelope
- func (msg *Envelope) WithTimestamp(timestamp string) *Envelope
- func (msg *Envelope) WithTopic(topic *Topic) *Envelope
- func (msg *Envelope) WithValue(value interface{}) *Envelope
- type HeaderOpt
- func WithChannel(channel string) HeaderOpt
- func WithContentType(contentType string) HeaderOpt
- func WithCorrelationID(correlationID string) HeaderOpt
- func WithDryRun(isDryRun bool) HeaderOpt
- func WithETag(eTag string) HeaderOpt
- func WithGeneric(headerID string, value interface{}) HeaderOpt
- func WithIfMatch(ifMatch string) HeaderOpt
- func WithIfNoneMatch(ifNoneMatch string) HeaderOpt
- func WithOrigin(origin string) HeaderOpt
- func WithOriginator(dittoOriginator string) HeaderOpt
- func WithReplyTarget(replyTarget string) HeaderOpt
- func WithReplyTo(replyTo string) HeaderOpt
- func WithResponseRequired(isResponseRequired bool) HeaderOpt
- func WithSchemaVersion(schemaVersion string) HeaderOpt
- func WithTimeout(timeout string) HeaderOpt
- type Headers
- func (h *Headers) Channel() string
- func (h *Headers) ContentType() string
- func (h *Headers) CorrelationID() string
- func (h *Headers) ETag() string
- func (h *Headers) Generic(id string) interface{}
- func (h *Headers) IfMatch() string
- func (h *Headers) IfNoneMatch() string
- func (h *Headers) IsDryRun() bool
- func (h *Headers) IsResponseRequired() bool
- func (h *Headers) MarshalJSON() ([]byte, error)
- func (h *Headers) Origin() string
- func (h *Headers) Originator() string
- func (h *Headers) ReplyTarget() int64
- func (h *Headers) ReplyTo() string
- func (h *Headers) Timeout() string
- func (h *Headers) UnmarshalJSON(data []byte) error
- func (h *Headers) Version() int64
- type Topic
- func (topic *Topic) MarshalJSON() ([]byte, error)
- func (topic *Topic) String() string
- func (topic *Topic) UnmarshalJSON(data []byte) error
- func (topic *Topic) WithAction(action TopicAction) *Topic
- func (topic *Topic) WithChannel(channel TopicChannel) *Topic
- func (topic *Topic) WithCriterion(criterion TopicCriterion) *Topic
- func (topic *Topic) WithEntityName(entityName string) *Topic
- func (topic *Topic) WithGroup(group TopicGroup) *Topic
- func (topic *Topic) WithNamespace(ns string) *Topic
- type TopicAction
- type TopicChannel
- type TopicCriterion
- type TopicGroup
Constants ¶
const ( HeaderCorrelationID = "correlation-id" HeaderResponseRequired = "response-required" HeaderChannel = "ditto-channel" HeaderDryRun = "ditto-dry-run" HeaderOrigin = "origin" HeaderOriginator = "ditto-originator" HeaderETag = "ETag" HeaderIfMatch = "If-Match" HeaderIfNoneMatch = "If-None-Match" HeaderReplyTarget = "ditto-reply-target" HeaderReplyTo = "reply-to" HeaderTimeout = "timeout" HeaderSchemaVersion = "version" HeaderContentType = "content-type" )
Ditto-specific headers constants.
const TopicPlaceholder = "_"
TopicPlaceholder can be used in the context of "any" for things namespaces and IDs in the retrieve topics.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Envelope ¶
type Envelope struct { Topic *Topic `json:"topic"` Headers *Headers `json:"headers,omitempty"` Path string `json:"path"` Value interface{} `json:"value,omitempty"` Fields string `json:"fields,omitempty"` Extra interface{} `json:"extra,omitempty"` Status int `json:"status,omitempty"` Revision int64 `json:"revision,omitempty"` Timestamp string `json:"timestamp,omitempty"` }
Envelope represents the Ditto's Envelope specification. As a Ditto's message consists of an envelope along with a Ditto-compliant payload, the structure is to be used as a ready to use Ditto message.
func (*Envelope) WithExtra ¶
WithExtra sets any extra Envelope configurations as defined by the Ditto protocol specification.
func (*Envelope) WithFields ¶
WithFields sets the fields of the Envelope as defined by the Ditto protocol specification.
func (*Envelope) WithHeaders ¶
WithHeaders sets the Headers of the Envelope.
func (*Envelope) WithRevision ¶
WithRevision sets the current revision number of an entity this Envelope refers to.
func (*Envelope) WithStatus ¶
WithStatus sets the Envelope's status based on the HTTP codes available.
func (*Envelope) WithTimestamp ¶
WithTimestamp sets the timestamp of the Envelope.
type HeaderOpt ¶
HeaderOpt represents a specific Headers option that can be applied to the Headers instance resulting in changing the value of a specific header of a set of headers.
func WithChannel ¶
WithChannel sets the 'ditto-channel' header value.
func WithContentType ¶
WithContentType sets the 'content-type' header value.
func WithCorrelationID ¶
WithCorrelationID sets the 'correlation-id' header value.
func WithDryRun ¶
WithDryRun sets the 'ditto-dry-run' header value.
func WithGeneric ¶
WithGeneric sets the value of the provided key header.
func WithIfMatch ¶
WithIfMatch sets the 'If-Match' header value.
func WithIfNoneMatch ¶
WithIfNoneMatch sets the 'If-None-Match' header value.
func WithOrigin ¶
WithOrigin sets the 'origin' header value.
func WithOriginator ¶
WithOriginator sets the 'ditto-originator' header value.
func WithReplyTarget ¶
WithReplyTarget sets the 'ditto-reply-target' header value.
func WithReplyTo ¶
WithReplyTo sets the 'reply-to' header value.
func WithResponseRequired ¶
WithResponseRequired sets the 'response-required' header value.
func WithSchemaVersion ¶
WithSchemaVersion sets the 'version' header value.
func WithTimeout ¶
WithTimeout sets the 'timeout' header value.
type Headers ¶
type Headers struct {
Values map[string]interface{}
}
Headers represents all Ditto-specific headers along with additional HTTP/etc. headers that can be applied depending on the transport used. See https://www.eclipse.org/ditto/protocol-specification.html
func NewHeaders ¶
NewHeaders returns a new Headers instance.
func NewHeadersFrom ¶
NewHeadersFrom returns a new Headers instance using the provided header.
func (*Headers) Channel ¶
Channel returns the 'ditto-channel' header value or empty string if not set.
func (*Headers) ContentType ¶
ContentType returns the 'content-type' header value or empty string if not set.
func (*Headers) CorrelationID ¶
CorrelationID returns the 'correlation-id' header value or empty string if not set.
func (*Headers) Generic ¶
Generic returns the value of the provided key header and if a header with such key is present.
func (*Headers) IfNoneMatch ¶
IfNoneMatch returns the 'If-None-Match' header value or empty string if not set.
func (*Headers) IsDryRun ¶
IsDryRun returns the 'ditto-dry-run' header value or empty string if not set.
func (*Headers) IsResponseRequired ¶
IsResponseRequired returns the 'response-required' header value or empty string if not set.
func (*Headers) MarshalJSON ¶
MarshalJSON marshels Headers.
func (*Headers) Originator ¶
Originator returns the 'ditto-originator' header value or empty string if not set.
func (*Headers) ReplyTarget ¶
ReplyTarget returns the 'ditto-reply-target' header value or empty string if not set.
func (*Headers) UnmarshalJSON ¶
UnmarshalJSON unmarshels Headers.
type Topic ¶
type Topic struct { Namespace string EntityName string Group TopicGroup Channel TopicChannel Criterion TopicCriterion Action TopicAction }
Topic represents the Ditto protocol's Topic entity. It's represented in the form of: <namespace>/<entity-name>/<group>/<channel>/<criterion>/<action>. Each of the components is configurable based on the Ditto's specification for the specific group and/or channel/criterion/etc.
func (*Topic) MarshalJSON ¶
MarshalJSON marshals Topic.
func (*Topic) UnmarshalJSON ¶
UnmarshalJSON unmarshals Topic.
func (*Topic) WithAction ¶
func (topic *Topic) WithAction(action TopicAction) *Topic
WithAction configures the TopicAction of the Topic.
func (*Topic) WithChannel ¶
func (topic *Topic) WithChannel(channel TopicChannel) *Topic
WithChannel configures the TopicChannel of the Topic.
func (*Topic) WithCriterion ¶
func (topic *Topic) WithCriterion(criterion TopicCriterion) *Topic
WithCriterion configures the TopicCriterion of the Topic.
func (*Topic) WithEntityName ¶
WithEntityName configures the entity name of the Topic.
func (*Topic) WithGroup ¶
func (topic *Topic) WithGroup(group TopicGroup) *Topic
WithGroup configures the TopicGroup of the Topic.
func (*Topic) WithNamespace ¶
WithNamespace configures the namespace of the Topic.
type TopicAction ¶
type TopicAction string
TopicAction is a representation of the defined by Ditto topic action options.
const ( ActionCreate TopicAction = "create" ActionCreated TopicAction = "created" ActionModify TopicAction = "modify" ActionModified TopicAction = "modified" ActionMerge TopicAction = "merge" ActionMerged TopicAction = "merged" ActionDelete TopicAction = "delete" ActionDeleted TopicAction = "deleted" ActionRetrieve TopicAction = "retrieve" ActionSubscribe TopicAction = "subscribe" ActionRequest TopicAction = "request" ActionCancel TopicAction = "cancel" ActionNext TopicAction = "next" ActionComplete TopicAction = "complete" ActionFailed TopicAction = "failed" )
Action constants.
type TopicChannel ¶
type TopicChannel string
TopicChannel is a representation of the defined by Ditto topic channel options.
const ( // ChannelTwin represents the twin channel topic. ChannelTwin TopicChannel = "twin" // ChannelLive represents the live channel topic. ChannelLive TopicChannel = "live" )
type TopicCriterion ¶
type TopicCriterion string
TopicCriterion is a representation of the defined by Ditto topic criterion options.
const ( // CriterionCommands represents the commands topic criterion. CriterionCommands TopicCriterion = "commands" // CriterionEvents represents the events topic criterion. CriterionEvents TopicCriterion = "events" // CriterionSearch represents the search topic criterion. CriterionSearch TopicCriterion = "search" // CriterionMessages represents the messages topic criterion. CriterionMessages TopicCriterion = "messages" // CriterionErrors represents the errors topic criterion. CriterionErrors TopicCriterion = "errors" )
type TopicGroup ¶
type TopicGroup string
TopicGroup is a representation of the defined by Ditto topic group options.
const ( // GroupThings represents the things group in the topic path. GroupThings TopicGroup = "things" // GroupPolicies represents the policies group in the topic path. GroupPolicies TopicGroup = "policies" )