NATS Object Store Trigger icon

NATS Object Store Trigger

Watch for object changes in NATS Object Store buckets and trigger workflows

Overview

This node is a trigger that monitors changes in buckets within a NATS Object Store. It listens for object events such as creations, updates, and optionally deletions inside a specified bucket. When such changes occur, it emits the details of the changed objects to start workflows automatically.

Common scenarios where this node is beneficial include:

  • Automating processing pipelines when new files are uploaded or existing files are modified in a storage bucket.
  • Keeping external systems synchronized with the latest state of objects in a bucket.
  • Migrating or initializing data by processing all existing objects on startup.

For example, you could use this node to trigger a workflow that generates thumbnails whenever an image file is added to a bucket, or to update a search index when documents are updated or deleted.

Properties

Name Meaning
Bucket Name The name of the bucket to monitor for changes. Must contain only letters, numbers, hyphens, and underscores (no spaces or dots).
Options Collection of additional options:
  Include Deletes Whether to trigger the workflow when objects are deleted from the bucket (true/false). Default is true.
  Include History Whether to process all existing objects in the bucket when the trigger starts. Useful for initial data processing or migration (true/false). Default is false.

Output

The node outputs JSON data representing the object change event. Each emitted item contains detailed metadata about the object, including but not limited to:

  • name: The object's key or path within the bucket.
  • size: Size of the object in bytes.
  • chunks: Number of chunks the object is divided into.
  • digest: A SHA-256 hash digest of the object content.
  • mtime: Last modification timestamp.
  • bucket: The bucket name.
  • deleted: Boolean indicating if the object was deleted.
  • metadata: Custom metadata associated with the object (e.g., uploader info, content type, tags).
  • revision: Revision number of the object.
  • created: Creation timestamp.

If the node is configured to include deletes, deletion events will also be emitted with deleted set to true.

The node does not output binary data directly; it only provides metadata about the objects.

Dependencies

  • Requires connection to a NATS server with access to the Object Store feature.
  • Needs an API authentication credential to connect securely to the NATS server.
  • Uses internal utilities to manage the NATS connection and watch for object store events.
  • No additional environment variables are explicitly required beyond the API credential.

Troubleshooting

  • Connection Issues: If the node cannot connect to the NATS server, ensure the API credentials are correct and the server is reachable. Network issues or incorrect credentials can cause connection failures.
  • Permission Errors: Async errors related to permissions may occur if the provided credentials lack rights to watch the specified bucket. Verify the credential's permissions.
  • Bucket Naming: Using invalid bucket names (containing spaces or dots) may cause errors. Use only allowed characters: letters, numbers, hyphens, and underscores.
  • Watcher Stops Unexpectedly: The node logs warnings if the watcher loop stops. This might indicate network instability or server-side issues.
  • Initial History Processing: Enabling "Include History" causes the node to process all existing objects at startup, which may lead to high load or delays if the bucket is large.

Links and References

Discussion