2023-11-27 00:54:59 -08:00
|
|
|
use anyhow::Context;
|
|
|
|
use std::env;
|
|
|
|
use tokio_postgres::config::SslMode;
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Debug, Clone)]
|
|
|
|
pub struct PostgresSessionConfig {
|
|
|
|
pub pg_config: String,
|
|
|
|
pub ssl: Option<PostgresSessionSslConfig>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Debug, Clone)]
|
|
|
|
pub struct PostgresSessionSslConfig {
|
|
|
|
pub ca_pem_b64: String,
|
|
|
|
pub client_pks_b64: String,
|
|
|
|
pub client_pks_pass: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PostgresSessionConfig {
|
|
|
|
pub fn new_from_env() -> anyhow::Result<Option<Self>> {
|
|
|
|
// pg not enabled
|
|
|
|
if env::var("PG_ENABLED").is_err() {
|
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
Production into main (#303)
* fix: panic on geyser close, multiplex bug
https://github.com/blockworks-foundation/geyser-grpc-connector/issues/3
* update Cargo.lock
* reverting cargo.lock
* Fix issues with grpc and postgres
* Solving merge issues
* Fixing cargo fmt
* Increase finish quic timeout (#280) (#281)
* integrate geyser slot subscription (#283)
* Increase finish quic timeout (#280)
* Moving geyser slot subscription from stream to channels (#282)
* Moving geyser slot subscription from stream to channels
* Closing all the slot subscription tasks incase of restart
* Making slot channel unbounded (bug)
* remove block_debug_listen
caused a panic - need more time to investigate
2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] thread 'tokio-runtime-worker' panicked at cluster-endpoints/src/grpc_inspect.rs:59:21:
2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] Error receiving block: Closed
2024-01-17T20:31:42.922 app[683d392fd45368] ams [info] 2024-01-17T20:31:42.912597Z ERROR lite_rpc: Services quit unexpectedly Err(cluster endpoint failure (Err(JoinError::Panic(Id(20), ...)), 1, [JoinHandle { id: Id(19) }, JoinHandle { id: Id(23) }])
* Update cargolock file
* Fixing clippy removing grpc_inspect
* merging main with production (#290)
* remove block_debug_listen (#286)
* remove block_debug_listen
caused a panic - need more time to investigate
2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] thread 'tokio-runtime-worker' panicked at cluster-endpoints/src/grpc_inspect.rs:59:21:
2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] Error receiving block: Closed
2024-01-17T20:31:42.922 app[683d392fd45368] ams [info] 2024-01-17T20:31:42.912597Z ERROR lite_rpc: Services quit unexpectedly Err(cluster endpoint failure (Err(JoinError::Panic(Id(20), ...)), 1, [JoinHandle { id: Id(19) }, JoinHandle { id: Id(23) }])
* clippy
* Fixing message too long and overflow panics (#288)
* Update geyser grpc connector commit (#289)
---------
Co-authored-by: Groovie | Mango <95291500+grooviegermanikus@users.noreply.github.com>
* Merging MTU changes and setting up transportation config (#293)
* remove block_debug_listen (#286)
* remove block_debug_listen
caused a panic - need more time to investigate
2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] thread 'tokio-runtime-worker' panicked at cluster-endpoints/src/grpc_inspect.rs:59:21:
2024-01-17T20:31:42.913 app[683d392fd45368] ams [info] Error receiving block: Closed
2024-01-17T20:31:42.922 app[683d392fd45368] ams [info] 2024-01-17T20:31:42.912597Z ERROR lite_rpc: Services quit unexpectedly Err(cluster endpoint failure (Err(JoinError::Panic(Id(20), ...)), 1, [JoinHandle { id: Id(19) }, JoinHandle { id: Id(23) }])
* clippy
* Fixing message too long and overflow panics (#288)
* Update geyser grpc connector commit (#289)
* Updating the transport config to match with solana endpoint (#292)
* Updating the transport config to match with solana endpoint
* Setting max MTU after groovies comments
---------
Co-authored-by: Groovie | Mango <95291500+grooviegermanikus@users.noreply.github.com>
* Making block subscription processed and moving confirmed block subscr… (#291)
* Making block subscription processed and moving confirmed block subscription to meta
* Sending both processed and confirmed blocks, if block has already been confirmed
* Minor bug, subscribing to processed blocks instead of confirmed (#295)
---------
Co-authored-by: Groovie | Mango <95291500+grooviegermanikus@users.noreply.github.com>
Co-authored-by: GroovieGermanikus <groovie@mango.markets>
2024-01-26 04:56:33 -08:00
|
|
|
let enable_pg = env::var("PG_ENABLED").context("PG_ENABLED")?;
|
|
|
|
if enable_pg != *"true" {
|
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
2023-11-27 00:54:59 -08:00
|
|
|
let env_pg_config = env::var("PG_CONFIG").context("PG_CONFIG not found")?;
|
|
|
|
|
|
|
|
let ssl_config = if env_pg_config
|
|
|
|
.parse::<tokio_postgres::Config>()?
|
|
|
|
.get_ssl_mode()
|
|
|
|
.eq(&SslMode::Disable)
|
|
|
|
{
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
let env_ca_pem_b64 = env::var("CA_PEM_B64").context("CA_PEM_B64 not found")?;
|
|
|
|
let env_client_pks_b64 =
|
|
|
|
env::var("CLIENT_PKS_B64").context("CLIENT_PKS_B64 not found")?;
|
|
|
|
let env_client_pks_pass =
|
|
|
|
env::var("CLIENT_PKS_PASS").context("CLIENT_PKS_PASS not found")?;
|
|
|
|
|
|
|
|
Some(PostgresSessionSslConfig {
|
|
|
|
ca_pem_b64: env_ca_pem_b64,
|
|
|
|
client_pks_b64: env_client_pks_b64,
|
|
|
|
client_pks_pass: env_client_pks_pass,
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(Some(Self {
|
|
|
|
pg_config: env_pg_config,
|
|
|
|
ssl: ssl_config,
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
}
|
2024-01-22 06:22:11 -08:00
|
|
|
|
|
|
|
impl PostgresSessionConfig {
|
|
|
|
pub fn new_for_tests() -> PostgresSessionConfig {
|
|
|
|
assert!(
|
|
|
|
env::var("PG_CONFIG").is_err(),
|
2024-02-05 11:20:15 -08:00
|
|
|
"MUST NOT provide PG_CONFIG environment variables as they are ignored!"
|
2024-01-22 06:22:11 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
// see localdev_integrationtest.sql how to setup the database
|
|
|
|
PostgresSessionConfig {
|
|
|
|
pg_config: r#"
|
|
|
|
host=localhost
|
|
|
|
dbname=literpc_integrationtest_localdev
|
|
|
|
user=literpc_integrationtest
|
|
|
|
password=youknowme
|
|
|
|
sslmode=disable
|
|
|
|
"#
|
|
|
|
.to_string(),
|
|
|
|
ssl: None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|