Skip to content

Commit

Permalink
fix: add instantiating indexer status, and display error if instantia…
Browse files Browse the repository at this point in the history
…tion fails (#1460)

add instantiating indexer status, and display error if instantiation fails
  • Loading branch information
lostman authored Nov 9, 2023
1 parent fd14dab commit fc5ca2f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/fuel-indexer-database/database-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ impl RegisteredIndexer {
Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumString, strum::Display,
)]
pub enum IndexerStatusKind {
#[strum(serialize = "instantiating")]
Instantiating,
#[strum(serialize = "starting")]
Starting,
#[strum(serialize = "running")]
Expand All @@ -590,6 +592,13 @@ pub struct IndexerStatus {
}

impl IndexerStatus {
pub fn instantiating() -> Self {
IndexerStatus {
status_kind: IndexerStatusKind::Instantiating,
status_message: "".to_string(),
}
}

pub fn starting() -> Self {
IndexerStatus {
status_kind: IndexerStatusKind::Starting,
Expand Down
27 changes: 25 additions & 2 deletions packages/fuel-indexer/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,35 @@ impl WasmIndexExecutor {
) -> IndexerResult<Self> {
let uid = manifest.uid();

match WasmIndexExecutor::new(config, manifest, wasm_bytes, pool, schema_version)
.await
let mut conn = pool.acquire().await?;
queries::set_indexer_status(
&mut conn,
manifest.namespace(),
manifest.identifier(),
IndexerStatus::instantiating(),
)
.await?;

match WasmIndexExecutor::new(
config,
manifest,
wasm_bytes,
pool.clone(),
schema_version,
)
.await
{
Ok(executor) => Ok(executor),
Err(e) => {
error!("Could not instantiate WasmIndexExecutor({uid}): {e:?}.");
let mut conn = pool.acquire().await?;
queries::set_indexer_status(
&mut conn,
manifest.namespace(),
manifest.identifier(),
IndexerStatus::error(format!("{e}")),
)
.await?;
Err(IndexerError::WasmExecutionInstantiationError)
}
}
Expand Down

0 comments on commit fc5ca2f

Please sign in to comment.