Ah, glad your issue was resolved. I did want to point out one thing:

> 2. The topic was obtained in the subscriber using new topic creation
> `client.CreateTopic(ctx, topic)` rather than getting a topic reference
> `client.Topic(topic)` which I see now is incorrect (thought which is
> poorly explained in the documentation).

Getting the topic via `create.CreateTopic` or `client.Topic` should work
for subscriber creation. Both return `pubsub.Topic` struct[1], which can
be used to call `topic.Publish` and pass to subscription config.
I quickly tested this to confirm, code here[2].

Lastly, with regards to the cmdline examples, I'm guessing this was
removed because we had the official gcloud sdk `gcloud pubsub ...`.
Although the gcloud sdk doesn't use the Go client, I think we didn't
think it would be necessary to support two API surfaces.

We do keep our code samples in our golang-samples[3] repo,
and I'm not sure if it was these samples that you found were
hard to navigate,  but if so, we're very much open to feedback.
I think I can sort of see your point of how the cmdline example
is easier to read (with it being all in one file), but it's part of the
repo's style to keep code samples in separate files. For learning,
I'll work on adding a more comprehensive end-to-end guide
that lives in the package docs instead.

[1] https://pkg.go.dev/cloud.google.com/go/pubsub#Topic
[2] https://play.golang.org/p/Vpe6RxP6Db3
[3] https://github.com/GoogleCloudPlatform/golang-samples/tree/master/pubsub
 

On Monday, April 19, 2021 at 2:35:01 PM UTC-7 kortschak wrote:

> On Mon, 2021-04-19 at 10:37 -0700, 'hong...@google.com' via golang-nuts
> wrote:
> > Is it possible for you to paste your yaml config file? At first
> > glance, nothing seems to be out of the ordinary, but I'd like to try
> > with the same configuration that you have to see if I missed
> > anything.
>
> Thanks, Alex.
>
> I resolved the issue.
>
> There were two parts:
>
> 1. As you surmise there was an typo in the config.
>
> 2. The topic was obtained in the subscriber using new topic creation
> `client.CreateTopic(ctx, topic)` rather than getting a topic reference
> `client.Topic(topic)` which I see now is incorrect (thought which is
> poorly explained in the documentation).
>
> The typo meant that when I did stumble onto the correct solution in the
> code, it still didn't work and the paradoxical behaviour of the python
> creation working for Go but not the other way around left me
> bewildered.
>
> I solved the issue by porting the pubsub cmdline[1] example that exists
> in v0.1.0 to the current release, v1.10.2, and seeing how it is done
> there. Some of the features appear to have been removed, but it is
> largely intact here[2].
>
> By way of comment on the documentation examples, in the Go client code
> they are fragments without context, which makes them pretty poor
> learning material; having something like the cmdline example ties
> things together, so it's odd that it was dropped. I'm happy to donate
> the port back if you feel it's helpful to have.
>
> Dan
>
> [1]https://pkg.go.dev/google.golang.org/cloud/examples/pubsub/cmdline
> [2]https://github.com/kortschak/pubsub
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dd880cc3-b70c-4f4d-b24c-213afb734ccen%40googlegroups.com.

Reply via email to