diff --git a/examples/long_lived.rs b/examples/long_lived.rs index ba04809..61030fb 100644 --- a/examples/long_lived.rs +++ b/examples/long_lived.rs @@ -26,7 +26,7 @@ impl FromPubSubMessage for UpdatePacket { fn schedule_pubsub_pull(subscription: Arc) { task::spawn(async move { while subscription.client().is_running() { - match subscription.get_messages::().await { + match subscription.get_messages::(100).await { Ok(messages) => { for (result, ack_id) in messages { match result { diff --git a/examples/serde.rs b/examples/serde.rs index d51b5df..a7f7491 100644 --- a/examples/serde.rs +++ b/examples/serde.rs @@ -40,7 +40,7 @@ async fn main() { }; let order_sub = Arc::new(pubsub.subscribe(config.pubsub_subscription)); - match order_sub.clone().get_messages::().await { + match order_sub.clone().get_messages::(100).await { Ok(packets) => { for packet in &packets { println!("Received: {:?}", packet); diff --git a/examples/singleshot.rs b/examples/singleshot.rs index 2d677a2..2e83953 100644 --- a/examples/singleshot.rs +++ b/examples/singleshot.rs @@ -37,7 +37,7 @@ async fn main() { }; let subscription = Arc::new(pubsub.subscribe(config.pubsub_subscription)); - match subscription.get_messages::().await { + match subscription.get_messages::(100).await { Ok(messages) => { for (result, ack_id) in messages { match result { diff --git a/examples/subscribe_to_topic.rs b/examples/subscribe_to_topic.rs index 2862376..1d45c90 100644 --- a/examples/subscribe_to_topic.rs +++ b/examples/subscribe_to_topic.rs @@ -35,7 +35,7 @@ async fn main() { println!("Subscribed to topic with: {}", sub.name); let packets = sub .clone() - .get_messages::() + .get_messages::(100) .await .expect("Error Checking PubSub"); diff --git a/src/subscription.rs b/src/subscription.rs index 8a23537..1b17268 100644 --- a/src/subscription.rs +++ b/src/subscription.rs @@ -59,6 +59,7 @@ impl Subscription { pub async fn get_messages( &self, + max_messages: u16, ) -> Result, String)>, error::Error> { let client = self .client @@ -69,7 +70,7 @@ impl Subscription { .parse() .unwrap(); - let json = r#"{"maxMessages": 100}"#; + let json = format!("{{\"maxMessages\": {}}}", max_messages); let mut req = client.request(Method::POST, json); *req.uri_mut() = uri.clone();