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

disable everything related to failure when failure_transport not configured in mesenger #18

Open
nikophil opened this issue Mar 7, 2020 · 9 comments · May be fixed by #29
Open

disable everything related to failure when failure_transport not configured in mesenger #18

nikophil opened this issue Mar 7, 2020 · 9 comments · May be fixed by #29

Comments

@nikophil
Copy link
Collaborator

nikophil commented Mar 7, 2020

(not sure about this one...)

@nikophil
Copy link
Collaborator Author

nikophil commented Mar 20, 2020

WDYT @weaverryan ?
by "disabling" i mean "remove services from container"
but it is a little bit tricky, because we should also disable some routes, thus we have to create a custom routing loader i guess

maybe not worth the pain to do that... 🤔

@weaverryan
Copy link
Contributor

Indeed. If we disable things based on the configuration of a different service, it would need to be done in a compiler pass. But it is a nice thing to do. So:

a) Probably let's not worry about routes. But I guess we could at least write those controllers so that if you try to access them, they give you a good error about needing the failure transport to be configured.

b) Removing the services would be nice, in a compiler pass. And, we may (?) not need to remove many. What I mean is, we would just need to remove any event listeners and any service we use directly in those failure controllers. If there are some additional, lower-level services that these other services depend on, we don't really need to remove those, as the container would remove them automatically because we removed all services using them, if that makes sene :p

@nikophil
Copy link
Collaborator Author

nikophil commented Mar 22, 2020

but the problem is: if i remove from the container the services which are injected in the controllers, i may have an error when building the container, won't I ?

@weaverryan
Copy link
Contributor

Yep, you'll need to make those services optional - so with the on-invalid-null and = null on the arguments to the constructor. But you could then immediately (in the constructor) throw an exception of the injected services are null.

It's not super clean... but it would be nice to clean things up.

@nikophil
Copy link
Collaborator Author

or i create another controller which handles these routes when failure transport is not configured
(and i disable original controllers)

@nikophil
Copy link
Collaborator Author

or i create the custom route loader. I've never done that, but i'm sure that's not that complicated

@weaverryan
Copy link
Contributor

weaverryan commented Mar 23, 2020

I like both of these ideas :). You can try the custom route loader... though... at the end of the day, I kinda prefer the user to be able to see the routes they're importing inside their app versus them being magically loaded somehow (and this will allow them to control the prefix - not sure how that works with custom route loaders)

@nikophil
Copy link
Collaborator Author

ok, i agree, that's better if the user can see easily the routes we're adding; go for this solution!

@nikophil
Copy link
Collaborator Author

btw, you can add a prefix even with a custom route loader
for example: https://github.com/symfony/recipes/blob/master/api-platform/core/2.1/config/routes/api_platform.yaml

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