Git Product home page Git Product logo

Comments (2)

mike-marcacci avatar mike-marcacci commented on July 26, 2024 1

Hi @tomercagan,

It sounds like you have a pretty good read on how this works! The quick answer is that you'll need to store state somewhere else. Here's the longer answer:

You have a task that needs to be completed exactly once. This means that you have to account for failure at any stage of the task – even failures of the entire system (somebody might trip over the power cable). Let's break this down into its two parts:

The task must not complete MORE than once:

  • If a task has been complete, we must not start it again
  • If a task has been started, we must not start it again until we know whether it has completed or failed

The task must not complete LESS than once:

  • If a task is created, it must start
  • If a task fails:
    • In the simplest cases, we can simply restart it
    • If we keep "checkpoints" (divided it into smaller tasks) we can resume from the last complete sub-task
    • If the task has side effects, we may need to revert and re-run, etc

There's a lot of other conditions/scenarios I could add above, but this hopefully illustrates the kinds of use case you have. In this scenario, redlock is only concerned with the problem in bold. While it's a very good solution to that problem, it doesn't provide much for addressing the other problems.

More generically, it's concerned with ensuring exclusivity in a distributed environment. Hopefully that helps – and free to follow up with more questions!

Cheers,
Mike

from node-redlock.

mike-marcacci avatar mike-marcacci commented on July 26, 2024

Hi @tomercagan,

I'm going to close this issue. Please feel free to reopen if you have further questions.

from node-redlock.

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.