Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubSub Subscription doesn't work if provided as variable vs a string literal #1181

Open
preslavmihaylov opened this issue Apr 28, 2024 · 3 comments

Comments

@preslavmihaylov
Copy link

I have a subscription whose identifier I've set as a constant, defined elsewhere.

The encore compiler doesn't allow me to do that because it checks whether the variable identifier matches the spec for the value its supposed to contain.

Example:
image

However, the value within that variable does conform to the spec expected by encore:

const pubSubSubscriptionName = "forum-post-tagger"
@preslavmihaylov
Copy link
Author

I see in the error message that it expects a string literal, but it would be nice if that can be passed as a variable as I like to keep constants like that defined in the same package to easily spot that eg two services have the same subscription name.

@eandre
Copy link
Member

eandre commented May 23, 2024

What's the use case for having "two services have the same subscription name"? A subscription can only be tied to a single service.

@preslavmihaylov
Copy link
Author

preslavmihaylov commented May 23, 2024

That's what I'm trying to avoid, which is why I prefer the constants route (stored in the same file) because that way, if I accidentally define a subscription twice for different services, it would be easier to spot the error.

Having said that, if Encore automatically detects duplicate subscriptions & errors out if so, then that is a viable solution as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants