When the process manager (PM) writes metadata
When a new process is spun up, e.g., the new metadata is written to disk immediately.
When starting a new process, specify whether to persist it or not
E.g. pass in a is_start_on_reboot: bool.
If this flag is true, the metadata about that process will be persisted.
If false, it will not be.
When rebooting the node, all processes with persisted data are started.
Choosing a data store when a process starts
E.g. type may look like
Option<Option<Vec<u8>>>
where
| Value | Interpretation |
|---|---|
None |
No persisted state |
Some(None) |
Persist state: start from scratch |
Some(Some(vec![..])) |
Persist state: start from given bytes |
When starting a process for the first time, the input is either None or Some(None).
When rebooting, processes are started based on the state of the PM persisted in the manifest, and the state persisted by each process is read out from the PM-portion of the manifest and passed in when starting them up.
Processes persist state by sending Request to PM
To persist state, processes send a Message to PM.
That Messages bytes field is to be written to disk.
It would be nice to have the ability to flag to not pass bytes into receiver of Message, but to attach it to the resulting Message so PM doesn't have to read in/write out those bytes.
PM gets bytes written to disk. PM stores handle, so on a boot it will be injected to process. PM deletes old handle (for immutable files).
Child processes
Addition of parent: String, children: Vec<String> fields can form the basis for parent/child processes.
Initially, child processes don't do anything different from parent processes.
They can be implemented higher up in different ways, depending on the app framework that is being built.
E.g., an Erlang-supervisor-type framework might automatically generate SendOnPanics for children that inform the parent of their child's panic.
A Gall-type framework might only allow one level of children ("Gall apps") beneath a single parent ("Gall"), and require that children aggressively persist state.
A spider-type framework might prohibit persisted state for children, since they are "short-lived"/"stateless" "threads".