Replies: 9 comments
|
What should supervisor do with events and effects? (since they also exist in domains) |
|
@goodmind Events and effects should be untouched, restart affects current state only |
|
What about current function in effect's |
|
seems like meaning of "restart" needs to be defined beforehand |
|
also, with this approach, we can remove obsolete subscriptions on the fly |
|
at first, we need to add .catch method to get semantic of "child is terminated", I mean, we need to have that anyway, isn't it? for example const store = createStore(null)
const computed = store.map(x => x)
computed.catch // event to forward to supervisor or something like that |
|
What should this do? // old domain
const domain = createDomain('simple domain')
// supervised domain
const supervisedDomain = domain.domain('supervisedDomain', {supervisor: false, restart: 'permanent'}) |
|
In this case behavior should remain untouched because |
|
https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/supervisor.ex related links |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It is a very common case when programmer wants to have high-level API to handle failures. It often makes sense to restart a part of application state in case of failures instead of letting user to encounter an error.
Proposal
A great implementation of fault-tolerance applications is already invented in Erlang-Elixir/OTP framework. They introduce a
supervisorentity with several restart strategies. The idea is to return a part of application to its initial state, notify developer about error but let user to continue using the system. Of course these are code issues in most cases but it also covers errors from external sources such as network issues when system will continue performing properly after restart.Elixir code example
Now our stores are being supervised with defined strategy.
List of proposed strategies:
Means to restart a store with its initial state in case of error
Means to restart all supervised nodes with initial states
Keep default behavior to not crash the existing API.
It makes sense to focus attention on supervisor's structure. It is an Erlang process and worker is a process as well.
Hence it can be resolved by wrapping domain
around another domainin case of effector terminology especially because Effector supports nested domains.Also I can redefine restart strategy for particular domain manually to not break a Domain abstraction like this:
Each domain has restart options:
The child is always restarted(default)
the child is never restarted
So that I can improve my supervision tree like this:
This configuration will not restart an app in case of
MyApp.Endpointfailure but will do it whenMyApp.DB1Connectorfails.OTP keeps
syncandasyncactions separately hence there is a direct analogy with Event and Effect.Also supervisors and supervised domains would be a great framework to implement effector dev tools.
Effector API change request
createDomain('supervisedDomain', {supervisor: false, restart: 'permanent'}) createDomain('supervisorDomain', {supervisor: true, strategy: 'one_for_all'})with default value
falsefor supervisor option.All reactions