DDS Event Source (offline soon)¶
For the use of DDS triggers, please refer to Using a DDS Trigger.
DDS example event¶
{
"records": [
{
"event_source": "dds",
"event_name": "insert",
"region": "region",
"event_version": "1.0",
"dds": {
"size_bytes": "100",
"token": "{\"_data\": \"825D8C2F4D0000001529295A100474039A3412A64BA89041DC952357FB4446645F696400645D8C2F8E5BECCB6CF5370D6A0004\"}",
"full_document": "{\"_id\": {\"$oid\": \"5d8c2f8e5beccb6cf5370d6a\"},\"name\": \"dds\",\"age\": {\"$numberDouble\": \"52.0\"}}",
"ns": "{\"db\": \"functiongraph\",\"coll\": \"person\"}"
},
"event_source_id": "e6065860-f7b8-4cca-80bd-24ef2a3bb748"
}
]
}
Parameter description¶
Parameter |
Type |
Description |
|---|---|---|
event_source |
String |
Event source |
event_name |
String |
Event name |
region |
String |
Region where the DDS instance is located |
event_version |
String |
Event version |
size_bytes |
String |
Message bytes |
token |
JSON String |
Base64-encoded data |
full_document |
JSON String |
Complete file information |
ns |
JSON String |
Column name |
event_source_id |
String |
Event source ID |
Example¶
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use OTC\fg_dds_event\DDSEvent;
function initializer($context)
{
$logger = $context->getLogger();
$output = 'Initializer called for function: ' . $context->getFunctionName();
$logger->debug($output);
return $output;
}
function handler($event, $context)
{
$logger = $context->getLogger();
$logger->info('Function name: ' . $context->getFunctionName());
$ddsEvent = new DDSEvent($event);
$logger->info('Record count from event: ' . count($ddsEvent->getRecords()));
$output = [
'statusCode' => 200,
'headers' => [
'Content-Type' => 'application/json',
],
'isBase64Encoded' => false,
'body' => json_encode($event),
];
return $output;
}
Full sample code is available in the samples-doc/scratch-event-dds.