Skip to content

*: bump proto #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion src/hstreamdb-pb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "hstreamdb-pb"
version = "0.1.1"
version = "0.2.0"

license = "BSD-3-Clause"
description = "Rust protocol library for HStreamDB"
Expand Down
2 changes: 1 addition & 1 deletion src/hstreamdb-pb/protocol
Submodule protocol updated 1 files
+25 −2 hstream.proto
4 changes: 2 additions & 2 deletions src/hstreamdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "hstreamdb"
version = "0.1.0"
version = "0.2.0"

license = "BSD-3-Clause"
description = "Rust client library for HStreamDB"
Expand All @@ -21,7 +21,7 @@ num-bigint = "0.4.3"
num-traits = "0.2.15"
md-5 = "0.10.1"

hstreamdb-pb = { version = "0.1.1", path = "../hstreamdb-pb/" }
hstreamdb-pb = { version = "0.2.0", path = "../hstreamdb-pb/" }
prost-types = "0.11.1"

prost = "0.11.0"
Expand Down
33 changes: 20 additions & 13 deletions src/hstreamdb/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ pub(crate) async fn get_available_node_addrs(
}

impl Client {
pub async fn create_stream(&self, stream: Stream) -> common::Result<()> {
self.channels.channel().await.create_stream(stream).await?;
Ok(())
pub async fn create_stream(&self, stream: Stream) -> common::Result<Stream> {
let stream = self.channels.channel().await.create_stream(stream).await?;
Ok(stream.into_inner())
}

pub async fn delete_stream(
Expand Down Expand Up @@ -138,14 +138,18 @@ impl Client {
}

impl Client {
pub async fn create_subscription(&self, subscription: Subscription) -> common::Result<()> {
pub async fn create_subscription(
&self,
subscription: Subscription,
) -> common::Result<Subscription> {
let subscription: hstreamdb_pb::Subscription = subscription.into();
self.channels
let subscription = self
.channels
.channel()
.await
.create_subscription(subscription)
.await?;
Ok(())
Ok(subscription.into_inner().into())
}

pub async fn delete_subscription(
Expand Down Expand Up @@ -267,12 +271,13 @@ mod tests {
replication_factor: 1,
backlog_duration: 30 * 60,
shard_count: 1,
creation_time: None,
};
let streams = (0..10)
let mut streams = (0..10)
.map(|_| make_stream(format!("stream-{}", rand_alphanumeric(10))))
.collect::<Vec<_>>();
for stream in streams.iter() {
client.create_stream(stream.clone()).await.unwrap()
for stream in streams.iter_mut() {
*stream = client.create_stream(stream.clone()).await.unwrap();
}

let listed_streams = client.list_streams().await.unwrap();
Expand Down Expand Up @@ -302,12 +307,13 @@ mod tests {
replication_factor: 1,
backlog_duration: 30 * 60,
shard_count: 1,
creation_time: None,
};
let streams = (0..10)
let mut streams = (0..10)
.map(|_| make_stream(format!("stream-{}", rand_alphanumeric(10))))
.collect::<Vec<_>>();
for stream in streams.iter() {
client.create_stream(stream.clone()).await.unwrap()
for stream in streams.iter_mut() {
*stream = client.create_stream(stream.clone()).await.unwrap();
}

let listed_streams = client.list_streams().await.unwrap();
Expand All @@ -321,6 +327,7 @@ mod tests {
ack_timeout_seconds: 60 * 10,
max_unacked_records: 1000,
offset: SpecialOffset::Earliest,
creation_time: None,
};
for stream in streams.iter() {
let subscription_ids = (0..5)
Expand All @@ -333,7 +340,7 @@ mod tests {
stream.stream_name.clone(),
))
.await
.unwrap()
.unwrap();
}
for subscription_id in subscription_ids.iter() {
assert!(
Expand Down
5 changes: 4 additions & 1 deletion src/hstreamdb/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub use hstreamdb_pb::{CompressionType, RecordId, SpecialOffset, Stream};
use hstreamdb_pb::{HStreamRecord, StreamingFetchRequest};
use num_bigint::ParseBigIntError;
use prost::{DecodeError, Message};
use prost_types::Struct;
pub use prost_types::{ListValue, Struct, Timestamp};
use tonic::transport;

use crate::producer;
Expand All @@ -16,6 +16,7 @@ pub struct Subscription {
pub ack_timeout_seconds: i32,
pub max_unacked_records: i32,
pub offset: SpecialOffset,
pub creation_time: Option<Timestamp>,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -48,6 +49,7 @@ impl From<Subscription> for hstreamdb_pb::Subscription {
ack_timeout_seconds: subscription.ack_timeout_seconds,
max_unacked_records: subscription.max_unacked_records,
offset: subscription.offset as _,
creation_time: subscription.creation_time,
}
}
}
Expand All @@ -61,6 +63,7 @@ impl From<hstreamdb_pb::Subscription> for Subscription {
ack_timeout_seconds: subscription.ack_timeout_seconds,
max_unacked_records: subscription.max_unacked_records,
offset,
creation_time: subscription.creation_time,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/hstreamdb/src/flow_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ mod tests {
replication_factor: 1,
backlog_duration: 10 * 60,
shard_count: 40,
creation_time: None,
})
.await
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/hstreamdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ pub mod utils;
pub use channel_provider::ChannelProviderSettings;
pub use client::Client;
pub use common::{
CompressionType, Error, Payload, Record, RecordId, Result, ShardId, SpecialOffset, Stream,
StreamShardOffset, Subscription,
CompressionType, Error, ListValue, Payload, Record, RecordId, Result, ShardId, SpecialOffset,
Stream, StreamShardOffset, Struct, Subscription, Timestamp,
};
1 change: 1 addition & 0 deletions src/hstreamdb/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ mod tests {
replication_factor: 1,
backlog_duration: 10 * 60,
shard_count: 200,
creation_time: None,
})
.await
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions src/hstreamdb/tests/consumer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async fn test_consumer() {
replication_factor: 1,
backlog_duration: 30 * 60,
shard_count: 12,
creation_time: None,
})
.await
.unwrap();
Expand All @@ -42,6 +43,7 @@ async fn test_consumer() {
ack_timeout_seconds: 60 * 60,
max_unacked_records: 1000,
offset: SpecialOffset::Earliest as _,
creation_time: None,
})
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions src/hstreamdb/tests/producer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async fn test_producer() {
replication_factor: 1,
backlog_duration: 30 * 60,
shard_count: 12,
creation_time: None,
})
.await
.unwrap();
Expand Down
4 changes: 3 additions & 1 deletion src/x/hstreamdb-erl-nifs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ fn async_create_stream(
replication_factor,
backlog_duration,
shard_count,
creation_time: None,
})
.await?;
Ok::<(), hstreamdb::Error>(())
Expand Down Expand Up @@ -262,10 +263,11 @@ fn async_create_subscription(
ack_timeout_seconds,
max_unacked_records,
offset,
creation_time: None,
})
.await;
OwnedEnv::new().send_and_clear(&pid, |env| match result {
Ok(()) => (create_subscription_reply(), ok()).encode(env),
Ok(_) => (create_subscription_reply(), ok()).encode(env),
Err(err) => (create_subscription_reply(), error(), err.to_string()).encode(env),
})
};
Expand Down