gcloud

package
v0.0.0-...-4d6e8e6 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Google Cloud PubSub implemenation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gcloud

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

Gcloud is an implementation of Publisher/Subscriber for Google Cloud Pubsub

func New

func New(ctx context.Context, topic string, client *pubsub.Client, opts ...Option) (*Gcloud, error)

New sets up a Gcloud instance for Publish/Subscribing to a Google Cloud Pubsub topic

func (*Gcloud) Close

func (p *Gcloud) Close()

Closes the underlying topic resources

func (*Gcloud) Publish

func (p *Gcloud) Publish(ctx context.Context, data []byte) error

Publish implements the Publisher interface for publishing a message on a Google Cloud Pubsub topic.

func (*Gcloud) PublishUntilComplete

func (p *Gcloud) PublishUntilComplete(ctx context.Context, data []byte) error

PublishUntilComplete is similar to Publish, but is a blocking call as it uses `.Get()`, it will also return any error that occurs

func (*Gcloud) Subscribe

func (p *Gcloud) Subscribe(ctx context.Context) (<-chan Message, error)

Subscribe implements the Subscriber interface for subscribing to a Google Cloud Pubsub topic.

type Message

type Message struct {
	*pubsub.Message
}

Message implements pubsub.Message for Google Cloud Pubsub

func (*Message) Data

func (m *Message) Data() []byte

Data returns the message data

type Option

type Option func(*Gcloud)

Option configures a Gcloud instance

func WithLogger

func WithLogger(log zerolog.Logger) Option

WithLogger returns an Option to configure the logger

func WithSubName

func WithSubName(subName string) Option

WithSubName returns an Option to configure subscription name

Jump to

Keyboard shortcuts

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