Skip to content

Commit

Permalink
refactor: Fetch Database Connection Parameters in Stream Handler (#890)
Browse files Browse the repository at this point in the history
Due to our migration of Provisioning logic to a separate API in Runner,
we can expect that an Indexers resources will be initialized before we
reach the point of executing blocks. So, it is no longer necessary to
lazy init DmlHandler or IndexerMeta due to not having the connection
parameters at the time of class initialization. Worker can poll for
these params before even beginning to execute any blocks. This also
continues to simplify both the code and behavior of the execute
function.
  • Loading branch information
darunrs authored Jul 22, 2024
1 parent 3f1056f commit a39f835
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 320 deletions.
17 changes: 13 additions & 4 deletions runner-client/examples/start_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let response = client
.start_executor(Request::new(StartExecutorRequest {
account_id: "test_account".to_string(),
function_name: "test_indexer".to_string(),
code: "console.log('hi');".to_string(),
account_id: "account_near".to_string(),
function_name: "sample_indexer".to_string(),
code: "
console.log('Hello, world!');
await context.db.IndexerStorage.insert({
\"function_name\": \"sample_indexer\",
\"key_name\": block.blockHeight.toString(),
\"value\": \"Hello, world!\"
});
"
.to_string(),
schema: "CREATE TABLE \"indexer_storage\" (
\"function_name\" TEXT NOT NULL,
\"key_name\" TEXT NOT NULL,
\"value\" TEXT NOT NULL,
PRIMARY KEY (\"function_name\", \"key_name\")
);".to_string(),
);"
.to_string(),
redis_stream: "test:stream".to_string(),
version: 123,
}))
Expand Down
Loading

0 comments on commit a39f835

Please sign in to comment.