-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Move Data Layer provisioning from Runner to Coordinator #805
Merged
+461
−422
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a95948b
feat: Create rust client for Data Layer
morgsmccauley 01cac86
refactor: Restructure coordinator handlers fs
morgsmccauley e5719ff
feat: Create data layer handler
morgsmccauley 3c1c88c
feat: Map raw grpc to enum
morgsmccauley 5463c6c
feat: Add `provisionted_state` to Indexer state
morgsmccauley aed6263
feat: Handle provisioning within coordinator
morgsmccauley 9264ef6
refactor: Make data layer service easier to work with
morgsmccauley 8a8048a
refactor: Handle failures starting provisioning
morgsmccauley afdf2c1
fix: Update data layer grpc examples to match proto
morgsmccauley d9a5ceb
test: Fix tests
morgsmccauley bfa2f0e
refactor: Remove implicit provisioning from Runner
morgsmccauley 1b76efd
Merge branch 'main' into feat/handle-provisioning-in-coordinator
morgsmccauley 64ae7a5
test: Remove obscolete snapshots
morgsmccauley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
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,96 @@ | ||
#![cfg_attr(test, allow(dead_code))] | ||
|
||
pub use runner::data_layer::ProvisioningStatus; | ||
|
||
use anyhow::Context; | ||
use runner::data_layer::data_layer_client::DataLayerClient; | ||
use runner::data_layer::{CheckProvisioningTaskStatusRequest, ProvisionRequest}; | ||
use tonic::transport::channel::Channel; | ||
use tonic::{Request, Status}; | ||
|
||
use crate::indexer_config::IndexerConfig; | ||
|
||
#[cfg(not(test))] | ||
pub use DataLayerHandlerImpl as DataLayerHandler; | ||
#[cfg(test)] | ||
pub use MockDataLayerHandlerImpl as DataLayerHandler; | ||
|
||
pub struct DataLayerHandlerImpl { | ||
client: DataLayerClient<Channel>, | ||
} | ||
|
||
#[cfg_attr(test, mockall::automock)] | ||
impl DataLayerHandlerImpl { | ||
pub fn from_env() -> anyhow::Result<Self> { | ||
let runner_url = std::env::var("RUNNER_URL").context("RUNNER_URL is not set")?; | ||
Self::connect(&runner_url) | ||
} | ||
|
||
pub fn connect(runner_url: &str) -> anyhow::Result<Self> { | ||
let channel = Channel::from_shared(runner_url.to_string()) | ||
.context("Runner URL is invalid")? | ||
.connect_lazy(); | ||
let client = DataLayerClient::new(channel); | ||
|
||
Ok(Self { client }) | ||
} | ||
|
||
pub async fn start_provisioning_task( | ||
&self, | ||
indexer_config: &IndexerConfig, | ||
) -> anyhow::Result<ProvisioningStatus> { | ||
let request = ProvisionRequest { | ||
account_id: indexer_config.account_id.to_string(), | ||
function_name: indexer_config.function_name.clone(), | ||
schema: indexer_config.schema.clone(), | ||
}; | ||
|
||
let response = self | ||
.client | ||
.clone() | ||
.start_provisioning_task(Request::new(request)) | ||
.await; | ||
|
||
if let Err(error) = response { | ||
if error.code() == tonic::Code::AlreadyExists { | ||
return Ok(ProvisioningStatus::Pending); | ||
} | ||
|
||
return Err(error.into()); | ||
} | ||
|
||
let status = match response.unwrap().into_inner().status { | ||
1 => ProvisioningStatus::Pending, | ||
2 => ProvisioningStatus::Complete, | ||
3 => ProvisioningStatus::Failed, | ||
_ => ProvisioningStatus::Unspecified, | ||
}; | ||
|
||
Ok(status) | ||
} | ||
|
||
pub async fn check_provisioning_task_status( | ||
&self, | ||
indexer_config: &IndexerConfig, | ||
) -> anyhow::Result<ProvisioningStatus> { | ||
let request = CheckProvisioningTaskStatusRequest { | ||
account_id: indexer_config.account_id.to_string(), | ||
function_name: indexer_config.function_name.clone(), | ||
}; | ||
|
||
let response = self | ||
.client | ||
.clone() | ||
.check_provisioning_task_status(Request::new(request)) | ||
.await?; | ||
|
||
let status = match response.into_inner().status { | ||
1 => ProvisioningStatus::Pending, | ||
2 => ProvisioningStatus::Complete, | ||
3 => ProvisioningStatus::Failed, | ||
_ => ProvisioningStatus::Unspecified, | ||
}; | ||
|
||
Ok(status) | ||
} | ||
} |
File renamed without changes.
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,3 @@ | ||
pub mod block_streams; | ||
pub mod data_layer; | ||
pub mod executors; |
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.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration to add
provisioned_state
enum, defaulting toProvisioned
. There is some risk here if an Indexer hasn't actually been provisioned, but I believe it's unlikely and can handle manually if so.