Coder Social home page Coder Social logo

Comments (12)

FZambia avatar FZambia commented on May 18, 2024 1

Yep, badger or bolt with raft leader election is an interesting thing to extend current possibilities.

The hardest part of making engine exported at this time is the fact that publish into PUB/SUB should be atomic with saving message to history cache. So publish operation in a whole can be atomic. This works with Redis (to certain degree though, I suppose atomicity of Redis LUA scripts could be not guaranteed when PUB/SUB operations involved), also in Memory engine. But if we split engine on PUB/SUB part and storage part we lose this atomicity. In this case message can be published to current subscribers but not saved in cache, or saved in cache but not published to subscribers. Currently I don't know what should we do in case of these errors at publish time.

Redis has no sync replication so there is a chance to lose messages even with AOF with fsync on every query when master goes down and last messages not achieved slave yet. Having nature of Redis in mind current Redis engine implementation can only be best effort mechanism to provide message persistence for later recovery process. It will work in practice for most real-world apps but there are no strong guarantees as far as I understand.

from centrifuge.

FZambia avatar FZambia commented on May 18, 2024 1

Guys, just want to update status on this. I remember about this issue but the task is not straightforward. I have some ideas but they ruin under various edge cases. At moment I am in progress of validating new idea - maybe it will fit fine but can't be sure.

At least I proved that I can make current engines separate if neseccary. Also played a bit with custom Nats engine which implements only PUB/SUB logic without any persistence layer.

from centrifuge.

FZambia avatar FZambia commented on May 18, 2024

Hello, my plan is making internal engine parts pluggable in the end. Though I am not sure about correct implementation and currently concentrated on finishing work on Centrifugo v2 built on top of this lib.

I don't fully understand your intents - this library should only persist a short-term cache of messages. What is your use case for persistent store? Are you going to keep unlimited amount of messages in it? Also Redis Pub/Sub is not currently used for persistence - it is used for Centrifuge node scalability.

from centrifuge.

stemcc avatar stemcc commented on May 18, 2024

Great, I'm glad to hear that's on the roadmap.

My use case for persistence is to have a cache that can survive reboots, while ideally using something a little simpler than Redis but that can still provide simple kv lookups (like Bolt for example). Otherwise I would just load a log file into memory when the app comes back online. I'm using Centrifuge to pass messages and data from a local daemon/server to a local gui client, local daemon to remote client, or remote daemon/server to local daemon/server.

from centrifuge.

 avatar commented on May 18, 2024

Badger or bolt with raft leader election should be enough to get HA.

I think redis is HA in that you can specify how often it syncs to disk ?

from centrifuge.

 avatar commented on May 18, 2024

from centrifuge.

FZambia avatar FZambia commented on May 18, 2024

@gedw99 thanks for suggestions. Centrifuge lib in its current state is very close to event sourcing system. At least this is already kind of. Its hard to say at moment in what direction we should expand it - maybe the understanding will come with usage reports if any:)

from centrifuge.

 avatar commented on May 18, 2024

I guess it's also because your relying on redis to do the hard stuff which is totally understandable.

You could use emitter golang project instead of redis. Then you can wrap it. It uses mqtt as the messaging layer and supports scaling honizontally

from centrifuge.

thienpow avatar thienpow commented on May 18, 2024

maybe can use mongodb instead of redis

from centrifuge.

FZambia avatar FZambia commented on May 18, 2024

@stemcc please take a look at referenced pull request where I am trying to split Engine on three parts - Broker, HistoryManager and PresenceManager. This is a road to pluggable components, hope this will allow to do more with this library. At least look at interesting concept example where Nats used for PUB/SUB and Redis for other stuff.

from centrifuge.

FZambia avatar FZambia commented on May 18, 2024

Let's reopen until it will be documented

from centrifuge.

FZambia avatar FZambia commented on May 18, 2024

Just posted a note about pluggable components on Medium, also we have an example of setting custom broker implementation. I suppose this is enough for a moment. If there are any questions about current implementation - feel free to ask.

from centrifuge.

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.