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

..03-May-2022-

apiv1/H02-Apr-2021-5,0643,758

internal/H02-Apr-2021-2,0471,418

loadtest/H02-Apr-2021-1,245944

pstest/H02-Apr-2021-2,2761,852

testdata/H02-Apr-2021-10,00510,002

CHANGES.mdH A D02-Apr-20215.1 KiB12573

README.mdH A D02-Apr-20211.3 KiB4739

debug.goH A D02-Apr-20211.5 KiB7348

doc.goH A D02-Apr-20215.6 KiB1411

example_subscription_iterator_test.goH A D02-Apr-20211.3 KiB5531

example_test.goH A D02-Apr-202112.3 KiB480336

example_topic_iterator_test.goH A D02-Apr-20211.2 KiB5431

flow_controller.goH A D02-Apr-20214.1 KiB13789

flow_controller_test.goH A D02-Apr-20216.4 KiB257196

go.modH A D02-Apr-2021545 1916

go.sumH A D02-Apr-202146 KiB469468

go_mod_tidy_hack.goH A D02-Apr-2021917 232

integration_test.goH A D02-Apr-202148.3 KiB1,7291,455

iterator.goH A D02-Apr-202118.4 KiB591422

iterator_test.goH A D02-Apr-202112.7 KiB424320

message.goH A D02-Apr-20213.5 KiB12473

mock_test.goH A D02-Apr-20214.7 KiB203162

nodebug.goH A D02-Apr-2021747 265

pstest_test.goH A D02-Apr-20212.5 KiB9666

pubsub.goH A D02-Apr-20213.7 KiB12378

pullstream.goH A D02-Apr-20216 KiB200152

pullstream_test.goH A D02-Apr-20213.7 KiB140108

service.goH A D02-Apr-20212.5 KiB8755

snapshot.goH A D02-Apr-20215.1 KiB15589

streaming_pull_test.goH A D02-Apr-202113 KiB468393

subscription.goH A D02-Apr-202133 KiB947564

subscription_test.goH A D02-Apr-202110.4 KiB403351

timeout_test.goH A D02-Apr-20212.3 KiB9570

topic.goH A D02-Apr-202119.3 KiB592360

topic_test.goH A D02-Apr-20217.4 KiB310253

trace.goH A D02-Apr-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