pub struct Client { /* private fields */ }Expand description
Client is a Google Pub/Sub client scoped to a single project.
Clients should be reused rather than being created as needed. A Client may be shared by multiple tasks.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(config: ClientConfig) -> Result<Self, Error>
pub async fn new(config: ClientConfig) -> Result<Self, Error>
new creates a Pub/Sub client. See ClientConfig for more information.
Sourcepub async fn create_subscription(
&self,
id: &str,
topic_id: &str,
cfg: SubscriptionConfig,
retry: Option<RetrySetting>,
) -> Result<Subscription, Status>
pub async fn create_subscription( &self, id: &str, topic_id: &str, cfg: SubscriptionConfig, retry: Option<RetrySetting>, ) -> Result<Subscription, Status>
create_subscription creates a new subscription on a topic.
id is the name of the subscription to create. It must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and must not start with “goog”.
cfg.ack_deadline is the maximum time after a subscriber receives a message before the subscriber should acknowledge the message. It must be between 10 and 600 seconds (inclusive), and is rounded down to the nearest second. If the provided ackDeadline is 0, then the default value of 10 seconds is used. Note: messages which are obtained via Subscription.Receive need not be acknowledged within this deadline, as the deadline will be automatically extended.
cfg.push_config may be set to configure this subscription for push delivery.
If the subscription already exists an error will be returned.
Sourcepub async fn get_subscriptions(
&self,
retry: Option<RetrySetting>,
) -> Result<Vec<Subscription>, Status>
pub async fn get_subscriptions( &self, retry: Option<RetrySetting>, ) -> Result<Vec<Subscription>, Status>
subscriptions returns an iterator which returns all of the subscriptions for the client’s project.
Sourcepub fn subscription(&self, id: &str) -> Subscription
pub fn subscription(&self, id: &str) -> Subscription
subscription creates a reference to a subscription.
Sourcepub async fn detach_subscription(
&self,
fqsn: &str,
retry: Option<RetrySetting>,
) -> Result<(), Status>
pub async fn detach_subscription( &self, fqsn: &str, retry: Option<RetrySetting>, ) -> Result<(), Status>
detach_subscription detaches a subscription from its topic. All messages
retained in the subscription are dropped. Subsequent Pull and StreamingPull
requests will return FAILED_PRECONDITION. If the subscription is a push
subscription, pushes to the endpoint will stop.
Sourcepub async fn create_topic(
&self,
id: &str,
cfg: Option<TopicConfig>,
retry: Option<RetrySetting>,
) -> Result<Topic, Status>
pub async fn create_topic( &self, id: &str, cfg: Option<TopicConfig>, retry: Option<RetrySetting>, ) -> Result<Topic, Status>
create_topic creates a new topic.
The specified topic ID must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and must not start with “goog”. For more information, see: https://cloud.google.com/pubsub/docs/admin#resource_names
If the topic already exists an error will be returned.
Sourcepub async fn get_topics(
&self,
retry: Option<RetrySetting>,
) -> Result<Vec<String>, Status>
pub async fn get_topics( &self, retry: Option<RetrySetting>, ) -> Result<Vec<String>, Status>
topics returns an iterator which returns all of the topics for the client’s project.
Sourcepub fn topic(&self, id: &str) -> Topic
pub fn topic(&self, id: &str) -> Topic
topic creates a reference to a topic in the client’s project.
If a Topic’s Publish method is called, it has background tasks associated with it. Clean them up by calling topic.stop.
Avoid creating many Topic instances if you use them to publish.
Sourcepub async fn get_snapshots(
&self,
retry: Option<RetrySetting>,
) -> Result<Vec<Snapshot>, Status>
pub async fn get_snapshots( &self, retry: Option<RetrySetting>, ) -> Result<Vec<Snapshot>, Status>
get_snapshots lists the existing snapshots. Snapshots are used in Seek (at https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
pub fn fully_qualified_topic_name(&self, id: &str) -> String
pub fn fully_qualified_subscription_name(&self, id: &str) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request