prorm API Reference
    Preparing search index...

    Class PubSubStore

    PubSubStore wraps a @google-cloud/pubsub client and exposes topic publishing, subscription listening, and topic/subscription administration.

    Implements

    Index
    name: "pubsub" = 'pubsub'

    The name of the store (e.g. 'mongodb', 'redis', 'dynamodb')

    library: "@google-cloud/pubsub" = '@google-cloud/pubsub'

    The client library being used

    • Publish one message to topic via topic(name).publishMessage. The message is encoded per the module's rules (string → UTF-8, Buffer → as-is, else JSON). Returns the server-assigned message id.

      Parameters

      • topic: string
      • message: PubSubMessage
      • Optionalattributes: Record<string, string>

      Returns Promise<string>

    • createTopic — create a new topic.

      Parameters

      • name: string

      Returns Promise<void>

    • createSubscription — attach a new subscription name to topic.

      Parameters

      • topic: string
      • name: string
      • Optionaloptions: unknown

      Returns Promise<void>

    • Subscribe to subscription, invoking handler for each streamed message (the driver's Message object; call .ack() / .nack() on it). Attaches a 'message' listener via subscription(name).on('message', ...) and returns a subscription handle whose stop() detaches the listener; it is also tracked so disconnect() detaches it.

      Parameters

      • subscription: string
      • handler: (message: any) => void | Promise<void>

      Returns Promise<PubSubSubscription>