deleteSnapshot method

Future<void> deleteSnapshot({
  1. int retries = 5,
  2. required String snapshot,
})

Removes an existing snapshot. Snapshots are used in Seek 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. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.

The snapshot name can be just the simple name or it can be the fully quantified name in the format: projects/{project}/snapshots/{snap}.

Implementation

Future<void> deleteSnapshot({
  int retries = 5,
  required String snapshot,
}) async {
  assert(_initialized);
  _logger.fine('[deleteSnapshot]: start -- [$snapshot]');

  try {
    await _execute(
      executor: () async => await _pubsubApi.projects.snapshots.delete(
        snapshot.startsWith('projects/')
            ? snapshot
            : 'projects/$_projectId/snapshots/$snapshot',
      ),
      retries: retries,
    );
  } finally {
    _logger.fine('[deleteSnapshot]: complete -- [$snapshot]');
  }
}