gcppubsub

package
v0.0.0-...-66f8d29 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gcppubsub provides a Google Cloud Pub/Sub driver for unimq.

To use this driver, import it in your application:

import (
    "github.com/teamlify-devx/unimq"
    _ "github.com/teamlify-devx/unimq/drivers/gcppubsub"
)

Then open a connection:

client, err := unimq.Open(ctx, "gcp_pubsub", &unimq.Config{
    ClientID: "my-project-id",
})

Configuration options via Extra map:

  • "credentials_file": Path to service account credentials JSON file
  • "subscription.ack_deadline": Ack deadline in seconds (default: 10)
  • "subscription.create": Auto-create subscription if not exists (default: true)
  • "publisher.batch_size": Maximum messages per batch
  • "publisher.delay_threshold": Delay threshold in milliseconds

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCPPubSubDriver

type GCPPubSubDriver struct{}

GCPPubSubDriver implements the unimq.Driver interface for Google Cloud Pub/Sub.

func (*GCPPubSubDriver) Name

func (d *GCPPubSubDriver) Name() string

Name returns the driver name.

func (*GCPPubSubDriver) Open

func (d *GCPPubSubDriver) Open(ctx context.Context, config *unimq.Config) (unimq.Queue, error)

Open creates a new GCP Pub/Sub queue instance.

type GCPPubSubQueue

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

GCPPubSubQueue implements the unimq.Queue interface for GCP Pub/Sub.

func (*GCPPubSubQueue) Close

func (q *GCPPubSubQueue) Close() error

Close closes the connection and releases resources.

func (*GCPPubSubQueue) Driver

func (q *GCPPubSubQueue) Driver() string

Driver returns the driver name.

func (*GCPPubSubQueue) Ping

func (q *GCPPubSubQueue) Ping(ctx context.Context) error

Ping checks if the connection is alive.

func (*GCPPubSubQueue) Publish

func (q *GCPPubSubQueue) Publish(ctx context.Context, topicName string, data []byte) error

Publish sends a message to the specified topic.

func (*GCPPubSubQueue) PublishBatch

func (q *GCPPubSubQueue) PublishBatch(ctx context.Context, topicName string, messages [][]byte) error

PublishBatch sends multiple messages to the specified topic.

func (*GCPPubSubQueue) PublishMessage

func (q *GCPPubSubQueue) PublishMessage(ctx context.Context, topicName string, msg *unimq.Message) error

PublishMessage sends a message with headers to the specified topic.

func (*GCPPubSubQueue) Subscribe

func (q *GCPPubSubQueue) Subscribe(ctx context.Context, topicName string, handler unimq.MessageHandler) error

Subscribe starts consuming messages from the specified topic.

func (*GCPPubSubQueue) SubscribeMultiple

func (q *GCPPubSubQueue) SubscribeMultiple(ctx context.Context, topics []string, handler unimq.MessageHandler) error

SubscribeMultiple subscribes to multiple topics simultaneously.