Skip to content

Commit

Permalink
Rename request builder method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarema committed Aug 25, 2022
1 parent 94afb04 commit cbec6e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions async-nats/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Client {
}

pub async fn request(&self, subject: String, payload: Bytes) -> Result<Message, Error> {
self.request_builder().payload(payload).send(subject).await
self.build_request().payload(payload).send(subject).await
}

pub async fn request_with_headers(
Expand All @@ -220,7 +220,7 @@ impl Client {
headers: HeaderMap,
payload: Bytes,
) -> Result<Message, Error> {
self.request_builder()
self.build_request()
.headers(headers)
.payload(payload)
.send(subject)
Expand All @@ -234,14 +234,14 @@ impl Client {
/// # #[tokio::main]
/// # async fn main() -> Result<(), async_nats::Error> {
/// let client = async_nats::connect("demo.nats.io").await?;
/// client.request_builder()
/// client.build_request()
/// .timeout(Some(std::time::Duration::from_secs(5)))
/// .payload("data".into())
/// .send("service".into()).await?;
/// # Ok(())
/// # }
/// ```
pub fn request_builder(&self) -> RequestBuilder {
pub fn build_request(&self) -> RequestBuilder {
RequestBuilder::new(self)
}

Expand Down Expand Up @@ -348,7 +348,7 @@ impl<'a> RequestBuilder<'a> {
/// # #[tokio::main]
/// # async fn main() -> Result<(), async_nats::Error> {
/// let client = async_nats::connect("demo.nats.io").await?;
/// client.request_builder()
/// client.build_request()
/// .payload("data".into())
/// .send("service".into()).await?;
/// # Ok(())
Expand All @@ -368,7 +368,7 @@ impl<'a> RequestBuilder<'a> {
/// let client = async_nats::connect("demo.nats.io").await?;
/// let mut headers = async_nats::HeaderMap::new();
/// headers.append("X-Example", b"value".as_ref().try_into().unwrap());
/// client.request_builder()
/// client.build_request()
/// .headers(headers)
/// .payload("data".into())
/// .send("service".into()).await?;
Expand All @@ -389,7 +389,7 @@ impl<'a> RequestBuilder<'a> {
/// # #[tokio::main]
/// # async fn main() -> Result<(), async_nats::Error> {
/// let client = async_nats::connect("demo.nats.io").await?;
/// client.request_builder()
/// client.build_request()
/// .timeout(Some(std::time::Duration::from_secs(15)))
/// .payload("data".into())
/// .send("service".into()).await?;
Expand All @@ -408,7 +408,7 @@ impl<'a> RequestBuilder<'a> {
/// # #[tokio::main]
/// # async fn main() -> Result<(), async_nats::Error> {
/// let client = async_nats::connect("demo.nats.io").await?;
/// client.request_builder()
/// client.build_request()
/// .inbox("custom_inbox".into())
/// .payload("data".into())
/// .send("service".into()).await?;
Expand All @@ -427,7 +427,7 @@ impl<'a> RequestBuilder<'a> {
/// # #[tokio::main]
/// # async fn main() -> Result<(), async_nats::Error> {
/// let client = async_nats::connect("demo.nats.io").await?;
/// client.request_builder()
/// client.build_request()
/// .payload("data".into())
/// .send("service".into()).await?;
/// # Ok(())
Expand Down
2 changes: 1 addition & 1 deletion async-nats/tests/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ mod client {
});

client
.request_builder()
.build_request()
.inbox(inbox.clone())
.send("service".into())
.await
Expand Down

0 comments on commit cbec6e4

Please sign in to comment.