gcp

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Topic(id string) Topic
	Subscription(id string) *gcppubsub.Subscription
	CreateSubscription(ctx context.Context, id string, cfg gcppubsub.SubscriptionConfig) (*gcppubsub.Subscription, error)
	Close() error
}

type Message

type Message interface {
	Ack()
	Nack()
}

type NotifyFn

type NotifyFn func(ctx context.Context, notification pubsub.Notification)

type Option

type Option func(svc *PubSubSvc)

func WithSubscriptionConcurrencyCount

func WithSubscriptionConcurrencyCount(c int) Option

WithSubscriptionConcurrencyCount Sets the concurrency count to GCPs subscription receiver

func WithSubscriptionLabels

func WithSubscriptionLabels(labels []string) Option

type PubSubSvc

type PubSubSvc struct {
	// contains filtered or unexported fields
}

func NewPubSubSvc

func NewPubSubSvc(logger logrus.FieldLogger, client *gcppubsub.Client, topicName string, options ...Option) *PubSubSvc

func (PubSubSvc) Close

func (svc PubSubSvc) Close() error

func (*PubSubSvc) Listen

func (svc *PubSubSvc) Listen(ctx context.Context, fn NotifyFn) error

Listen uses the client co connect to GCP and attach to a Topic, while attaching a new unique subscriber for receiving notifications. Listen returns immediately

func (*PubSubSvc) Publish

func (svc *PubSubSvc) Publish(ctx context.Context, data pubsub.Data) error

type Subscription

type Subscription interface {
	String() string
	ID() string
	Delete(ctx context.Context) error
	Exists(ctx context.Context) (bool, error)
	Receive(ctx context.Context, f func(context.Context, *gcppubsub.Message)) error
}

type Topic

type Topic interface {
	Exists(ctx context.Context) (bool, error)
	Publish(ctx context.Context, msg *gcppubsub.Message) *gcppubsub.PublishResult
	Stop()
}

Jump to

Keyboard shortcuts

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