rele icon indicating copy to clipboard operation
rele copied to clipboard

Use rele without creating a subscription

Open alysivji opened this issue 2 years ago • 4 comments

Looking through the documentation and the code, this library creates a new subscription on the PubSub topic specified in the sub decorator.

I'm looking to separate code that creates infrastructure from code that processes subscriber messages. Ideally, my subscribers would be created in Terraform along with the retry / dead letter topic config for each subscriber. I'm also hesitant to provide my subscribers with additional permissions beyond reading and acknowledging messages for a given set of subscriptions

Is it possible to use rele without creating a subscription? If not, is this a feature you would accept a PR for?

alysivji avatar Jul 04 '22 20:07 alysivji

In theory this should work without issue according to this https://github.com/mercadona/rele/blob/master/rele/client.py#L62

Have you tried it already?

andrewgy8 avatar Jul 05 '22 09:07 andrewgy8

Ah right, having thought about this for aa few minutes, this makes perfect sense.

The reason we create a subscription is due to when the worker spin ups the first time and the subscription is not there, we create one.

On any subsequent start of the worker, the subscription registered in GCP will be there. Meaning that we dont create a subscription hence the suppression linked above.

So to further answer your question, you creating a subscription with Terraform should be no issue. Just make sure your subscription/topic names match up and you should be good.

andrewgy8 avatar Jul 05 '22 09:07 andrewgy8

Thanks for the prompt reply! I'm going to be working on this next sprint and will check back in once I try out your suggestion

alysivji avatar Jul 06 '22 01:07 alysivji

@daniel-ruiz this issue can be closed 😉

andrewgy8 avatar Aug 03 '22 10:08 andrewgy8