Giter Site home page Giter Site logo

Comments (6)

dunglas avatar dunglas commented on August 17, 2024 1

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.

dunglas avatar dunglas commented on August 17, 2024

It looks like your hub isn't responding. Then it's "intended" that the bundle throws.

from mercure-bundle.

Richard87 avatar Richard87 commented on August 17, 2024

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.

dunglas avatar dunglas commented on August 17, 2024

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.

Richard87 avatar Richard87 commented on August 17, 2024

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.

Richard87 avatar Richard87 commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.