Documentation ¶
Index ¶
- Variables
- type DeliveryPolicy
- type Message
- func (*Message) Descriptor() ([]byte, []int)deprecated
- func (x *Message) GetChannel() string
- func (x *Message) GetCreated() int64
- func (x *Message) GetPayload() []byte
- func (x *Message) GetProtocol() string
- func (x *Message) GetPublisher() string
- func (x *Message) GetSubtopic() string
- func (*Message) ProtoMessage()
- func (x *Message) ProtoReflect() protoreflect.Message
- func (x *Message) Reset()
- func (x *Message) String() string
- type MessageHandler
- type Option
- type PubSub
- type Publisher
- type Subscriber
- type SubscriberConfig
Constants ¶
This section is empty.
Variables ¶
var File_pkg_messaging_message_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type DeliveryPolicy ¶
type DeliveryPolicy uint8
const ( // DeliverNewPolicy will only deliver new messages that are sent after the consumer is created. // This is the default policy. DeliverNewPolicy DeliveryPolicy = iota // DeliverAllPolicy starts delivering messages from the very beginning of a stream. DeliverAllPolicy )
type Message ¶
type Message struct { Channel string `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` Subtopic string `protobuf:"bytes,2,opt,name=subtopic,proto3" json:"subtopic,omitempty"` Publisher string `protobuf:"bytes,3,opt,name=publisher,proto3" json:"publisher,omitempty"` Protocol string `protobuf:"bytes,4,opt,name=protocol,proto3" json:"protocol,omitempty"` Payload []byte `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` Created int64 `protobuf:"varint,6,opt,name=created,proto3" json:"created,omitempty"` // Unix timestamp in nanoseconds // contains filtered or unexported fields }
Message represents a message emitted by the Magistrala adapters layer.
func (*Message) Descriptor
deprecated
func (*Message) GetChannel ¶
func (*Message) GetCreated ¶
func (*Message) GetPayload ¶
func (*Message) GetProtocol ¶
func (*Message) GetPublisher ¶
func (*Message) GetSubtopic ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) ProtoReflect ¶
func (x *Message) ProtoReflect() protoreflect.Message
type MessageHandler ¶
type MessageHandler interface { // Handle handles messages passed by underlying implementation. Handle(msg *Message) error // Cancel is used for cleanup during unsubscribing and it's optional. Cancel() error }
MessageHandler represents Message handler for Subscriber.
type Option ¶
type Option func(vals interface{}) error
Option represents optional configuration for message broker.
This is used to provide optional configuration parameters to the underlying publisher and pubsub implementation so that it can be configured to meet the specific needs.
For example, it can be used to set the message prefix so that brokers can be used for event sourcing as well as internal message broker. Using value of type interface is not recommended but is the most suitable for this use case as options should be compiled with respect to the underlying broker which can either be RabbitMQ or NATS.
The example below shows how to set the prefix and jetstream stream for NATS.
Example:
broker.NewPublisher(ctx, url, broker.Prefix(eventsPrefix), broker.JSStream(js))
type PubSub ¶
type PubSub interface { Publisher Subscriber }
PubSub represents aggregation interface for publisher and subscriber.
type Publisher ¶
type Publisher interface { // Publishes message to the stream. Publish(ctx context.Context, topic string, msg *Message) error // Close gracefully closes message publisher's connection. Close() error }
Publisher specifies message publishing API.
type Subscriber ¶
type Subscriber interface { // Subscribe subscribes to the message stream and consumes messages. Subscribe(ctx context.Context, cfg SubscriberConfig) error // Unsubscribe unsubscribes from the message stream and // stops consuming messages. Unsubscribe(ctx context.Context, id, topic string) error // Close gracefully closes message subscriber's connection. Close() error }
Subscriber specifies message subscription API.
type SubscriberConfig ¶
type SubscriberConfig struct { ID string Topic string Handler MessageHandler DeliveryPolicy DeliveryPolicy }
Directories ¶
Path | Synopsis |
---|---|
Package mqtt hold the implementation of the Publisher and PubSub interfaces for the MQTT messaging system, the internal messaging broker of the Magistrala IoT platform.
|
Package mqtt hold the implementation of the Publisher and PubSub interfaces for the MQTT messaging system, the internal messaging broker of the Magistrala IoT platform. |
Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Magistrala IoT platform.
|
Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Magistrala IoT platform. |
tracing
Package tracing provides tracing instrumentation for Magistrala things policies service.
|
Package tracing provides tracing instrumentation for Magistrala things policies service. |
Package rabbitmq holds the implementation of the Publisher and PubSub interfaces for the RabbitMQ messaging system, the internal messaging broker of the Magistrala IoT platform.
|
Package rabbitmq holds the implementation of the Publisher and PubSub interfaces for the RabbitMQ messaging system, the internal messaging broker of the Magistrala IoT platform. |
tracing
Package tracing provides tracing instrumentation for Magistrala things policies service.
|
Package tracing provides tracing instrumentation for Magistrala things policies service. |
Package tracing provides tracing instrumentation for Magistrala things policies service.
|
Package tracing provides tracing instrumentation for Magistrala things policies service. |