Create a generic state machine class to standardize our state machines

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Replication
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Several of our classes can be modeled as state machines, where each states has a set of states it is allowed to transition to.

      These state machines are often implemented as enum classes, where the set of legal state transitions is, at times, undocumented and unenforced.

      Having a generic CRTP state machine class would allow us to:

      • have a standard way of defining state machines, making our classes easier to understand
      • document and enforce the validity of certain state transitions
      • customize the handling of illegal state transitions
      • discover existing bugs related to illegal state transitions, and customize our handling of them
      • make our classes' state machine part of the class' type itself, rather than a private: implementation detail
      • reason about other classes based on the states they present

      Some examples of existing state machines:

      OplogSyncState

      PrimaryOnlyService::State

      ReplicationCoordinatorImpl::ConfigState

      Transaction::TransactionState

      AbstractAsyncComponent::State

      SyncSourceResolver::State

      BackgroundSync::ProducerState

            Assignee:
            Joseph Obaraye
            Reporter:
            Joseph Obaraye
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: