kafka: fix message size for gRPC client (#195)
This commit is contained in:
parent
a090e97a9b
commit
b9e734fe1d
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -12,8 +12,20 @@ The minor version will be incremented upon a breaking change and the patch versi
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- client: add `GeyserGrpcClient::subscribe_once2` ([#195](https://github.com/rpcpool/yellowstone-grpc/pull/195)).
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
|
## 2023-10-06
|
||||||
|
|
||||||
|
- yellowstone-grpc-kafka-1.0.0-rc.2+solana.1.16.15
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- kafka: fix message size for gRPC client ([#195](https://github.com/rpcpool/yellowstone-grpc/pull/195)).
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
|
|
||||||
## 2023-10-05
|
## 2023-10-05
|
||||||
|
|
|
@ -4639,7 +4639,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yellowstone-grpc-kafka"
|
name = "yellowstone-grpc-kafka"
|
||||||
version = "1.0.0-rc.1+solana.1.16.15"
|
version = "1.0.0-rc.2+solana.1.16.15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@ -4663,6 +4663,7 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"vergen",
|
"vergen",
|
||||||
|
"yellowstone-grpc-client",
|
||||||
"yellowstone-grpc-proto",
|
"yellowstone-grpc-proto",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ members = [
|
||||||
"examples/rust", # 1.10.0+solana.1.16.15
|
"examples/rust", # 1.10.0+solana.1.16.15
|
||||||
"yellowstone-grpc-client", # 1.11.0+solana.1.16.15
|
"yellowstone-grpc-client", # 1.11.0+solana.1.16.15
|
||||||
"yellowstone-grpc-geyser", # 1.9.0+solana.1.16.15
|
"yellowstone-grpc-geyser", # 1.9.0+solana.1.16.15
|
||||||
"yellowstone-grpc-kafka", # 1.0.0-rc.1+solana.1.16.15
|
"yellowstone-grpc-kafka", # 1.0.0-rc.2+solana.1.16.15
|
||||||
"yellowstone-grpc-proto", # 1.10.0+solana.1.16.15
|
"yellowstone-grpc-proto", # 1.10.0+solana.1.16.15
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ docker-compose -f ./yellowstone-grpc-kafka/docker-kafka.yml up
|
||||||
kafka_2.13-3.5.0/bin/kafka-topics.sh --bootstrap-server localhost:29092 --create --topic grpc1
|
kafka_2.13-3.5.0/bin/kafka-topics.sh --bootstrap-server localhost:29092 --create --topic grpc1
|
||||||
# send messages from gRPC to Kafka
|
# send messages from gRPC to Kafka
|
||||||
cargo run --bin grpc-kafka -- --config yellowstone-grpc-kafka/config.json --prometheus 127.0.0.1:8873 grpc2kafka
|
cargo run --bin grpc-kafka -- --config yellowstone-grpc-kafka/config.json --prometheus 127.0.0.1:8873 grpc2kafka
|
||||||
|
# read messages from Kafka
|
||||||
|
kafka_2.13-3.5.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:29092 --topic grpc1
|
||||||
```
|
```
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
|
@ -190,20 +190,27 @@ impl<F: Interceptor> GeyserGrpcClient<F> {
|
||||||
blocks_meta: HashMap<String, SubscribeRequestFilterBlocksMeta>,
|
blocks_meta: HashMap<String, SubscribeRequestFilterBlocksMeta>,
|
||||||
commitment: Option<CommitmentLevel>,
|
commitment: Option<CommitmentLevel>,
|
||||||
accounts_data_slice: Vec<SubscribeRequestAccountsDataSlice>,
|
accounts_data_slice: Vec<SubscribeRequestAccountsDataSlice>,
|
||||||
|
) -> GeyserGrpcClientResult<impl Stream<Item = Result<SubscribeUpdate, Status>>> {
|
||||||
|
self.subscribe_once2(SubscribeRequest {
|
||||||
|
slots,
|
||||||
|
accounts,
|
||||||
|
transactions,
|
||||||
|
entry,
|
||||||
|
blocks,
|
||||||
|
blocks_meta,
|
||||||
|
commitment: commitment.map(|value| value as i32),
|
||||||
|
accounts_data_slice,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub async fn subscribe_once2(
|
||||||
|
&mut self,
|
||||||
|
request: SubscribeRequest,
|
||||||
) -> GeyserGrpcClientResult<impl Stream<Item = Result<SubscribeUpdate, Status>>> {
|
) -> GeyserGrpcClientResult<impl Stream<Item = Result<SubscribeUpdate, Status>>> {
|
||||||
let (mut subscribe_tx, response) = self.subscribe().await?;
|
let (mut subscribe_tx, response) = self.subscribe().await?;
|
||||||
subscribe_tx
|
subscribe_tx.send(request).await?;
|
||||||
.send(SubscribeRequest {
|
|
||||||
slots,
|
|
||||||
accounts,
|
|
||||||
transactions,
|
|
||||||
entry,
|
|
||||||
blocks,
|
|
||||||
blocks_meta,
|
|
||||||
commitment: commitment.map(|value| value as i32),
|
|
||||||
accounts_data_slice,
|
|
||||||
})
|
|
||||||
.await?;
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "yellowstone-grpc-kafka"
|
name = "yellowstone-grpc-kafka"
|
||||||
version = "1.0.0-rc.1+solana.1.16.15"
|
version = "1.0.0-rc.2+solana.1.16.15"
|
||||||
authors = ["Triton One"]
|
authors = ["Triton One"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Yellowstone gRPC Kafka Producer/Dedup/Consumer"
|
description = "Yellowstone gRPC Kafka Producer/Dedup/Consumer"
|
||||||
|
@ -26,6 +26,7 @@ tonic = { version = "0.10.2", features = ["gzip", "tls", "tls-roots"] }
|
||||||
tonic-health = "0.10.2"
|
tonic-health = "0.10.2"
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||||
|
yellowstone-grpc-client = { path = "../yellowstone-grpc-client" }
|
||||||
yellowstone-grpc-proto = { path = "../yellowstone-grpc-proto" }
|
yellowstone-grpc-proto = { path = "../yellowstone-grpc-proto" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
},
|
},
|
||||||
"grpc2kafka": {
|
"grpc2kafka": {
|
||||||
"endpoint": "http://127.0.0.1:10000",
|
"endpoint": "http://127.0.0.1:10000",
|
||||||
"x_token": "",
|
"x_token": null,
|
||||||
"request": {
|
"request": {
|
||||||
"slots": ["client"],
|
"slots": ["client"],
|
||||||
"blocks": {
|
"blocks": {
|
||||||
|
|
|
@ -2,9 +2,7 @@ use {
|
||||||
anyhow::Context,
|
anyhow::Context,
|
||||||
clap::{Parser, Subcommand},
|
clap::{Parser, Subcommand},
|
||||||
futures::{
|
futures::{
|
||||||
channel::mpsc,
|
|
||||||
future::{BoxFuture, FutureExt},
|
future::{BoxFuture, FutureExt},
|
||||||
sink::SinkExt,
|
|
||||||
stream::StreamExt,
|
stream::StreamExt,
|
||||||
},
|
},
|
||||||
rdkafka::{
|
rdkafka::{
|
||||||
|
@ -14,23 +12,18 @@ use {
|
||||||
producer::{FutureProducer, FutureRecord},
|
producer::{FutureProducer, FutureRecord},
|
||||||
},
|
},
|
||||||
sha2::{Digest, Sha256},
|
sha2::{Digest, Sha256},
|
||||||
std::{net::SocketAddr, sync::Arc},
|
std::{net::SocketAddr, sync::Arc, time::Duration},
|
||||||
tokio::{
|
tokio::{
|
||||||
signal::unix::{signal, SignalKind},
|
signal::unix::{signal, SignalKind},
|
||||||
task::JoinSet,
|
task::JoinSet,
|
||||||
},
|
},
|
||||||
tonic::{
|
|
||||||
codec::Streaming,
|
|
||||||
metadata::AsciiMetadataValue,
|
|
||||||
transport::{Channel, ClientTlsConfig},
|
|
||||||
Request, Response,
|
|
||||||
},
|
|
||||||
tracing::{debug, trace, warn},
|
tracing::{debug, trace, warn},
|
||||||
tracing_subscriber::{
|
tracing_subscriber::{
|
||||||
filter::{EnvFilter, LevelFilter},
|
filter::{EnvFilter, LevelFilter},
|
||||||
layer::SubscriberExt,
|
layer::SubscriberExt,
|
||||||
util::SubscriberInitExt,
|
util::SubscriberInitExt,
|
||||||
},
|
},
|
||||||
|
yellowstone_grpc_client::GeyserGrpcClient,
|
||||||
yellowstone_grpc_kafka::{
|
yellowstone_grpc_kafka::{
|
||||||
config::{Config, ConfigDedup, ConfigGrpc2Kafka, ConfigKafka2Grpc, GrpcRequestToProto},
|
config::{Config, ConfigDedup, ConfigGrpc2Kafka, ConfigKafka2Grpc, GrpcRequestToProto},
|
||||||
dedup::KafkaDedup,
|
dedup::KafkaDedup,
|
||||||
|
@ -38,7 +31,7 @@ use {
|
||||||
prom,
|
prom,
|
||||||
},
|
},
|
||||||
yellowstone_grpc_proto::{
|
yellowstone_grpc_proto::{
|
||||||
prelude::{geyser_client::GeyserClient, subscribe_update::UpdateOneof, SubscribeUpdate},
|
prelude::{subscribe_update::UpdateOneof, SubscribeUpdate},
|
||||||
prost::Message as _,
|
prost::Message as _,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -218,28 +211,17 @@ impl ArgsAction {
|
||||||
.create()
|
.create()
|
||||||
.context("failed to create kafka producer")?;
|
.context("failed to create kafka producer")?;
|
||||||
|
|
||||||
// Create gRPC client
|
// Create gRPC client & subscribe
|
||||||
let mut endpoint = Channel::from_shared(config.endpoint)?;
|
let mut client = GeyserGrpcClient::connect_with_timeout(
|
||||||
if endpoint.uri().scheme_str() == Some("https") {
|
config.endpoint,
|
||||||
endpoint = endpoint.tls_config(ClientTlsConfig::new())?;
|
config.x_token,
|
||||||
}
|
None,
|
||||||
let channel = endpoint.connect().await?;
|
Some(Duration::from_secs(10)),
|
||||||
let x_token: Option<AsciiMetadataValue> = match config.x_token {
|
Some(Duration::from_secs(5)),
|
||||||
Some(x_token) => Some(x_token.try_into()?),
|
false,
|
||||||
None => None,
|
)
|
||||||
};
|
.await?;
|
||||||
let mut client = GeyserClient::with_interceptor(channel, move |mut req: Request<()>| {
|
let mut geyser = client.subscribe_once2(config.request.to_proto()).await?;
|
||||||
if let Some(x_token) = x_token.clone() {
|
|
||||||
req.metadata_mut().insert("x-token", x_token);
|
|
||||||
}
|
|
||||||
Ok(req)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Subscribe on Geyser events
|
|
||||||
let (mut subscribe_tx, subscribe_rx) = mpsc::unbounded();
|
|
||||||
subscribe_tx.send(config.request.to_proto()).await?;
|
|
||||||
let response: Response<Streaming<SubscribeUpdate>> = client.subscribe(subscribe_rx).await?;
|
|
||||||
let mut geyser = response.into_inner().boxed();
|
|
||||||
|
|
||||||
// Receive-send loop
|
// Receive-send loop
|
||||||
let mut send_tasks = JoinSet::new();
|
let mut send_tasks = JoinSet::new();
|
||||||
|
|
Loading…
Reference in New Issue