pub async fn create_subscription(
        &mut self,
        id: &str,
        config: SubscriptionConfig,
    ) -> Result<Subscription, Error> {
        let request = api::Subscription {
            name: format!(
                "projects/{0}/subscriptions/{1}",
                self.client.project_name.as_str(),
                id,
            ),
            topic: self.name.clone(),
            ack_deadline_seconds: config.ack_deadline_duration.num_seconds() as i32,
            retain_acked_messages: config.message_retention_duration.is_some(),
            message_retention_duration: config.message_retention_duration.map(|mut dur| {
                let seconds = dur.num_seconds();
                dur = dur - chrono::Duration::seconds(seconds);
                let nanos = dur.num_nanoseconds().unwrap_or(0) as i32;
                prost_types::Duration { seconds, nanos }
            }),
            labels: config.labels,
            enable_message_ordering: false,
            push_config: None,
            expiration_policy: None,
            dead_letter_policy: None,
            ..Default::default()
        };
        let request = self.client.construct_request(request).await?;
        let response = self.client.subscriber.create_subscription(request).await?;
        let subscription = response.into_inner();

        Ok(Subscription::new(self.client.clone(), subscription.name))
    }
/// Create a subscription tied to this topic.
Create a subscription tied to this topic.
Create a subscription tied to this topic .
pub async fn create_subscription(
        &mut self,
        id: &str,
        config: SubscriptionConfig,
    ) -> Result<Subscription, Error> {
        let request = api::Subscription {
            name: format!(
                "projects/{0}/subscriptions/{1}",
                self.client.project_name.as_str(),
                id,
            ),
            topic: self.name.clone(),
            ack_deadline_seconds: config.ack_deadline_duration.num_seconds() as i32,
            retain_acked_messages: config.message_retention_duration.is_some(),
            message_retention_duration: config.message_retention_duration.map(|mut dur| {
                let seconds = dur.num_seconds();
                dur = dur - chrono::Duration::seconds(seconds);
                let nanos = dur.num_nanoseconds().unwrap_or(0) as i32;
                prost_types::Duration { seconds, nanos }
            }),
            labels: config.labels,
            enable_message_ordering: false,
            push_config: None,
            expiration_policy: None,
            dead_letter_policy: None,
            ..Default::default()
        };
        let request = self.client.construct_request(request).await?;
        let response = self.client.subscriber.create_subscription(request).await?;
        let subscription = response.into_inner();
        Ok(Subscription::new(self.client.clone(), subscription.name))
    }
pub async fn create_subscription ( & mut self , id : & str , config : SubscriptionConfig , ) -> Result < Subscription , Error > { let request = api :: Subscription { name : format ! ( " " self client project_name as_str ( ) id ) , topic : self . name . clone ( ) , ack_deadline_seconds : config . ack_deadline_duration . num_seconds ( ) as i32 , retain_acked_messages : config . message_retention_duration . is_some ( ) , message_retention_duration : config . message_retention_duration . map ( | mut dur | { let seconds = dur . num_seconds ( ) ; dur = dur - chrono :: Duration :: seconds ( seconds ) ; let nanos = dur . num_nanoseconds ( ) . unwrap_or ( 0 ) as i32 ; prost_types :: Duration { seconds , nanos } } ) , labels : config . labels , enable_message_ordering : false , push_config : None , expiration_policy : None , dead_letter_policy : None , .. Default :: default ( ) } ; let request = self . client . construct_request ( request ) . await ? ; let response = self . client . subscriber . create_subscription ( request ) . await ? ; let subscription = response . into_inner ( ) ; Ok ( Subscription :: new ( self . client . clone ( ) , subscription . name ) ) }
Create a subscription tied to this topic.
Create a subscription tied to this topic .
&mut self
id
&str
config
SubscriptionConfig
&mut self
id
&str
config
SubscriptionConfig