Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TopicRegistrar ¶
type TopicRegistrar map[string]*TopicRegistration
TopicRegistrar is a map of <pubsubname>-<topic> to `TopicRegistration` and acts as a lookup as the application is building up subscriptions with potentially multiple routes per topic.
func (TopicRegistrar) AddSubscription ¶
func (m TopicRegistrar) AddSubscription(sub *common.Subscription, fn common.TopicEventHandler) error
type TopicRegistration ¶
type TopicRegistration struct { Subscription *TopicSubscription DefaultHandler common.TopicEventHandler RouteHandlers map[string]common.TopicEventHandler }
TopicRegistration encapsulates the subscription and handlers.
type TopicRoutes ¶
type TopicRoutes struct { Rules []TopicRule `json:"rules,omitempty"` Default string `json:"default,omitempty"` // contains filtered or unexported fields }
TopicRoutes encapsulates the default route and multiple routing rules.
type TopicRule ¶
type TopicRule struct { // Match is the CEL expression to match on the CloudEvent envelope. Match string `json:"match"` // Path is the HTTP path to post the event to (passed as Path in gRPC). Path string `json:"path"` // contains filtered or unexported fields }
TopicRule represents a single routing rule.
type TopicSubscription ¶
type TopicSubscription struct { // PubsubName is name of the pub/sub this message came from. PubsubName string `json:"pubsubname"` // Topic is the name of the topic. Topic string `json:"topic"` // Route is the route of the handler where HTTP topic events should be published (passed as Path in gRPC). Route string `json:"route,omitempty"` // Routes specify multiple routes where topic events should be sent. Routes *TopicRoutes `json:"routes,omitempty"` // Metadata is the subscription metadata. Metadata map[string]string `json:"metadata,omitempty"` }
TopicSubscription internally represents single topic subscription.
func NewTopicSubscription ¶
func NewTopicSubscription(pubsubName, topic string) *TopicSubscription
NewTopicSubscription creates a new `TopicSubscription`.
func (*TopicSubscription) AddRoutingRule ¶
func (s *TopicSubscription) AddRoutingRule(path, match string, priority int) error
AddRoutingRule adds a routing rule. An error is returned if a there id a duplicate priority > 1.
func (*TopicSubscription) SetDefaultRoute ¶
func (s *TopicSubscription) SetDefaultRoute(path string) error
SetDefaultRoute sets the default route if not already set. An error is returned if it is already set.
func (*TopicSubscription) SetMetadata ¶
func (s *TopicSubscription) SetMetadata(metadata map[string]string) error
SetMetadata sets the metadata for the subscription if not already set. An error is returned if it is already set.