pubsub

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSubscriptionTopicNotResource = errRange.New(
		"Invalid call to pubsub.NewSubscription",
		"pubsub.NewSubscription requires the first argument to be a resource of type pubsub.Topic.",
		errors.PrependDetails(pubsubNewSubscriptionHelp),
	)

	ErrTopicNameNotUnique = errRange.New(
		"Duplicate PubSub topic name",
		"A PubSub topic name must be unique within a service.",

		errors.PrependDetails("If you wish to reuse the same topic, then you can export the original Topic object import it here."),
	)

	ErrSubscriptionNameNotUnique = errRange.New(
		"Duplicate PubSub subscription on topic",
		"Subscription names on topics must be unique.",
	)

	ErrUnableToIdentifyServicesInvolved = errRange.New(
		"Unable to identify services involved",
		"Unable to identify services involved in the PubSub subscription.",
		errors.MarkAsInternalError(),
	)

	ErrSubscriptionHandlerNotDefinedInSameService = errRange.New(
		"Invalid PubSub subscription handler",
		"The handler for the subscription must be defined in the same service as the call to pubsub.NewSubscription.",
		errors.PrependDetails(pubsubNewSubscriptionHelp),
	)

	ErrTopicRefOutsideService = errRange.New(
		"Call to pubsub.TopicRef outside service",
		"pubsub.TopicRef can only be called from within a service.",
	)
)
View Source
var SubscriptionParser = &resourceparser.Parser{
	Name: "PubSub Subscription",

	InterestingImports: []paths.Pkg{"encore.dev/pubsub"},
	Run: func(p *resourceparser.Pass) {
		name := pkginfo.QualifiedName{Name: "NewSubscription", PkgPath: "encore.dev/pubsub"}

		spec := &parseutil.ReferenceSpec{
			MinTypeArgs: 0,
			MaxTypeArgs: 1,
			Parse:       parsePubSubSubscription,
		}

		parseutil.FindPkgNameRefs(p.Pkg, []pkginfo.QualifiedName{name}, func(file *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node) {
			parseutil.ParseReference(p, spec, parseutil.ReferenceData{
				File:         file,
				Stack:        stack,
				ResourceFunc: name,
			})
		})
	},
}
View Source
var TopicParser = &resourceparser.Parser{
	Name: "PubSub Topic",

	InterestingImports: []paths.Pkg{"encore.dev/pubsub"},
	Run: func(p *resourceparser.Pass) {
		name := pkginfo.QualifiedName{Name: "NewTopic", PkgPath: "encore.dev/pubsub"}

		spec := &parseutil.ReferenceSpec{
			MinTypeArgs: 1,
			MaxTypeArgs: 1,
			Parse:       parsePubSubTopic,
		}

		parseutil.FindPkgNameRefs(p.Pkg, []pkginfo.QualifiedName{name}, func(file *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node) {
			parseutil.ParseReference(p, spec, parseutil.ReferenceData{
				File:         file,
				Stack:        stack,
				ResourceFunc: name,
			})
		})
	},
}

Functions

func ResolveTopicUsage

func ResolveTopicUsage(data usage.ResolveData, topic *Topic) usage.Usage

Types

type DeliveryGuarantee

type DeliveryGuarantee int
const (
	AtLeastOnce DeliveryGuarantee = iota
	ExactlyOnce
)

type Perm

type Perm string
const (
	PublishPerm Perm = "publish"
)

type PublishUsage

type PublishUsage struct {
	usage.Base
}

type RefUsage

type RefUsage struct {
	usage.Base
	Perms []Perm
}

func (*RefUsage) HasPerm added in v1.16.0

func (u *RefUsage) HasPerm(perm Perm) bool

type Subscription

type Subscription struct {
	AST     *ast.CallExpr
	File    *pkginfo.File
	Name    string // The unique name of the pub sub subscription
	Doc     string // The documentation on the pub sub subscription
	Topic   pkginfo.QualifiedName
	Cfg     SubscriptionConfig
	Handler ast.Expr // The reference to the handler function
}

func (*Subscription) ASTExpr

func (s *Subscription) ASTExpr() ast.Expr

func (*Subscription) End

func (s *Subscription) End() token.Pos

func (*Subscription) Kind

func (s *Subscription) Kind() resource.Kind

func (*Subscription) Package

func (s *Subscription) Package() *pkginfo.Package

func (*Subscription) Pos

func (s *Subscription) Pos() token.Pos

func (*Subscription) ResourceName

func (s *Subscription) ResourceName() string

type SubscriptionConfig

type SubscriptionConfig struct {
	AckDeadline      time.Duration
	MessageRetention time.Duration
	MinRetryBackoff  time.Duration
	MaxRetryBackoff  time.Duration
	MaxRetries       int
}

type Topic

type Topic struct {
	AST               *ast.CallExpr
	File              *pkginfo.File
	Name              string              // The unique name of the pub sub topic
	Doc               string              // The documentation on the pub sub topic
	DeliveryGuarantee DeliveryGuarantee   // What guarantees does the pub sub topic have?
	OrderingKey       string              // What field in the message type should be used to ensure First-In-First-Out (FIFO) for messages with the same key
	MessageType       *schema.TypeDeclRef // The message type of the pub sub topic
}

func (*Topic) ASTExpr

func (t *Topic) ASTExpr() ast.Expr

func (*Topic) End

func (t *Topic) End() token.Pos

func (*Topic) Kind

func (t *Topic) Kind() resource.Kind

func (*Topic) Package

func (t *Topic) Package() *pkginfo.Package

func (*Topic) Pos

func (t *Topic) Pos() token.Pos

func (*Topic) ResourceName

func (t *Topic) ResourceName() string

Jump to

Keyboard shortcuts

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