Skip to content

Commit

Permalink
refactor : separate subscription builder to work on each subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagaprasadvr committed Oct 21, 2024
1 parent 10ba722 commit bfe6ed9
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 138 deletions.
16 changes: 8 additions & 8 deletions grpc-ingest/config-grpc2redis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
prometheus: 0.0.0.0:8873
geyser:
endpoint: http://127.0.0.1:10000
x_token: null
endpoint: https://index.rpcpool.com
x_token: 54498915-e5ac-4b37-af09-c13cad7e645d
commitment: finalized
connection_timeout: 10
connection_timeout: "10"
timeout: 10
subscriptions:
token-metadata:
stream:
name: !ACCOUNTS
name: ACCOUNTS
max_len: 100_000_000
max_concurrency: 2
filter:
Expand All @@ -17,7 +17,7 @@ subscriptions:
- metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s
token-extension:
stream:
name: !ACCOUNTS
name: ACCOUNTS
max_len: 100_000_000
max_concurrency: 2
filter:
Expand All @@ -26,7 +26,7 @@ subscriptions:
- TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
token:
stream:
name: !ACCOUNTS
name: ACCOUNTS
max_len: 100_000_000
max_concurrency: 5
filter:
Expand All @@ -35,7 +35,7 @@ subscriptions:
- TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
tcomp:
stream:
name: !ACCOUNTS
name: ACCOUNTS
max_len: 100_000_000
max_concurrency: 2
filter:
Expand All @@ -44,7 +44,7 @@ subscriptions:
- CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d
bubblegum:
stream:
name: !ACCOUNTS_WITH_TRANSACTIONS
name: ACCOUNTS_WITH_TRANSACTIONS
max_len: 100_000_000
max_concurrency: 2
filter:
Expand Down
40 changes: 7 additions & 33 deletions grpc-ingest/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,45 +126,29 @@ pub struct ConfigGeyser {
pub x_token: Option<String>,
#[serde(default = "ConfigGeyser::default_commitment")]
pub commitment: ConfigGrpcRequestCommitment,
#[serde(
default = "ConfigGeyser::default_connection_timeout",
deserialize_with = "deserialize_usize_str"
)]
pub connect_timeout: usize,
#[serde(
default = "ConfigGeyser::default_timeout",
deserialize_with = "deserialize_usize_str"
)]
pub timeout: usize,
#[serde(default = "ConfigGeyser::default_connection_timeout")]
pub connect_timeout: u64,
#[serde(default = "ConfigGeyser::default_timeout")]
pub timeout: u64,
}

impl ConfigGeyser {
pub const fn default_commitment() -> ConfigGrpcRequestCommitment {
ConfigGrpcRequestCommitment::Finalized
}

pub const fn default_connection_timeout() -> usize {
pub const fn default_connection_timeout() -> u64 {
10
}

pub const fn default_timeout() -> usize {
pub const fn default_timeout() -> u64 {
10
}
}

#[derive(Debug, Clone, Deserialize, Default)]
#[serde(rename_all = "UPPERCASE")]
pub enum StreamName {
#[default]
Accounts,
Transactions,
#[serde(rename = "ACCOUNTS_WITH_TRANSACTIONS")]
AccountsWithTransactions,
}

#[derive(Debug, Clone, Deserialize, Default)]
pub struct ConfigStream {
pub name: StreamName,
pub name: String,
#[serde(
default = "ConfigStream::default_stream_maxlen",
deserialize_with = "deserialize_usize_str"
Expand All @@ -187,16 +171,6 @@ impl ConfigStream {
}
}

impl ToString for StreamName {
fn to_string(&self) -> String {
match self {
StreamName::Accounts => "ACCOUNTS".to_string(),
StreamName::Transactions => "TRANSACTIONS".to_string(),
StreamName::AccountsWithTransactions => "ACCOUNTS_WITH_TRANSACTIONS".to_string(),
}
}
}

#[derive(Debug, Clone, Deserialize, Default)]
pub struct ConfigGrpcRequestFilter {
pub accounts: Option<ConfigGrpcRequestAccounts>,
Expand Down
Loading

0 comments on commit bfe6ed9

Please sign in to comment.