We will use the Pub/Sub Golang library, which uses a persistent TCP connection under the covers.
google_pubsub
: a A new table for adding Pub/Sub connection details and topics
name
: string String column PK
system_key
: string String column
project_id
: string String column
credentials
: string String column (encryptedEncrypted. Will contain the credentials JSON file)
topics
: jsonb JSONB column (array of Pub/Sub topics array)
There will be endpoints for CRUD (details will be added later).
The topics entered during Pub/Sub connection creation will be added as subscribers to the topic tree. The Pub/Sub connection will implement the client
interface in core_messaging/broker/client_manager.go. We will use Use the Publish
function to forward messages.
...
Code Block |
---|
{ "credentials_map": { // thisThis is the service account jsonJSON object "type": "service_account", "project_id": "myprojectid", "private_key_id": "blahblahblah", "private_key": "<priv_key>", "client_email": "a@a.com", "client_id": "9126871624161341", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/dahjkdhajkd%40dajsdgajdadsad.iam.gserviceaccount.com" }, "project_id": "myprojectid", "topics": [ {"path": "iotdemo"}, // Non iotIoT coreCore topic {"path": "/devices/+/events", "type": 1, "target": "performance-testing"}, // iotIoT coreCore topic {"path": "/devices/+/events/sub", "type": 1, "target": "performance-testing-sub", "sub_folder": "sub"}, // iot core topic {"path": "/devices/+/state", "type": 2, "target": "performance-testing-state"} // iotIoT coreCore topic ] } |
path
is the topic the Pub/Sub client will subscribe to internally to the ClearBlade broker. type
is the topic type. No type represents a non-IoT Core topic, . 1 is for event
, and 2 is for state
. target
is the topic the Pub/Sub client will publish to in Pub/Sub. sub_folder
is for the event's topic if it has a subfolder.
...