Repository navigation
[fm-sim] add the basic simulator skeleton: a clock and a bunch of plumbing. - #11720
Open
mergeconflict wants to merge 1 commit into
Open
mergeconflict wants to merge 1 commit into
mergeconflict wants to merge 1 commit into
Conversation
nexus-fm-simulation holds the simulated world (so far a clock) and typed operations on it, with no command-line types. fm-sim holds the clap vocabulary, a parser for one line, and a simulator that runs lines against a single current state; a history of states comes next. The fm-sim binary reads a script or runs interactively and is tested against golden output.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is the first of many, inshallah, implementing a simulated environment for fault management. It doesn't really do much on its own, but it establishes a whole bunch of scaffolding across two crates that the rest of the sim's functionality will eventually fit into.
nexus-fm-simulation: the "core" functionality, which currently includes:struct SimState: the state of the simulated environment, which currently only contains a time field. Instances are immutable snapshots.struct SimStateBuilder: allows basic functional mutation of states.mod time: operations on the simulated clock inSimState.fm-sim: the simulator CLI lib/bin crates, which is mostly the clap command vocabulary and REPL logic. The main things here:struct Simulator: contains a current state, and arunfunction that parses and dispatches clap commands to do stuff with that state.trait Query,trait Mutate,enum Verb<Q: Query, M: Mutate>: a bit of plumbing that lets us bind groups of related clap subcommands to their respective behaviors. I'm pretty happy with this bit of design, I hope you like it.enum TimeQuery,enum TimeMutate: the only implementations ofQueryandMutateso far, which are the clap subcommands fortime showandtime advance.The idea is that users should eventually be able to use the core crate on its own for writing unit tests, and the CLI for both scripted tests and ad hoc manual tests. The advantage of the former style is that the core crate exposes a strongly typed interface: for example,
time::advancereturns aDateTime<Utc>, whereas the commands in the CLI crate just return string output. The advantage of the latter style is that often you just want scripts and golden files.Subsequent PRs will add history / op log (similar to what @sunshowers implemented for reconfigurator-cli), and all the rest of the command vocabulary in RFD 726. There are a handful of
// TODO(#10209)comments throughout, indicating where those additions should land.Context: #10209.