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

..17-Aug-2021-

apiv1/H17-Aug-2021-5,8354,345

internal/H17-Aug-2021-2,0681,434

loadtest/H17-Aug-2021-1,256954

pstest/H17-Aug-2021-2,6002,103

testdata/H17-Aug-2021-10,06210,050

CHANGES.mdH A D17-Aug-20219.9 KiB202108

README.mdH A D17-Aug-20211.3 KiB4739

debug.goH A D17-Aug-20211.5 KiB7348

doc.goH A D17-Aug-20215.6 KiB1411

example_subscription_iterator_test.goH A D17-Aug-20211.3 KiB5531

example_test.goH A D17-Aug-202112.3 KiB480336

example_topic_iterator_test.goH A D17-Aug-20211.2 KiB5431

flow_controller.goH A D17-Aug-20214.1 KiB13789

flow_controller_test.goH A D17-Aug-20216.4 KiB257196

go.modH A D17-Aug-2021545 1916

go.sumH A D17-Aug-202152.5 KiB537536

go_mod_tidy_hack.goH A D17-Aug-2021917 232

integration_test.goH A D17-Aug-202154.6 KiB1,9821,688

iterator.goH A D17-Aug-202118.4 KiB591422

iterator_test.goH A D17-Aug-202112.7 KiB424320

message.goH A D17-Aug-20213.5 KiB12473

mock_test.goH A D17-Aug-20214.7 KiB203162

nodebug.goH A D17-Aug-2021747 265

pstest_test.goH A D17-Aug-20212.5 KiB9666

pubsub.goH A D17-Aug-20216.1 KiB196133

pubsub_test.goH A D17-Aug-20213.4 KiB12092

pullstream.goH A D17-Aug-20216 KiB200152

pullstream_test.goH A D17-Aug-20213.9 KiB150118

schema.goH A D17-Aug-20217.7 KiB264177

schema_test.goH A D17-Aug-20214.5 KiB176140

service.goH A D17-Aug-20212.8 KiB9461

snapshot.goH A D17-Aug-20215.1 KiB15589

streaming_pull_test.goH A D17-Aug-202113 KiB468393

subscription.goH A D17-Aug-202134.2 KiB981579

subscription_test.goH A D17-Aug-202110.4 KiB403351

timeout_test.goH A D17-Aug-20212.3 KiB9570

topic.goH A D17-Aug-202119.8 KiB606369

topic_test.goH A D17-Aug-20219.2 KiB388315

trace.goH A D17-Aug-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