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 ¶
- type GCPPubSubDriver
- type GCPPubSubQueue
- func (q *GCPPubSubQueue) Close() error
- func (q *GCPPubSubQueue) Driver() string
- func (q *GCPPubSubQueue) Ping(ctx context.Context) error
- func (q *GCPPubSubQueue) Publish(ctx context.Context, topicName string, data []byte) error
- func (q *GCPPubSubQueue) PublishBatch(ctx context.Context, topicName string, messages [][]byte) error
- func (q *GCPPubSubQueue) PublishMessage(ctx context.Context, topicName string, msg *unimq.Message) error
- func (q *GCPPubSubQueue) Subscribe(ctx context.Context, topicName string, handler unimq.MessageHandler) error
- func (q *GCPPubSubQueue) SubscribeMultiple(ctx context.Context, topics []string, handler unimq.MessageHandler) error
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.
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) 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.