Skip to content

Commit

Permalink
fix: Wrap CoinGeckoClient in Mutex (#25)
Browse files Browse the repository at this point in the history
* fix: Wrap CoinGeckoClient in Mutex

* feat: Rate Limiter Governor for socket calls

* fix: points per bucket
  • Loading branch information
ankurdubey521 authored Jul 12, 2024
1 parent 00bddcc commit 0b0eab2
Show file tree
Hide file tree
Showing 12 changed files with 2,065 additions and 50 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
ETHEREUM_RPC_URL: ${{ secrets.ETHEREUM_RPC_URL }}
ARBITRUM_RPC_URL: ${{ secrets.ARBITRUM_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
BAE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
MONGO_URL: ${{ secrets.MONGO_URL }}
REDIS_URL: ${{ secrets.REDIS_URL }}
environment: Testing

container_img_build_push_gar:
needs: [test]
needs: [ test ]
# Allow the job to fetch a GitHub ID token
permissions:
id-token: write
Expand All @@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
image:
- us-docker.pkg.dev/biconomy-prod/biconomy-prod/reflux
- us-docker.pkg.dev/biconomy-prod/biconomy-prod/reflux
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
# {owner}/{repo}/.github/workflows/{filename}@{ref}
uses: bcnmy/devops/.github/workflows/container_img_build_push_gar.yaml@master
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ target/

*.env
*.swp
# *.yaml
*.log
85 changes: 85 additions & 0 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions bin/reflux/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use axum::http::Method;
use clap::Parser;
use dotenv::dotenv;
use log::{debug, error, info};
use tokio::sync::Mutex;
use tower_http::cors::{Any, CorsLayer};

use account_aggregation::service::AccountAggregationService;
Expand Down Expand Up @@ -119,16 +120,16 @@ async fn run_solver(config: Arc<Config>) {
let erc20_instance_map = generate_erc20_instance_map(&config).unwrap();
let bungee_client = BungeeClient::new(&config.bungee.base_url, &config.bungee.api_key)
.expect("Failed to Instantiate Bungee Client");
let token_price_provider = CoingeckoClient::new(
let token_price_provider = Arc::new(Mutex::new(CoingeckoClient::new(
config.coingecko.base_url.clone(),
config.coingecko.api_key.clone(),
redis_client.clone(),
Duration::from_secs(config.coingecko.expiry_sec),
);
)));
let settlement_engine = Arc::new(SettlementEngine::new(
Arc::clone(&config),
bungee_client,
token_price_provider,
Arc::clone(&token_price_provider),
erc20_instance_map,
));

Expand Down Expand Up @@ -205,12 +206,12 @@ async fn run_indexer(config: Arc<Config>) {
let bungee_client = BungeeClient::new(&config.bungee.base_url, &config.bungee.api_key)
.expect("Failed to Instantiate Bungee Client");

let token_price_provider = CoingeckoClient::new(
let token_price_provider = Arc::new(Mutex::new(CoingeckoClient::new(
config.coingecko.base_url.clone(),
config.coingecko.api_key.clone(),
redis_provider.clone(),
Duration::from_secs(config.coingecko.expiry_sec),
);
)));

let indexer: Indexer<BungeeClient, RedisClient, RedisClient, CoingeckoClient<RedisClient>> =
Indexer::new(
Expand Down
Loading

0 comments on commit 0b0eab2

Please sign in to comment.