Documentation
¶
Overview ¶
Package pubsub provides a Google PubSub abstraction.
Example ¶
package main
import (
"context"
"github.com/bsm/bps"
_ "github.com/bsm/bps/pubsub"
)
func main() {
ctx := context.TODO()
pub, err := bps.NewPublisher(ctx, "pubsub://my-project-id/")
if err != nil {
panic(err.Error())
}
defer pub.Close()
if err := pub.Topic("topic").Publish(ctx, &bps.PubMessage{Data: []byte("message")}); err != nil {
panic(err.Error())
}
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PubTopic ¶
type PubTopic struct {
// contains filtered or unexported fields
}
PubTopic wraps a pubsub topic.
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher wraps a google pubsub client and implements the bps.Publisher interface.
func NewPublisher ¶
func NewPublisher(ctx context.Context, projectID string, settings *native.PublishSettings, opts ...option.ClientOption) (*Publisher, error)
NewPublisher inits a publisher.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber is a Google PubSub wrapper that implements bps.Subscriber interface.
func NewSubscriber ¶
func NewSubscriber(ctx context.Context, projectID string) (*Subscriber, error)
NewSubscriber inits a subscriber. It starts handling from the newest available message (published after subscribing). Google PubSub may re-deliver successfully handled messages.
Click to show internal directories.
Click to hide internal directories.