()
| 115 | } |
| 116 | |
| 117 | func ExampleMessage_As() { |
| 118 | // This example is specific to the gcppubsub implementation; it demonstrates |
| 119 | // access to the underlying PubsubMessage type. |
| 120 | // The types exposed for As by gcppubsub are documented in |
| 121 | // https://godoc.org/gocloud.dev/pubsub/gcppubsub#hdr-As |
| 122 | |
| 123 | ctx := context.Background() |
| 124 | sub, err := pubsub.OpenSubscription(ctx, "gcppubsub://project/topic") |
| 125 | if err != nil { |
| 126 | log.Fatal(err) |
| 127 | } |
| 128 | defer sub.Shutdown(ctx) |
| 129 | |
| 130 | msg, err := sub.Receive(ctx) |
| 131 | if err != nil { |
| 132 | log.Fatal(err) |
| 133 | } |
| 134 | var pm *pbapi.PubsubMessage |
| 135 | if msg.As(&pm) { |
| 136 | _ = pm.GetAttributes() |
| 137 | } |
| 138 | msg.Ack() |
| 139 | } |
| 140 | |
| 141 | func ExampleSubscription_As() { |
| 142 | // This example is specific to the gcppubsub implementation; it demonstrates |
nothing calls this directly
no test coverage detected