-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose RPC from Coordinator to enable/disable Indexers (#729)
This PR exposes a new gRPC endpoint from Coordinator to "manage" indexers. Currently, this only allows for enabling/disabling, but will probably be expanded over time. There isn't any intention to use this from another service, it's more of a manual & internal tool that we can use. The endpoint is essentially just a wrapper over the persistent Redis state. The exposed methods end up mutating this state, which in turn, is then used to govern how Indexers should be synchronised. Within the `coordinator/` directory, the endpoint can be used with `grpcurl` like so: - enable: `grpcurl -plaintext -proto proto/indexer_manager.proto -d '{"account_id": "morgs.near", "function_name": "test"}' 0.0.0.0:8002 indexer.IndexerManager.Enable` - disable: `grpcurl -plaintext -proto proto/indexer_manager.proto -d '{"account_id": "morgs.near", "function_name": "test"}' 0.0.0.0:8002 indexer.IndexerManager.Disable` - list: `grpcurl -plaintext -proto proto/indexer_manager.proto 0.0.0.0:8002 indexer.IndexerManager.List`
- Loading branch information
1 parent
702fe46
commit 94fe3b3
Showing
12 changed files
with
630 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
tonic_build::compile_protos("proto/indexer_manager.proto")?; | ||
|
||
Ok(()) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
syntax = "proto3"; | ||
|
||
package indexer; | ||
|
||
// The IndexerManager service provides RPCs to manage Indexer instances | ||
service IndexerManager { | ||
// Re-enable an existing Indexer | ||
rpc Enable (IndexerRequest) returns (EnableIndexerResponse); | ||
|
||
// Disable an Indexer, preventing it from running | ||
rpc Disable (IndexerRequest) returns (DisableIndexerResponse); | ||
|
||
// List all Indexer with their state | ||
rpc List (Empty) returns (ListIndexersResponse); | ||
} | ||
|
||
// Request message for managing Indexers | ||
message IndexerRequest { | ||
// Account ID which the indexer is defined under | ||
string account_id = 1; | ||
// Name of the indexer | ||
string function_name = 2; | ||
} | ||
|
||
// Response message for enabling Indexer | ||
message EnableIndexerResponse { | ||
bool success = 1; | ||
} | ||
|
||
// Response message for disabling Indexer | ||
message DisableIndexerResponse { | ||
bool success = 1; | ||
} | ||
|
||
// Reponse message for listing Indexers | ||
message ListIndexersResponse { | ||
repeated IndexerState indexers = 1; | ||
} | ||
|
||
// Persisted state relevant to Indexer | ||
message IndexerState { | ||
string account_id = 1; | ||
string function_name = 2; | ||
bool enabled = 3; | ||
} | ||
|
||
message Empty {} |
This file contains 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
Oops, something went wrong.