Giter Site home page Giter Site logo

Comments (9)

henry-hz avatar henry-hz commented on April 28, 2024

maybe add a mechanism to generate an event before shutdown, so sagas will be able to reverse any long transaction ?

from commanded.

Papipo avatar Papipo commented on April 28, 2024

It doesn't make sense that aggregates emit events because they haven't been receiving commands lately.

from commanded.

henry-hz avatar henry-hz commented on April 28, 2024

yep, agree. there are two reasons to shutdown, or the business process was finished, or we need more memory, and that aggregate has been sparsely used. for the first, the PM could shutdown them sending stop commands, but for the former, the solution above is fine. an algorithm could calculate the desired "cache" memory, and sets the best timeout based on memory needs

from commanded.

Papipo avatar Papipo commented on April 28, 2024

I guess that this is one of those cases that depends on the use case. Providing configurable timeouts would probably suffice. It's just a matter of finding a good value for your application.

from commanded.

bbhoss avatar bbhoss commented on April 28, 2024

Hibernating after a timeout could also be a good idea, since it will reduce memory to be as small as possible. You could probably have a timeout handler that registers (probably in ETS/Registry) the process somewhere as "in hibernation", with the current time, then have some sort of reaper that decides when to kill/shutdown processes. This is a common issue in actor languages, and why Pony was built to allow garbage collecting the actors themselves, which seems like a pretty rare/one of a kind ability.

from commanded.

slashdotdash avatar slashdotdash commented on April 28, 2024

@bbhoss GenServer already has support for handling timeouts. You can return a timeout (in milliseconds) as part of the reply to handle_cast and handle_call requests. If there are no subsequent requests within the given timeout period, the GenServer will receive a :timeout message and can be stopped.

It just needs to be implemented for the aggregate GenServer.

from commanded.

bbhoss avatar bbhoss commented on April 28, 2024

I understand that, what I'm proposing is in the timeout message handler, we register as hibernated, then return a :hibernate tuple. Then a configurable reaper could evict the processes later.

from commanded.

slashdotdash avatar slashdotdash commented on April 28, 2024

Done in #57.

from commanded.

slashdotdash avatar slashdotdash commented on April 28, 2024

Published to Hex as v0.11.0

from commanded.

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.