dashbitco / broadway_cloud_pub_sub

A Broadway producer for Google Cloud Pub/Sub
Apache License 2.0
70 stars 24 forks source link

Upgrade GOTH to newer version #70

Closed fuatto closed 2 years ago

fuatto commented 2 years ago

I'm using the latest version of broadway_cloud_pub_sub (0.7) which is using goth <= 1.2 (I've tried 1.0, 1.1, 1.2) That don't support GenServer way like in goth 1.3, therefore I did follow the instruction which uses the `Goth.Token.for_scope({account, scope}, sub \ nil), below is what I received:

image

To the trace below I think that there would be something wrong in my service account config, I wanted to log out the further error message inside but I don't know the way (any suggestion on this?) image

If not, an Upgrade of Goth to the >= 1.3 with the usage below would be perfect (just pass in the json key file and that's it)

defmodule MyApp.Application do
  use Application

  def start(_type, _args) do
    credentials = "GOOGLE_APPLICATION_CREDENTIALS_JSON" |> System.fetch_env!() |> Jason.decode!()
    source = {:service_account, credentials, []}

    children = [
      {Goth, name: MyApp.Goth, source: source}
    ]

    Supervisor.start_link(children, strategy: :one_for_one)
  end
end

Thanks in advance

josevalim commented 2 years ago

Hi @fuatto! We specify Goth ~> 1.0, which means it should pick up 1.3 if you do a mix deps.update goth. Have you tried that? Or do you mean that our code is incorrect?

fuatto commented 2 years ago

Wow, thanks for really fast response sir @josevalim !

Yes, I did try the mix deps.update goth it only picks up the goth 1.2, as below:

image

I also try to explicitly set goth ~> 1.3.0-rc.3 as mix suggests:

image

I got:

image

which leads me to a dead-end...

Again, just to be clear about the issue I have:

1/ I have to use the goth <= 1.2 as the latest broadway pub-sub doesn't support goth 1.3... (or maybe there is a way to upgrade goth to 1.3 with the current broadway pub-sub version and I didn't do it correctly yet)

2/ I'm able to use broadway pub-sub just fine with the default service account as the docs instruction that is to use the funcition Goth.Token.for_scope(<scope>) (as in the Custom token generator part in the docs)

3/ My use case is that I want to use the specific service account, which is instructed in goth 1.2 docs by passing in the service account email, and the result is in the prev. comment => for this direction I want to know exactly what the error is to take further actions (maybe I should create an issue in goth, but this is a little bit absurd as in the new 1.3-* versions, they just receive the whole json key file to get which service account is being used - so convenient already) -> any suggestion on this would also be appreciated! 🙏

josevalim commented 2 years ago

You can try as the error message says and specify {:goth, "~> 1.3.0-rc.3", override: true}, and that will force the prerelease version.

fuatto commented 2 years ago

^ It works with the override option, thank you so much for the help!

For others, I'm just not sure why I can't use the old way of goth <= 1.2 which is using the Goth.Token.for_scope({account, scope}, sub \\ nil) for broadway pub-sub ver 0.7 so if the use case is to use pubsub with specific account, just update goth .