Struct google_cloud_pubsub::client::Client
source · [−]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
sourceimpl 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.
sourcepub async fn create_subscription(
&self,
id: &str,
topic_id: &str,
cfg: SubscriptionConfig,
cancel: Option<CancellationToken>,
retry: Option<RetrySetting>
) -> Result<Subscription, Status>
pub async fn create_subscription(
&self,
id: &str,
topic_id: &str,
cfg: SubscriptionConfig,
cancel: Option<CancellationToken>,
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,
cancel: Option<CancellationToken>,
retry: Option<RetrySetting>
) -> Result<Vec<Subscription>, Status>
pub async fn get_subscriptions(
&self,
cancel: Option<CancellationToken>,
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,
cancel: Option<CancellationToken>,
retry: Option<RetrySetting>
) -> Result<(), Status>
pub async fn detach_subscription(
&self,
fqsn: &str,
cancel: Option<CancellationToken>,
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>,
cancel: Option<CancellationToken>,
retry: Option<RetrySetting>
) -> Result<Topic, Status>
pub async fn create_topic(
&self,
id: &str,
cfg: Option<TopicConfig>,
cancel: Option<CancellationToken>,
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,
cancel: Option<CancellationToken>,
retry: Option<RetrySetting>
) -> Result<Vec<String>, Status>
pub async fn get_topics(
&self,
cancel: Option<CancellationToken>,
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.
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 !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T in a tonic::Request
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more