Comments (6)
Marking final
classes in public libraries makes the maintenance way easier for us (and limits the number of potential BC breaks when you upgrade). Also, using composition instead of inheritance is considered a best practice these days.
from mercure-bundle.
It looks like your hub isn't responding. Then it's "intended" that the bundle throws.
from mercure-bundle.
I know, but I can't have it like that... So how can I "hack" it so it doesnt throw?
I'm trying to override it, but the "final" tag is complicating things...
from mercure-bundle.
I would suggest to use the messenger integration (in async mode), then it will crash "silently", and the worker will retry later.
Another solution is just to use try/catch
where you call the publisher (you can tweak the timeout etc by passing options to the Symfony HttpClient).
from mercure-bundle.
Okay, thanks to my previous hack I managed to "silence" the error to just log a warning instead... for the next user, I'm hooking into API-Platforms Mercure publish logic:
But I don't really understand why "everything" have to be final these days, it makes it much harder to tweak things, like the Publisher
that just have a single __invoke
function... why final
?
App\Service\Doctrine\PublishMercureCollectionUpdatesListener:
tags: [{name: doctrine.event_subscriber, connection: default, priority: 150}]
decorates: 'api_platform.doctrine.listener.mercure.publish'
arguments:
$formats: "%api_platform.formats%"
$messageBus: null
$publisher: "@mercure.hub.default.publisher"
$logger: "@logger"
from mercure-bundle.
Yup, I understand that as a guideline,
And I agree about composition over inheritance, and API-surface etc.
But If I need to change the way Publisher pushes messages, adding information or similar, I need a place to hook in.
And overriding 'api_platform.doctrine.listener.mercure.publish' just because it's not final is not ideal. Ofcourse, that means I can publish my own Mercure-Bundle to handle the integrations, and it depends on how flexible you want this library to be. I would love to contribute to MercureBundle instead of competing (I'm still working on how to publish updates to collection in a good way my current way is failing with a timeout because of way to much unnecessary traffic!).
I just don't understand why a simple class like Publisher needs to be final, especially since it just need a invoke method that takes a Update object...
anyway, thanks for helping out so fast, I really appreciate it :)
from mercure-bundle.
Related Issues (20)
- Events never dispatched? HOT 2
- MERCURE_PUBLISH_URL ignored ? HOT 7
- autowire mock hub to use in testing environment
- Nginx+Mercure problems HOT 9
- Unauthorized response with default config HOT 4
- add possibility to send updates in multiple formats
- HubInterface and generated JWT token not working fine HOT 1
- Documentation about pub/sub HOT 1
- [Informations] How to handle relations ?
- Publish with hub doesn't work HOT 2
- Unable to use the `mercure()` Twig function to subscribe to two different URLs at different places HOT 1
- Add support for lcobucci/jwt v5 HOT 3
- How pasa additional payloads to mercure() twig function
- Multi domain usage HOT 1
- Symfony: Two topics on one page
- Provide a command to use to test publish / subscribe
- I can access to published messages after user close app sesion, using twig function
- Symfony 7 HOT 2
- Fake hub to functionnal test
- add support for two jwt secret : publisher & subscriber HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mercure-bundle.