tile38/vendor/cloud.google.com/go/pubsub
tidwall 6a55c8de8f fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
..
apiv1 fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
internal/distribution fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
CHANGES.md fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
LICENSE fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
README.md fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
debug.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
doc.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
flow_controller.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
go.mod fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
go.sum fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
go_mod_tidy_hack.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
iterator.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
message.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
nodebug.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
pubsub.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
pullstream.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
service.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
snapshot.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
subscription.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
topic.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00
trace.go fix: distance if point and object have the same coordinates 2021-07-08 06:45:31 -07:00

README.md

Cloud Pub/Sub GoDoc

Example Usage

First create a pubsub.Client to use throughout your application:

client, err := pubsub.NewClient(ctx, "project-id")
if err != nil {
	log.Fatal(err)
}

Then use the client to publish and subscribe:

// Publish "hello world" on topic1.
topic := client.Topic("topic1")
res := topic.Publish(ctx, &pubsub.Message{
	Data: []byte("hello world"),
})
// The publish happens asynchronously.
// Later, you can get the result from res:
...
msgID, err := res.Get(ctx)
if err != nil {
	log.Fatal(err)
}

// Use a callback to receive messages via subscription1.
sub := client.Subscription("subscription1")
err = sub.Receive(ctx, func(ctx context.Context, m *pubsub.Message) {
	fmt.Println(m.Data)
	m.Ack() // Acknowledge that we've consumed the message.
})
if err != nil {
	log.Println(err)
}