1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
// This file is @generated by prost-build.
/// A topic resource.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Topic {
/// Name of the topic.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// A message data and its attributes.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubsubMessage {
/// The message payload. For JSON requests, the value of this field must be
/// base64-encoded.
#[prost(bytes = "bytes", tag = "1")]
pub data: ::prost::bytes::Bytes,
/// Optional attributes for this message.
#[prost(btree_map = "string, string", tag = "2")]
pub attributes: ::prost::alloc::collections::BTreeMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
/// ID of this message assigned by the server at publication time. Guaranteed
/// to be unique within the topic. This value may be read by a subscriber
/// that receives a PubsubMessage via a Pull call or a push delivery. It must
/// not be populated by a publisher in a Publish call.
#[prost(string, tag = "3")]
pub message_id: ::prost::alloc::string::String,
}
/// Request for the GetTopic method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetTopicRequest {
/// The name of the topic to get.
#[prost(string, tag = "1")]
pub topic: ::prost::alloc::string::String,
}
/// Request for the Publish method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublishRequest {
/// The messages in the request will be published on this topic.
#[prost(string, tag = "1")]
pub topic: ::prost::alloc::string::String,
/// The messages to publish.
#[prost(message, repeated, tag = "2")]
pub messages: ::prost::alloc::vec::Vec<PubsubMessage>,
}
/// Response for the Publish method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublishResponse {
/// The server-assigned ID of each published message, in the same order as
/// the messages in the request. IDs are guaranteed to be unique within
/// the topic.
#[prost(string, repeated, tag = "1")]
pub message_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Request for the ListTopics method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListTopicsRequest {
/// The name of the cloud project that topics belong to.
#[prost(string, tag = "1")]
pub project: ::prost::alloc::string::String,
/// Maximum number of topics to return.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// The value returned by the last ListTopicsResponse; indicates that this is
/// a continuation of a prior ListTopics call, and that the system should
/// return the next page of data.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response for the ListTopics method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListTopicsResponse {
/// The resulting topics.
#[prost(message, repeated, tag = "1")]
pub topics: ::prost::alloc::vec::Vec<Topic>,
/// If not empty, indicates that there may be more topics that match the
/// request; this value should be passed in a new ListTopicsRequest.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for the ListTopicSubscriptions method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListTopicSubscriptionsRequest {
/// The name of the topic that subscriptions are attached to.
#[prost(string, tag = "1")]
pub topic: ::prost::alloc::string::String,
/// Maximum number of subscription names to return.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// The value returned by the last ListTopicSubscriptionsResponse; indicates
/// that this is a continuation of a prior ListTopicSubscriptions call, and
/// that the system should return the next page of data.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response for the ListTopicSubscriptions method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListTopicSubscriptionsResponse {
/// The names of the subscriptions that match the request.
#[prost(string, repeated, tag = "1")]
pub subscriptions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// If not empty, indicates that there may be more subscriptions that match
/// the request; this value should be passed in a new
/// ListTopicSubscriptionsRequest to get more subscriptions.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for the DeleteTopic method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteTopicRequest {
/// Name of the topic to delete.
#[prost(string, tag = "1")]
pub topic: ::prost::alloc::string::String,
}
/// A subscription resource.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Subscription {
/// Name of the subscription.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// The name of the topic from which this subscription is receiving messages.
/// This will be present if and only if the subscription has not been detached
/// from its topic.
#[prost(string, tag = "2")]
pub topic: ::prost::alloc::string::String,
/// If push delivery is used with this subscription, this field is
/// used to configure it. An empty pushConfig signifies that the subscriber
/// will pull and ack messages using API methods.
#[prost(message, optional, tag = "4")]
pub push_config: ::core::option::Option<PushConfig>,
/// This value is the maximum time after a subscriber receives a message
/// before the subscriber should acknowledge the message. After message
/// delivery but before the ack deadline expires and before the message is
/// acknowledged, it is an outstanding message and will not be delivered
/// again during that time (on a best-effort basis).
///
/// For pull delivery this value
/// is used as the initial value for the ack deadline. It may be overridden
/// for a specific message by calling ModifyAckDeadline.
///
/// For push delivery, this value is also used to set the request timeout for
/// the call to the push endpoint.
///
/// If the subscriber never acknowledges the message, the Pub/Sub
/// system will eventually redeliver the message.
#[prost(int32, tag = "5")]
pub ack_deadline_seconds: i32,
}
/// Configuration for a push delivery endpoint.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PushConfig {
/// A URL locating the endpoint to which messages should be pushed.
/// For example, a Webhook endpoint might use "<https://example.com/push".>
#[prost(string, tag = "1")]
pub push_endpoint: ::prost::alloc::string::String,
/// Endpoint configuration attributes.
///
/// Every endpoint has a set of API supported attributes that can be used to
/// control different aspects of the message delivery.
///
/// The currently supported attribute is `x-goog-version`, which you can
/// use to change the format of the push message. This attribute
/// indicates the version of the data expected by the endpoint. This
/// controls the shape of the envelope (i.e. its fields and metadata).
/// The endpoint version is based on the version of the Pub/Sub
/// API.
///
/// If not present during the CreateSubscription call, it will default to
/// the version of the API used to make such call. If not present during a
/// ModifyPushConfig call, its value will not be changed. GetSubscription
/// calls will always return a valid version, even if the subscription was
/// created without this attribute.
///
/// The possible values for this attribute are:
///
/// * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
/// * `v1beta2`: uses the push format defined in the v1beta2 Pub/Sub API.
///
#[prost(btree_map = "string, string", tag = "2")]
pub attributes: ::prost::alloc::collections::BTreeMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
/// A message and its corresponding acknowledgment ID.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReceivedMessage {
/// This ID can be used to acknowledge the received message.
#[prost(string, tag = "1")]
pub ack_id: ::prost::alloc::string::String,
/// The message.
#[prost(message, optional, tag = "2")]
pub message: ::core::option::Option<PubsubMessage>,
}
/// Request for the GetSubscription method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetSubscriptionRequest {
/// The name of the subscription to get.
#[prost(string, tag = "1")]
pub subscription: ::prost::alloc::string::String,
}
/// Request for the ListSubscriptions method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListSubscriptionsRequest {
/// The name of the cloud project that subscriptions belong to.
#[prost(string, tag = "1")]
pub project: ::prost::alloc::string::String,
/// Maximum number of subscriptions to return.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// The value returned by the last ListSubscriptionsResponse; indicates that
/// this is a continuation of a prior ListSubscriptions call, and that the
/// system should return the next page of data.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response for the ListSubscriptions method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListSubscriptionsResponse {
/// The subscriptions that match the request.
#[prost(message, repeated, tag = "1")]
pub subscriptions: ::prost::alloc::vec::Vec<Subscription>,
/// If not empty, indicates that there may be more subscriptions that match
/// the request; this value should be passed in a new ListSubscriptionsRequest
/// to get more subscriptions.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for the DeleteSubscription method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteSubscriptionRequest {
/// The subscription to delete.
#[prost(string, tag = "1")]
pub subscription: ::prost::alloc::string::String,
}
/// Request for the ModifyPushConfig method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModifyPushConfigRequest {
/// The name of the subscription.
#[prost(string, tag = "1")]
pub subscription: ::prost::alloc::string::String,
/// The push configuration for future deliveries.
///
/// An empty pushConfig indicates that the Pub/Sub system should
/// stop pushing messages from the given subscription and allow
/// messages to be pulled and acknowledged - effectively pausing
/// the subscription if Pull is not called.
#[prost(message, optional, tag = "2")]
pub push_config: ::core::option::Option<PushConfig>,
}
/// Request for the Pull method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PullRequest {
/// The subscription from which messages should be pulled.
#[prost(string, tag = "1")]
pub subscription: ::prost::alloc::string::String,
/// If this is specified as true the system will respond immediately even if
/// it is not able to return a message in the Pull response. Otherwise the
/// system is allowed to wait until at least one message is available rather
/// than returning no messages. The client may cancel the request if it does
/// not wish to wait any longer for the response.
#[prost(bool, tag = "2")]
pub return_immediately: bool,
/// The maximum number of messages returned for this request. The Pub/Sub
/// system may return fewer than the number specified.
#[prost(int32, tag = "3")]
pub max_messages: i32,
}
/// Response for the Pull method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PullResponse {
/// Received Pub/Sub messages. The Pub/Sub system will return zero messages if
/// there are no more available in the backlog. The Pub/Sub system may return
/// fewer than the maxMessages requested even if there are more messages
/// available in the backlog.
#[prost(message, repeated, tag = "1")]
pub received_messages: ::prost::alloc::vec::Vec<ReceivedMessage>,
}
/// Request for the ModifyAckDeadline method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModifyAckDeadlineRequest {
/// The name of the subscription.
#[prost(string, tag = "1")]
pub subscription: ::prost::alloc::string::String,
/// The acknowledgment ID.
#[prost(string, tag = "2")]
pub ack_id: ::prost::alloc::string::String,
/// The new ack deadline with respect to the time this request was sent to the
/// Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
/// deadline will expire 10 seconds after the ModifyAckDeadline call was made.
/// Specifying zero may immediately make the message available for another pull
/// request.
#[prost(int32, tag = "3")]
pub ack_deadline_seconds: i32,
}
/// Request for the Acknowledge method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AcknowledgeRequest {
/// The subscription whose message is being acknowledged.
#[prost(string, tag = "1")]
pub subscription: ::prost::alloc::string::String,
/// The acknowledgment ID for the messages being acknowledged that was returned
/// by the Pub/Sub system in the Pull response. Must not be empty.
#[prost(string, repeated, tag = "2")]
pub ack_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Generated client implementations.
pub mod subscriber_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// The service that an application uses to manipulate subscriptions and to
/// consume messages from a subscription via the Pull method.
#[derive(Debug, Clone)]
pub struct SubscriberClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> SubscriberClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> SubscriberClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
SubscriberClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Creates a subscription to a given topic for a given subscriber.
/// If the subscription already exists, returns ALREADY_EXISTS.
/// If the corresponding topic doesn't exist, returns NOT_FOUND.
///
/// If the name is not provided in the request, the server will assign a random
/// name for this subscription on the same project as the topic.
pub async fn create_subscription(
&mut self,
request: impl tonic::IntoRequest<super::Subscription>,
) -> std::result::Result<tonic::Response<super::Subscription>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/CreateSubscription",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Subscriber",
"CreateSubscription",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets the configuration details of a subscription.
pub async fn get_subscription(
&mut self,
request: impl tonic::IntoRequest<super::GetSubscriptionRequest>,
) -> std::result::Result<tonic::Response<super::Subscription>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/GetSubscription",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Subscriber",
"GetSubscription",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists matching subscriptions.
pub async fn list_subscriptions(
&mut self,
request: impl tonic::IntoRequest<super::ListSubscriptionsRequest>,
) -> std::result::Result<
tonic::Response<super::ListSubscriptionsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/ListSubscriptions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Subscriber",
"ListSubscriptions",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes an existing subscription. All pending messages in the subscription
/// are immediately dropped. Calls to Pull after deletion will return
/// NOT_FOUND. After a subscription is deleted, a new one may be created with
/// the same name, but the new one has no association with the old
/// subscription, or its topic unless the same topic is specified.
pub async fn delete_subscription(
&mut self,
request: impl tonic::IntoRequest<super::DeleteSubscriptionRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/DeleteSubscription",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Subscriber",
"DeleteSubscription",
),
);
self.inner.unary(req, path, codec).await
}
/// Modifies the ack deadline for a specific message. This method is useful to
/// indicate that more time is needed to process a message by the subscriber,
/// or to make the message available for redelivery if the processing was
/// interrupted.
pub async fn modify_ack_deadline(
&mut self,
request: impl tonic::IntoRequest<super::ModifyAckDeadlineRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/ModifyAckDeadline",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Subscriber",
"ModifyAckDeadline",
),
);
self.inner.unary(req, path, codec).await
}
/// Acknowledges the messages associated with the ack tokens in the
/// AcknowledgeRequest. The Pub/Sub system can remove the relevant messages
/// from the subscription.
///
/// Acknowledging a message whose ack deadline has expired may succeed,
/// but such a message may be redelivered later. Acknowledging a message more
/// than once will not result in an error.
pub async fn acknowledge(
&mut self,
request: impl tonic::IntoRequest<super::AcknowledgeRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/Acknowledge",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("google.pubsub.v1beta2.Subscriber", "Acknowledge"),
);
self.inner.unary(req, path, codec).await
}
/// Pulls messages from the server. Returns an empty list if there are no
/// messages available in the backlog. The server may return UNAVAILABLE if
/// there are too many concurrent pull requests pending for the given
/// subscription.
pub async fn pull(
&mut self,
request: impl tonic::IntoRequest<super::PullRequest>,
) -> std::result::Result<tonic::Response<super::PullResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/Pull",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("google.pubsub.v1beta2.Subscriber", "Pull"));
self.inner.unary(req, path, codec).await
}
/// Modifies the PushConfig for a specified subscription.
///
/// This may be used to change a push subscription to a pull one (signified
/// by an empty PushConfig) or vice versa, or change the endpoint URL and other
/// attributes of a push subscription. Messages will accumulate for
/// delivery continuously through the call regardless of changes to the
/// PushConfig.
pub async fn modify_push_config(
&mut self,
request: impl tonic::IntoRequest<super::ModifyPushConfigRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Subscriber/ModifyPushConfig",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Subscriber",
"ModifyPushConfig",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Generated client implementations.
pub mod publisher_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// The service that an application uses to manipulate topics, and to send
/// messages to a topic.
#[derive(Debug, Clone)]
pub struct PublisherClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> PublisherClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> PublisherClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
PublisherClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Creates the given topic with the given name.
pub async fn create_topic(
&mut self,
request: impl tonic::IntoRequest<super::Topic>,
) -> std::result::Result<tonic::Response<super::Topic>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Publisher/CreateTopic",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("google.pubsub.v1beta2.Publisher", "CreateTopic"),
);
self.inner.unary(req, path, codec).await
}
/// Adds one or more messages to the topic. Returns NOT_FOUND if the topic does
/// not exist.
pub async fn publish(
&mut self,
request: impl tonic::IntoRequest<super::PublishRequest>,
) -> std::result::Result<
tonic::Response<super::PublishResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Publisher/Publish",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("google.pubsub.v1beta2.Publisher", "Publish"));
self.inner.unary(req, path, codec).await
}
/// Gets the configuration of a topic.
pub async fn get_topic(
&mut self,
request: impl tonic::IntoRequest<super::GetTopicRequest>,
) -> std::result::Result<tonic::Response<super::Topic>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Publisher/GetTopic",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("google.pubsub.v1beta2.Publisher", "GetTopic"));
self.inner.unary(req, path, codec).await
}
/// Lists matching topics.
pub async fn list_topics(
&mut self,
request: impl tonic::IntoRequest<super::ListTopicsRequest>,
) -> std::result::Result<
tonic::Response<super::ListTopicsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Publisher/ListTopics",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("google.pubsub.v1beta2.Publisher", "ListTopics"),
);
self.inner.unary(req, path, codec).await
}
/// Lists the name of the subscriptions for this topic.
pub async fn list_topic_subscriptions(
&mut self,
request: impl tonic::IntoRequest<super::ListTopicSubscriptionsRequest>,
) -> std::result::Result<
tonic::Response<super::ListTopicSubscriptionsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Publisher/ListTopicSubscriptions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.pubsub.v1beta2.Publisher",
"ListTopicSubscriptions",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes the topic with the given name. Returns NOT_FOUND if the topic does
/// not exist. After a topic is deleted, a new topic may be created with the
/// same name; this is an entirely new topic with none of the old
/// configuration or subscriptions. Existing subscriptions to this topic are
/// not deleted.
pub async fn delete_topic(
&mut self,
request: impl tonic::IntoRequest<super::DeleteTopicRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.pubsub.v1beta2.Publisher/DeleteTopic",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("google.pubsub.v1beta2.Publisher", "DeleteTopic"),
);
self.inner.unary(req, path, codec).await
}
}
}