Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to provide an expiration time for a subscription in Google Cloud PubSub

I'm trying to set an expiration time for a subscription.

This is how options looks like as suggested by the official docs:

https://cloud.google.com/nodejs/docs/reference/pubsub/0.28.x/global#CreateSubscriptionRequest https://cloud.google.com/nodejs/docs/reference/pubsub/0.28.x/global#ExpirationPolicy

let options = {
  expirationPolicy: {
    ttl: '86400s',
  },
};

Then I got .google.pubsub.v1.ExpirationPolicy.ttl: object expected error.

So I tried having an object inside property ttl then I got the following error: The value for 0 is too small. You passed expiration duration in the request, but the minimum value is 24h.

I'm unable to find the correct format to this.

I'm on @google-cloud/[email protected] and tried upgrading to @google-cloud/[email protected]. No luck.

Anyone has experienced this before or know the correct format for expirationPolicy?

like image 657
nuttiness7120 Avatar asked Nov 22 '25 10:11

nuttiness7120


1 Answers

The expirationPolicy ttl needs to be specified as an object with the seconds field as an integer:

let options = {
  expirationPolicy: {
    ttl: {
      seconds: 86400
    }
  }
};

This is inconsistent with the documentation, so I have created a GitHub issue to track the inconsistency.

like image 184
Kamal Aboul-Hosn Avatar answered Nov 23 '25 23:11

Kamal Aboul-Hosn