This plugin is a wrapper for the Google Cloud Pub/Sub library.
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-pubsub
yum install halon-extras-pubsub
For the configuration schema, see pubsub.schema.json. Below is a sample configuration.
Note that the JSON key file setting (credentials) is optional and Google Application Default Credentials will be used if omitted.
plugins:
- id: pubsub
config:
projects:
- id: project-id
topics:
- topic1
# credentials: /path/to/keyfile.json
These functions needs to be imported from the extras://pubsub module path.
Publish a message to a topic asynchronously (Supports HSL suspend functionality).
Params
- project
string- The ID of the project as configured insmtpd.yaml - topic
string- The topic as configured insmtpd.yaml - message
string- The message to publish
Returns
A successful publish will return an associative array with a id key that contains the ID of the message. On error an additional error key will be provided with the error message.
Example
import { pubsub_publish } from "extras://pubsub";
echo pubsub_publish("project-id", "topic1", "This is a sample message.");