Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Merge sync logic to provide fine-grained life-cycle control (…
…#762) To synchronise Block Streams/Executors we compare the latest registry with the rest of the system. Components are started/stopped as needed, but we lack control over life-cycle events such as registration/deletion. As we build towards Coordinator managing provisioning, we need a way to hook in to these life-cycle events, so we can provision/de-provision accordingly. This PR refactors the current synchronisation logic to provide greater control over these life-cycle events. Existing Block Stream/Executor sync logic have been merged to to a single `Synchronisation` struct, which now manages new/existing/deleted indexers as a whole, providing the required life-cycle hooks described above. Merging the sync logic allows us to control _when_ Block Streams/Executors are started/stopped, allowing us to do things before and after, specifically, de-/provisioning. I wanted to do this refactor first to make reviewing easier, I'll follow this up with the provisioning changes next. To achieve the above, each Indexer now has it's own `IndexerState` object in Redis. After synchronising a newly registered Indexer we write its state object, and after removing it, we delete the state object. This means we have the following states, allowing us to handle each accordingly: - Non-existent State/Existing Config - New Indexer - Existing State/Exisiting Config - Existing Indexer - Exisiting State/Non-existent Config - Deleted Indexer The synchronisation logic is essentially the same, expect that now it is driven off the persistent Redis state, rather than the current Block Stream/Executors state.
- Loading branch information