google

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package google provides methods to work with Google Cloud Pub/Sub enabling the publishing and consumption of messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TopicName           string
	ProjectID           string
	SubscriptionDetails *Subscription
	Topic               *gpubsub.Topic
	TimeoutDuration     int
	ConnRetryDuration   int
	Subscription        *gpubsub.Subscription
}

Config stores the configuration parameters required to connect to Google Cloud Pub/Sub.

type GCPubSub

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

GCPubSub is a client for interacting with Google Cloud Pub/Sub.

func New

func New(config *Config, logger log.Logger) (*GCPubSub, error)

New returns new client

func (*GCPubSub) Bind

func (g *GCPubSub) Bind(message []byte, target interface{}) error

func (*GCPubSub) CommitOffset

func (g *GCPubSub) CommitOffset(pubsub.TopicPartition)

CommitOffset In Google Cloud Pub/Sub, there is no direct equivalent to committing offsets as in Apache Kafka. Pub/Sub is a fully-managed service where the acknowledgment of messages is handled automatically. In Pub/Sub, once a message is received and processed by a subscriber, it is automatically acknowledged by the service. There is no need to explicitly commit offsets or track offsets manually like in Kafka.

func (*GCPubSub) HealthCheck

func (g *GCPubSub) HealthCheck() types.Health

HealthCheck returns the health of the Pub/Sub

func (*GCPubSub) IsSet

func (g *GCPubSub) IsSet() bool

IsSet checks whether google Pub/Sub is initialized or not

func (*GCPubSub) Ping

func (g *GCPubSub) Ping() error

Ping checks for the health of google Pub/Sub, returns an error if it is down

func (*GCPubSub) PublishEvent

func (g *GCPubSub) PublishEvent(key string, value interface{}, headers map[string]string) error

PublishEvent publishes the event to google Pub/Sub

func (*GCPubSub) PublishEventWithOptions

func (g *GCPubSub) PublishEventWithOptions(_ string, value interface{}, headers map[string]string,
	options *pubsub.PublishOptions) (err error)

PublishEventWithOptions publishes message to google Pub/Sub. Ability to provide additional options described in PublishOptions struct

func (*GCPubSub) Subscribe

func (g *GCPubSub) Subscribe() (*pubsub.Message, error)

Subscribe read messages from google Pub/Sub configured

func (*GCPubSub) SubscribeWithCommit

func (g *GCPubSub) SubscribeWithCommit(commitFunc pubsub.CommitFunc) (*pubsub.Message, error)

SubscribeWithCommit calls the CommitFunc after subscribing message from googlePubSub and based on the return values decides whether to commit message and consume another message

type Subscription

type Subscription struct {
	Name string
}

Subscription defines the name of the Pub/Sub subscription.

Jump to

Keyboard shortcuts

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