Documentation ¶
Index ¶
- Constants
- func ApplyMetadata(cloudEvent map[string]interface{}, componentFeatures []Feature, ...)
- func FromCloudEvent(cloudEvent []byte, topic, pubsub, traceID string) (map[string]interface{}, error)
- func HasExpired(cloudEvent map[string]interface{}) bool
- func NewCloudEventsEnvelope(id, source, eventType, subject string, topic string, pubsubName string, ...) map[string]interface{}
- func RetryNotifyRecover(operation backoff.Operation, b backoff.BackOff, notify backoff.Notify, ...) error
- type AppResponse
- type AppResponseStatus
- type ConcurrencyMode
- type Feature
- type Metadata
- type NewMessage
- type PubSub
- type PublishRequest
- type SubscribeRequest
Constants ¶
const ( // DefaultCloudEventType is the default event type for an Dapr published event DefaultCloudEventType = "com.dapr.event.sent" // CloudEventsSpecVersion is the specversion used by Dapr for the cloud events implementation CloudEventsSpecVersion = "1.0" // DefaultCloudEventSource is the default event source DefaultCloudEventSource = "Dapr" // DefaultCloudEventDataContentType is the default content-type for the data attribute DefaultCloudEventDataContentType = "text/plain" TraceIDField = "traceid" TopicField = "topic" PubsubField = "pubsubname" ExpirationField = "expiration" DataContentTypeField = "datacontenttype" DataField = "data" DataBase64Field = "data_base64" SpecVersionField = "specversion" TypeField = "type" SourceField = "source" IDField = "id" SubjectField = "subject" )
Variables ¶
This section is empty.
Functions ¶
func ApplyMetadata ¶ added in v1.0.0
func ApplyMetadata(cloudEvent map[string]interface{}, componentFeatures []Feature, metadata map[string]string)
ApplyMetadata will process metadata to modify the cloud event based on the component's feature set.
func FromCloudEvent ¶ added in v1.0.0
func FromCloudEvent(cloudEvent []byte, topic, pubsub, traceID string) (map[string]interface{}, error)
FromCloudEvent returns a map representation of an existing cloudevents JSON
func HasExpired ¶ added in v1.0.0
HasExpired determines if the current cloud event has expired.
func NewCloudEventsEnvelope ¶
func NewCloudEventsEnvelope(id, source, eventType, subject string, topic string, pubsubName string, dataContentType string, data []byte, traceID string) map[string]interface{}
NewCloudEventsEnvelope returns a map representation of a cloudevents JSON
func RetryNotifyRecover ¶ added in v1.1.1
func RetryNotifyRecover(operation backoff.Operation, b backoff.BackOff, notify backoff.Notify, recovered func()) error
RetryNotifyRecover is a wrapper around backoff.RetryNotify that adds another callback for when an operation previously failed but has since recovered. The main purpose of this wrapper is to call `notify` only when the operations fails the first time and `recovered` when it finally succeeds. This can be helpful in limiting log messages to only the events that operators need to be alerted on.
Types ¶
type AppResponse ¶ added in v0.4.0
type AppResponse struct {
Status AppResponseStatus `json:"status"`
}
AppResponse is the object describing the response from user code after a pubsub event
type AppResponseStatus ¶ added in v0.4.0
type AppResponseStatus string
AppResponseStatus represents a status of a PubSub response.
const ( // Success means the message is received and processed correctly. Success AppResponseStatus = "SUCCESS" // Retry means the message is received but could not be processed and must be retried. Retry AppResponseStatus = "RETRY" // Drop means the message is received but should not be processed. Drop AppResponseStatus = "DROP" )
type ConcurrencyMode ¶ added in v1.0.0
type ConcurrencyMode string
ConcurrencyMode is a pub/sub metadata setting that allows to specify whether messages are delivered in a serial or parallel execution
const ( // ConcurrencyKey is the metadata key name for ConcurrencyMode ConcurrencyKey = "concurrencyMode" Single ConcurrencyMode = "single" Parallel ConcurrencyMode = "parallel" )
func Concurrency ¶ added in v1.0.0
func Concurrency(metadata map[string]string) (ConcurrencyMode, error)
Concurrency takes a metadata object and returns the ConcurrencyMode configured. Default is Parallel
type Feature ¶ added in v1.0.0
type Feature string
Feature names a feature that can be implemented by PubSub components.
const ( // FeatureMessageTTL is the feature to handle message TTL. FeatureMessageTTL Feature = "MESSAGE_TTL" )
type NewMessage ¶
type NewMessage struct { Data []byte `json:"data"` Topic string `json:"topic"` Metadata map[string]string `json:"metadata"` }
NewMessage is an event arriving from a message bus instance
type PubSub ¶
type PubSub interface { Init(metadata Metadata) error Features() []Feature Publish(req *PublishRequest) error Subscribe(req SubscribeRequest, handler func(msg *NewMessage) error) error Close() error }
PubSub is the interface for message buses
type PublishRequest ¶
type PublishRequest struct { Data []byte `json:"data"` PubsubName string `json:"pubsubname"` Topic string `json:"topic"` Metadata map[string]string `json:"metadata"` }
PublishRequest is the request to publish a message
type SubscribeRequest ¶
type SubscribeRequest struct { Topic string `json:"topic"` Metadata map[string]string `json:"metadata"` }
SubscribeRequest is the request to subscribe to a topic