Skip to content

Commit

Permalink
feat(core): insert into indexer table
Browse files Browse the repository at this point in the history
  • Loading branch information
remiroyc committed Sep 7, 2023
1 parent d60e5d2 commit 521ab13
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
39 changes: 30 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
chrono = "0.4.19"
anyhow = "1.0"
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.11", features = ["json"] }
Expand Down
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use crate::core::block::process_blocks_continuously;
use anyhow::Result;
use ark_starknet::{client2::StarknetClient, collection_manager::CollectionManager};
use aws_config::meta::region::RegionProviderChain;
use aws_sdk_dynamodb::Client as DynamoClient;
use aws_sdk_dynamodb::{types::AttributeValue, Client as DynamoClient};
use aws_sdk_kinesis::Client as KinesisClient;
use chrono::Utc;
use dotenv::dotenv;
use reqwest::{Client as ReqwestClient, Url};
use simple_logger::SimpleLogger;
Expand All @@ -33,6 +34,21 @@ async fn main() -> Result<()> {
let dynamo_client = DynamoClient::new(&config);
let reqwest_client = ReqwestClient::new();

let indexer_table_name =
env::var("ARK_INDEXER_TABLE_NAME").expect("ARK_INDEXER_TABLE_NAME must be set");

let indexer_version = env::var("ARK_INDEXER_VERSION").unwrap_or(String::from("undefined"));
let now = Utc::now();
let unix_timestamp = now.timestamp();

dynamo_client
.put_item()
.table_name(indexer_table_name)
.item("PK", AttributeValue::S(String::from("ECS_")))
.item("SK", AttributeValue::S(unix_timestamp.to_string()))
.item("status", AttributeValue::S(String::from("running")))
.item("version", AttributeValue::S(String::from(indexer_version)));

Check warning on line 50 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `std::string::String`

warning: useless conversion to the same type: `std::string::String` --> src/main.rs:50:44 | 50 | .item("version", AttributeValue::S(String::from(indexer_version))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `indexer_version` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default

process_blocks_continuously(
&collection_manager,
&rpc_client,
Expand Down

0 comments on commit 521ab13

Please sign in to comment.