Skip to content

Commit

Permalink
refactor: Merge sync logic to provide fine-grained life-cycle control (
Browse files Browse the repository at this point in the history
…#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
morgsmccauley authored Jun 12, 2024
1 parent 8ffa697 commit 0f3b9d2
Show file tree
Hide file tree
Showing 12 changed files with 1,496 additions and 1,442 deletions.
5 changes: 0 additions & 5 deletions coordinator/src/block_streams/mod.rs

This file was deleted.

Loading

0 comments on commit 0f3b9d2

Please sign in to comment.