pubsub

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Metadata = "metadata"
	Entries  = "entries"
)
View Source
const (
	APIVersionV1alpha1 = "dapr.io/v1alpha1"
	APIVersionV2alpha1 = "dapr.io/v2alpha1"

	MetadataKeyPubSub = "pubsubName"
)

Variables

View Source
var ErrBulkPublishFailure = errors.New("bulk publish failed")
View Source
var ErrMessageDropped = errors.New("pubsub message dropped") // TODO: remove this and use apierrors.PubSubMsgDropped

Functions

func ApplyBulkPublishResiliency added in v1.10.0

func ExtractCloudEventExtensions added in v1.14.0

func ExtractCloudEventExtensions(cloudEvent map[string]any) (*structpb.Struct, error)

func ExtractCloudEventProperty added in v1.14.0

func ExtractCloudEventProperty(cloudEvent map[string]any, property string) string

func FetchEntry added in v1.14.0

func FetchEntry(rawPayload bool, entry *contribpubsub.BulkMessageEntry, cloudEvent map[string]interface{}) (*runtimev1pb.TopicEventBulkRequestEntry, error)

func GRPCEnvelopeFromSubscriptionMessage added in v1.14.0

func GRPCEnvelopeFromSubscriptionMessage(ctx context.Context, msg *SubscribedMessage, log logger.Logger, tracingSpec *config.TracingSpec) (*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]interface{}

func NewCloudEvent added in v1.0.0

func NewCloudEvent(req *CloudEvent, metadata map[string]string) (map[string]interface{}, error)

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.

Types

type Adapter added in v1.0.0

Adapter is the interface for message buses.

type AdapterStreamer added in v1.14.0

type AdapterStreamer interface {
	Subscribe(rtv1pb.Dapr_SubscribeTopicEventsAlpha1Server, *rtv1pb.SubscribeTopicEventsRequestInitialAlpha1) error
	Publish(context.Context, *SubscribedMessage) error
	StreamerKey(pubsub, topic string) string
}

type BulkSubscribe added in v1.10.0

type BulkSubscribe struct {
	Enabled            bool  `json:"enabled"`
	MaxMessagesCount   int32 `json:"maxMessagesCount,omitempty"`
	MaxAwaitDurationMs int32 `json:"maxAwaitDurationMs,omitempty"`
}

type BulkSubscribeEnvelope added in v1.10.0

type BulkSubscribeEnvelope struct {
	ID        string
	Entries   []BulkSubscribeMessageItem
	Metadata  map[string]string
	Topic     string
	Pubsub    string
	EventType string
}

type BulkSubscribeJSON added in v1.10.0

type BulkSubscribeJSON struct {
	Enabled            bool  `json:"enabled"`
	MaxMessagesCount   int32 `json:"maxMessagesCount,omitempty"`
	MaxAwaitDurationMs int32 `json:"maxAwaitDurationMs,omitempty"`
}

type BulkSubscribeMessageItem added in v1.10.0

type BulkSubscribeMessageItem struct {
	EntryId     string            `json:"entryId"` //nolint:stylecheck
	Event       interface{}       `json:"event"`
	Metadata    map[string]string `json:"metadata"`
	ContentType string            `json:"contentType,omitempty"`
}

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"`
	Source          string `mapstructure:"cloudevent.source"`
	Type            string `mapstructure:"cloudevent.type"`
	TraceParent     string `mapstructure:"cloudevent.traceparent"`
}

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 Expr added in v1.4.0

type Expr interface {
	fmt.Stringer

	Eval(variables map[string]interface{}) (interface{}, error)
}

type NotAllowedError added in v1.0.0

type NotAllowedError struct {
	Topic string
	ID    string
}

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 OptionsOutbox struct {
	Publisher             Adapter
	GetPubsubFn           func(string) (contribPubsub.PubSub, bool)
	GetStateFn            func(string) (state.Store, bool)
	CloudEventExtractorFn func(map[string]any, string) string
	Namespace             string
}

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 RoutesJSON struct {
	Rules   []*RuleJSON `json:"rules,omitempty"`
	Default string      `json:"default,omitempty"`
}

type Rule added in v1.4.0

type Rule struct {
	Match Expr   `json:"match"`
	Path  string `json:"path"`
}

func CreateRoutingRule added in v1.14.0

func CreateRoutingRule(match, path string) (*Rule, error)

type RuleJSON added in v1.4.0

type RuleJSON struct {
	Match string `json:"match"`
	Path  string `json:"path"`
}

type Streamer added in v1.14.0

type Streamer interface {
	Subscribe(rtv1pb.Dapr_SubscribeTopicEventsAlpha1Server) error
}

type SubscribedMessage added in v1.14.0

type SubscribedMessage struct {
	CloudEvent map[string]interface{}
	Data       []byte
	Topic      string
	Metadata   map[string]string
	Path       string
	PubSub     string
}

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 GetSubscriptionsHTTP

func GetSubscriptionsHTTP(ctx context.Context, channel channel.AppChannel, log logger.Logger, r resiliency.Provider) ([]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,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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