Snapshot

Snapshot

A Snapshot object will give you access to your Cloud Pub/Sub snapshot.

Snapshots are sometimes retrieved when using various methods:

Snapshots may be created with:

  • Subscription#createSnapshot

You can use snapshots to seek a subscription to a specific point in time.

  • Subscription#seek

Constructor

new Snapshot()

Example
```
//-
// From PubSub#getSnapshots:
//-
pubsub.getSnapshots((err, snapshots) => {
  // `snapshots` is an array of Snapshot objects.
});

//-
// From PubSub#getSnapshotsStream:
//-
pubsub.getSnapshotsStream()
  .on('error', console.error)
  .on('data', (snapshot) => {
    // `snapshot` is a Snapshot object.
  });

//-
// From PubSub#snapshot:
//-
const snapshot = pubsub.snapshot('my-snapshot');
// snapshot is a Snapshot object.

//-
// Create a snapshot with {module:pubsub/subscription#createSnapshot}:
//-
const subscription = pubsub.subscription('my-subscription');

subscription.createSnapshot('my-snapshot', (err, snapshot) => {
  if (!err) {
    // `snapshot` is a Snapshot object.
  }
});

//-
// Seek to your snapshot:
//-
const subscription = pubsub.subscription('my-subscription');

subscription.seek('my-snapshot', (err) => {
  if (err) {
    // Error handling omitted.
  }
});
```