• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..01-Mar-2021-

apiv1/H01-Mar-2021-5,0653,760

internal/H01-Mar-2021-2,0471,418

loadtest/H01-Mar-2021-1,249948

pstest/H01-Mar-2021-2,2881,864

testdata/H01-Mar-2021-10,00510,002

CHANGES.mdH A D01-Mar-20214.8 KiB11870

README.mdH A D01-Mar-20211.3 KiB4739

debug.goH A D01-Mar-20211.5 KiB7348

doc.goH A D01-Mar-20215.6 KiB1411

example_subscription_iterator_test.goH A D01-Mar-20211.3 KiB5531

example_test.goH A D01-Mar-202112.3 KiB480336

example_topic_iterator_test.goH A D01-Mar-20211.2 KiB5431

flow_controller.goH A D01-Mar-20214.1 KiB13789

flow_controller_test.goH A D01-Mar-20216.4 KiB257196

go.modH A D01-Mar-2021650 2118

go.sumH A D01-Mar-202143.3 KiB441440

go_mod_tidy_hack.goH A D01-Mar-2021917 232

integration_test.goH A D01-Mar-202148.2 KiB1,7281,454

iterator.goH A D01-Mar-202118.3 KiB589420

iterator_test.goH A D01-Mar-202112.1 KiB403305

message.goH A D01-Mar-20213.6 KiB12877

mock_test.goH A D01-Mar-20214.7 KiB203162

nodebug.goH A D01-Mar-2021747 265

pstest_test.goH A D01-Mar-20212.5 KiB9666

pubsub.goH A D01-Mar-20213.7 KiB12378

pullstream.goH A D01-Mar-20215.9 KiB197149

pullstream_test.goH A D01-Mar-20213.7 KiB140108

service.goH A D01-Mar-20212.5 KiB8755

snapshot.goH A D01-Mar-20215.2 KiB16195

streaming_pull_test.goH A D01-Mar-202113 KiB468393

subscription.goH A D01-Mar-202133.6 KiB970579

subscription_test.goH A D01-Mar-202110.4 KiB402350

timeout_test.goH A D01-Mar-20212.3 KiB9570

topic.goH A D01-Mar-202119.3 KiB592360

topic_test.goH A D01-Mar-20217.4 KiB310253

trace.goH A D01-Mar-20219.9 KiB239124

README.md

1## Cloud Pub/Sub [![Go Reference](https://pkg.go.dev/badge/cloud.google.com/go/pubsub.svg)](https://pkg.go.dev/cloud.google.com/go/pubsub)
2
3- [About Cloud Pubsub](https://cloud.google.com/pubsub/)
4- [API documentation](https://cloud.google.com/pubsub/docs)
5- [Go client documentation](https://pkg.go.dev/cloud.google.com/go/pubsub)
6- [Complete sample programs](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/pubsub)
7
8### Example Usage
9
10First create a `pubsub.Client` to use throughout your application:
11
12[snip]:# (pubsub-1)
13```go
14client, err := pubsub.NewClient(ctx, "project-id")
15if err != nil {
16	log.Fatal(err)
17}
18```
19
20Then use the client to publish and subscribe:
21
22[snip]:# (pubsub-2)
23```go
24// Publish "hello world" on topic1.
25topic := client.Topic("topic1")
26res := topic.Publish(ctx, &pubsub.Message{
27	Data: []byte("hello world"),
28})
29// The publish happens asynchronously.
30// Later, you can get the result from res:
31...
32msgID, err := res.Get(ctx)
33if err != nil {
34	log.Fatal(err)
35}
36
37// Use a callback to receive messages via subscription1.
38sub := client.Subscription("subscription1")
39err = sub.Receive(ctx, func(ctx context.Context, m *pubsub.Message) {
40	fmt.Println(m.Data)
41	m.Ack() // Acknowledge that we've consumed the message.
42})
43if err != nil {
44	log.Println(err)
45}
46```
47