Skip to content

Commit 79f37fd

Browse files
authored
feat: batch receive methods for the client (#24)
1 parent 21bae4e commit 79f37fd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

relay_client/src/http.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use {
99
auth::ed25519_dalek::Keypair,
1010
domain::{DecodedClientId, SubscriptionId, Topic},
1111
jwt::{self, JwtError, VerifyableClaims},
12-
rpc::{self, RequestPayload},
12+
rpc::{self, Receipt, RequestPayload},
1313
},
1414
std::{sync::Arc, time::Duration},
1515
url::Url,
@@ -247,6 +247,17 @@ impl Client {
247247
.await
248248
}
249249

250+
/// Acknowledge receipt of messages from a subscribed client.
251+
pub async fn batch_receive(
252+
&self,
253+
receipts: impl Into<Vec<Receipt>>,
254+
) -> Response<rpc::BatchReceiveMessages> {
255+
self.request(rpc::BatchReceiveMessages {
256+
receipts: receipts.into(),
257+
})
258+
.await
259+
}
260+
250261
pub(crate) async fn request<T>(&self, payload: T) -> Response<T>
251262
where
252263
T: RequestPayload,

relay_client/src/websocket.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ use {
55
domain::{SubscriptionId, Topic},
66
rpc::{
77
BatchFetchMessages,
8+
BatchReceiveMessages,
89
BatchSubscribe,
910
BatchUnsubscribe,
1011
FetchMessages,
1112
Publish,
13+
Receipt,
1214
Subscribe,
1315
Subscription,
1416
Unsubscribe,
@@ -231,6 +233,20 @@ impl Client {
231233
response
232234
}
233235

236+
/// Acknowledge receipt of messages from a subscribed client.
237+
pub async fn batch_receive(
238+
&self,
239+
receipts: impl Into<Vec<Receipt>>,
240+
) -> ResponseFuture<BatchReceiveMessages> {
241+
let (request, response) = create_request(BatchReceiveMessages {
242+
receipts: receipts.into(),
243+
});
244+
245+
self.request(request);
246+
247+
response
248+
}
249+
234250
/// Opens a connection to the Relay.
235251
pub async fn connect(&self, opts: &ConnectionOptions) -> Result<(), Error> {
236252
let (tx, rx) = oneshot::channel();

0 commit comments

Comments
 (0)