java.lang.Object
me.ahoo.cosid.internal.RuntimeParts
What a runtime is made of, assembled in order (stores, the machine slot, generators) and closed in reverse
(07-runtime-and-spring.md §1, 05-machine-lease.md §4.3). A failed start closes what it created.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimePartsassemble(RuntimeSpec spec, RuntimeOptions options, Function<String, ExecutorService> ownExecutors) Checks the spec, then opens the stores, acquires the slot and creates the generators; on failure closes what was created and rethrows.voidclose()Closes in reverse dependency order (05-machine-lease.md §4.3): every time-based generator, then the other generators, then the slot released with the exact largest timestamp the generators issued, then the stores in reverse order, then the own executor.The generators by name, in name order.lease()The slot lease of the default machine, when it is leased.The slot lease of a started machine, when it is leased.machines()The started machines by name, in start order, with their namespaces.static ExecutorServiceownExecutor(String namespace) The runtime's own executor: a virtual thread per task, named after the namespace.
-
Method Details
-
ownExecutor
The runtime's own executor: a virtual thread per task, named after the namespace.- Parameters:
namespace- the namespace- Returns:
- the executor
-
assemble
public static RuntimeParts assemble(RuntimeSpec spec, RuntimeOptions options, Function<String, ExecutorService> ownExecutors) Checks the spec, then opens the stores, acquires the slot and creates the generators; on failure closes what was created and rethrows.- Parameters:
spec- the specoptions- the optionsownExecutors- creates the runtime's own executor when the options have none- Returns:
- the parts
- Throws:
CosIdException- if the spec is invalid or a step fails
-
namespace
-
generators
The generators by name, in name order.- Returns:
- the generators
-
lease
The slot lease of the default machine, when it is leased.- Returns:
- the lease, empty with a static slot, without a slot, or once closed
-
lease
The slot lease of a started machine, when it is leased.- Parameters:
machine- the machine name, "default" for the default one- Returns:
- the lease, empty with a static slot, for a machine that did not start, or once closed
-
machines
The started machines by name, in start order, with their namespaces.- Returns:
- the namespaces by machine name
-
close
public void close()Closes in reverse dependency order (05-machine-lease.md §4.3): every time-based generator, then the other generators, then the slot released with the exact largest timestamp the generators issued, then the stores in reverse order, then the own executor. Every step runs even if an earlier one fails. Closing again does nothing.- Throws:
CosIdException- if a step failed, with each failure suppressed
-