Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyBulkPublishResiliency(ctx context.Context, req *contribPubsub.BulkPublishRequest, ...) (contribPubsub.BulkPublishResponse, error)
- func ExtractCloudEventExtensions(cloudEvent map[string]any) (*structpb.Struct, error)
- func ExtractCloudEventProperty(cloudEvent map[string]any, property string) string
- func FetchEntry(rawPayload bool, entry *contribpubsub.BulkMessageEntry, ...) (*runtimev1pb.TopicEventBulkRequestEntry, error)
- func GRPCEnvelopeFromSubscriptionMessage(ctx context.Context, msg *SubscribedMessage, log logger.Logger, ...) (context.Context, *runtimev1pb.TopicEventRequest, trace.Span, error)
- func IsOperationAllowed(topic string, pubSub *PubsubItem, scopedTopics []string) bool
- func NewBulkSubscribeEnvelope(req *BulkSubscribeEnvelope) map[string]any
- func NewCloudEvent(req *CloudEvent, metadata map[string]string) (map[string]any, error)
- func NewDefaultBulkPublisher(p contribPubsub.PubSub) contribPubsub.BulkPublisher
- func NewDefaultBulkSubscriber(p contribPubsub.PubSub) *defaultBulkSubscriber
- func NewOutbox(opts OptionsOutbox) outbox.Outbox
- func NewPublishResiliencyError(mode TransportMode, code codes.Code, err error) resiliency.CodeError
- func ParentSpanContextFromCloudEvent(cloudEvent map[string]any, log logger.Logger) trace.SpanContext
- type Adapter
- type AdapterStreamer
- type BulkSubscribe
- type BulkSubscribeEnvelope
- type BulkSubscribeJSON
- type BulkSubscribeMessageItem
- type CloudEvent
- type ConnectionID
- type Expr
- type NotAllowedError
- type NotFoundError
- type OptionsOutbox
- type PubsubItem
- type RoutesJSON
- type Rule
- type RuleJSON
- type Streamer
- type SubscribedMessage
- type Subscription
- type SubscriptionJSON
- type TopicKey
- type TransportMode
Constants ¶
const ( Metadata = "metadata" Entries = "entries" )
const ( APIVersionV1alpha1 = "dapr.io/v1alpha1" APIVersionV2alpha1 = "dapr.io/v2alpha1" MetadataKeyPubSub = "pubsubName" )
Variables ¶
var ErrBulkPublishFailure = errors.New("bulk publish failed")
var ErrMessageDropped = errors.New("pubsub message dropped") // TODO: remove this and use apierrors.PubSubMsgDropped
var ErrSubscriptionClosed = errors.New("subscription is closed")
ErrSubscriptionClosed is returned when a message is published to a subscription that is being closed (e.g. during graceful shutdown or hot-reload). Callers should avoid NACKing the message.
Functions ¶
func ApplyBulkPublishResiliency ¶ added in v1.10.0
func ApplyBulkPublishResiliency(ctx context.Context, req *contribPubsub.BulkPublishRequest, policyDef *resiliency.PolicyDefinition, bulkPublisher contribPubsub.BulkPublisher, mode TransportMode, ) (contribPubsub.BulkPublishResponse, error)
func ExtractCloudEventExtensions ¶ added in v1.14.0
func ExtractCloudEventProperty ¶ added in v1.14.0
func FetchEntry ¶ added in v1.14.0
func FetchEntry(rawPayload bool, entry *contribpubsub.BulkMessageEntry, cloudEvent map[string]any) (*runtimev1pb.TopicEventBulkRequestEntry, error)
func GRPCEnvelopeFromSubscriptionMessage ¶ added in v1.14.0
func GRPCEnvelopeFromSubscriptionMessage(ctx context.Context, msg *SubscribedMessage, log logger.Logger, tracingSpec *config.TracingSpec) (context.Context, *runtimev1pb.TopicEventRequest, trace.Span, error)
func IsOperationAllowed ¶ added in v1.14.0
func IsOperationAllowed(topic string, pubSub *PubsubItem, scopedTopics []string) bool
func NewBulkSubscribeEnvelope ¶ added in v1.10.0
func NewBulkSubscribeEnvelope(req *BulkSubscribeEnvelope) map[string]any
func NewCloudEvent ¶ added in v1.0.0
NewCloudEvent encapsulates the creation of a Dapr cloudevent from an existing cloudevent or a raw payload.
func NewDefaultBulkPublisher ¶ added in v1.10.0
func NewDefaultBulkPublisher(p contribPubsub.PubSub) contribPubsub.BulkPublisher
NewDefaultBulkPublisher returns a new defaultBulkPublisher from a PubSub.
func NewDefaultBulkSubscriber ¶ added in v1.10.0
func NewDefaultBulkSubscriber(p contribPubsub.PubSub) *defaultBulkSubscriber
NewDefaultBulkSubscriber returns a new defaultBulkSubscriber from a PubSub.
func NewOutbox ¶ added in v1.12.0
func NewOutbox(opts OptionsOutbox) outbox.Outbox
NewOutbox returns an instance of an Outbox.
func NewPublishResiliencyError ¶ added in v1.17.10
func NewPublishResiliencyError(mode TransportMode, code codes.Code, err error) resiliency.CodeError
NewPublishResiliencyError wraps a pub/sub component (bulk) publish error in a resiliency.CodeError so retry `matching` can evaluate it. For HTTP publishes the gRPC status code is mapped to its HTTP equivalent (matched against `httpStatusCodes`); otherwise the gRPC code is used (matched against `gRPCStatusCodes`).
func ParentSpanContextFromCloudEvent ¶ added in v1.19.0
func ParentSpanContextFromCloudEvent(cloudEvent map[string]any, log logger.Logger) trace.SpanContext
ParentSpanContextFromCloudEvent returns the parent span context carried by an inbound CloudEvent, to be passed to diag.StartInternalCallbackSpan.
It returns the zero trace.SpanContext when the CloudEvent carries no trace context, or carries one that cannot be used. That is not an error: StartInternalCallbackSpan starts a new root span from a zero parent, so a message published outside Dapr - or re-queued from a dead letter queue, which drops the trace context the broker was carrying - is still traced, rather than being delivered with no span at all.
Types ¶
type Adapter ¶ added in v1.0.0
type Adapter interface {
Publish(context.Context, *contribPubsub.PublishRequest, TransportMode) error
BulkPublish(context.Context, *contribPubsub.BulkPublishRequest, TransportMode) (contribPubsub.BulkPublishResponse, error)
}
Adapter is the interface for message buses.
type AdapterStreamer ¶ added in v1.14.0
type AdapterStreamer interface {
// Subscribe registers the stream connection, calls start, sends the
// initial response and then blocks receiving from the stream. Messages
// published once start has begun are delivered after the initial response.
Subscribe(stream rtv1pb.Dapr_SubscribeTopicEventsAlpha1Server, req *rtv1pb.SubscribeTopicEventsRequestInitialAlpha1, connectionID ConnectionID, start func() error) error
Publish(context.Context, *SubscribedMessage) (*rtv1pb.SubscribeTopicEventsRequestProcessedAlpha1, error)
StreamerKey(pubsub, topic string) string
Close(key string, connectionID ConnectionID)
}
type BulkSubscribe ¶ added in v1.10.0
type BulkSubscribeEnvelope ¶ added in v1.10.0
type BulkSubscribeJSON ¶ added in v1.10.0
type BulkSubscribeMessageItem ¶ added in v1.10.0
type CloudEvent ¶ added in v1.0.0
type CloudEvent struct {
ID string `mapstructure:"cloudevent.id"`
Data []byte `mapstructure:"-"` // cannot be overridden
Topic string `mapstructure:"-"` // cannot be overridden
Pubsub string `mapstructure:"-"` // cannot be overridden
DataContentType string `mapstructure:"-"` // cannot be overridden
TraceID string `mapstructure:"cloudevent.traceid"`
TraceState string `mapstructure:"cloudevent.tracestate"`
Baggage string `mapstructure:"cloudevent.baggage"`
Source string `mapstructure:"cloudevent.source"`
Type string `mapstructure:"cloudevent.type"`
TraceParent string `mapstructure:"cloudevent.traceparent"`
Subject string `mapstructure:"cloudevent.subject"`
}
CloudEvent is a request object to create a Dapr compliant cloudevent. The cloud event properties can manually be overwritten by using metadata beginning with "cloudevent." as prefix.
type ConnectionID ¶ added in v1.16.0
type ConnectionID uint64
ConnectionID uniquely identifies a connection
type NotAllowedError ¶ added in v1.0.0
pubsub.NotAllowedError is returned by the runtime when publishing is forbidden.
func (NotAllowedError) Error ¶ added in v1.0.0
func (e NotAllowedError) Error() string
type NotFoundError ¶ added in v1.0.0
type NotFoundError struct {
PubsubName string
}
pubsub.NotFoundError is returned by the runtime when the pubsub does not exist.
func (NotFoundError) Error ¶ added in v1.0.0
func (e NotFoundError) Error() string
type OptionsOutbox ¶ added in v1.14.0
type PubsubItem ¶ added in v1.14.0
type PubsubItem struct {
Component contribPubsub.PubSub
ScopedSubscriptions []string
ScopedPublishings []string
AllowedTopics []string
ProtectedTopics []string
NamespaceScoped bool
}
PubsubItem is a pubsub component with its scoped subscriptions and publishings.
type RoutesJSON ¶ added in v1.4.0
type Rule ¶ added in v1.4.0
func CreateRoutingRule ¶ added in v1.14.0
type Streamer ¶ added in v1.14.0
type Streamer interface {
Subscribe(rtv1pb.Dapr_SubscribeTopicEventsAlpha1Server) error
}
type SubscribedMessage ¶ added in v1.14.0
type Subscription ¶
type Subscription struct {
PubsubName string `json:"pubsubname"`
Topic string `json:"topic"`
DeadLetterTopic string `json:"deadLetterTopic"`
Metadata map[string]string `json:"metadata"`
Rules []*Rule `json:"rules,omitempty"`
Scopes []string `json:"scopes"`
BulkSubscribe *BulkSubscribe `json:"bulkSubscribe"`
}
func GetSubscriptionsGRPC ¶
func GetSubscriptionsGRPC(ctx context.Context, channel runtimev1pb.AppCallbackClient, log logger.Logger, r resiliency.Provider) ([]Subscription, error)
func GetSubscriptionsHTTP ¶
func GetSubscriptionsHTTP(ctx context.Context, channel channel.AppChannel, log logger.Logger, r resiliency.Provider, appID string) ([]Subscription, error)
type SubscriptionJSON ¶ added in v1.4.0
type SubscriptionJSON struct {
PubsubName string `json:"pubsubname"`
Topic string `json:"topic"`
DeadLetterTopic string `json:"deadLetterTopic"`
Metadata map[string]string `json:"metadata,omitempty"`
Route string `json:"route"` // Single route from v1alpha1
Routes RoutesJSON `json:"routes"` // Multiple routes from v2alpha1
BulkSubscribe BulkSubscribeJSON `json:"bulkSubscribe,omitzero"`
}
type TopicKey ¶ added in v1.16.0
type TopicKey string
TopicKey uniquely identifies a pubsub+topic combination
type TransportMode ¶ added in v1.17.10
TransportMode aliases transport.Mode so callers can keep using rtpubsub.TransportMode. The concrete type lives in the leaf transport package to avoid an import cycle with the Adapter fakes/mocks.
const ( // TransportModeGRPC matches broker errors against `gRPCStatusCodes`, using the // component's native gRPC status code. Passed by the gRPC publish API and by // internal republish paths (dead-letter, outbox). TransportModeGRPC TransportMode = iota // TransportModeHTTP matches broker errors against `httpStatusCodes`, mapping the // component's gRPC status code to its HTTP equivalent. Passed by the HTTP // publish API. TransportModeHTTP )