Skip to content

Commit 2f3b6bd

Browse files
chamonsfreeznet
authored andcommitted
fix: Ability to set deliver_at_time from SerializeMessage messages directly (streamnative#337)
streamnative#336 Before this, the only way to set deliver_at_time was via the MessageBuilder. Co-authored-by: Rui Fu <freeznet@users.noreply.github.com>
1 parent dcc5c97 commit 2f3b6bd

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

examples/consumer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ async fn main() -> Result<(), pulsar::Error> {
5050
env::var("PULSAR_BASIC_USERNAME"),
5151
env::var("PULSAR_BASIC_PASSWORD"),
5252
) {
53-
builder =
54-
builder.with_auth_provider(Box::new(BasicAuthentication::new(&username, &password)))
53+
builder = builder.with_auth_provider(BasicAuthentication::new(&username, &password))
5554
}
5655

5756
let pulsar: Pulsar<_> = builder.build().await?;

examples/producer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ async fn main() -> Result<(), pulsar::Error> {
5252
env::var("PULSAR_BASIC_USERNAME"),
5353
env::var("PULSAR_BASIC_PASSWORD"),
5454
) {
55-
builder =
56-
builder.with_auth_provider(Box::new(BasicAuthentication::new(&username, &password)))
55+
builder = builder.with_auth_provider(BasicAuthentication::new(&username, &password))
5756
}
5857

5958
let pulsar: Pulsar<_> = builder.build().await?;

src/authentication/basic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ pub struct BasicAuthentication {
1212

1313
impl BasicAuthentication {
1414
#[must_use]
15-
pub fn new(username: &str, password: &str) -> Self {
16-
Self {
15+
pub fn new(username: &str, password: &str) -> Box<Self> {
16+
Box::new(Self {
1717
auth_data: format!("{username}:{password}"),
18-
}
18+
})
1919
}
2020
}
2121

src/producer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ pub struct Message {
8181
pub event_time: ::std::option::Option<u64>,
8282
/// current version of the schema
8383
pub schema_version: ::std::option::Option<Vec<u8>>,
84+
/// UTC Unix timestamp in milliseconds, time at which the message should be
85+
/// delivered to consumers
86+
pub deliver_at_time: ::std::option::Option<i64>,
8487
}
8588

8689
/// internal message type carrying options that must be defined
@@ -126,6 +129,7 @@ impl From<Message> for ProducerMessage {
126129
replicate_to: m.replicate_to,
127130
event_time: m.event_time,
128131
schema_version: m.schema_version,
132+
deliver_at_time: m.deliver_at_time,
129133
..Default::default()
130134
}
131135
}

0 commit comments

Comments
 (0)