forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Chen, Junjie <chenjunjie@huawei.com> Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
55 lines
12 KiB
HTML
55 lines
12 KiB
HTML
<a name="functiongraph_01_0210"></a><a name="functiongraph_01_0210"></a>
|
|
|
|
<h1 class="topictitle1">Using a DDS Trigger</h1>
|
|
<div id="body32001227"><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p20317235111217">This section describes how to create a DDS trigger for a function, and invoke the function when a database table changes.</p>
|
|
<p id="functiongraph_01_0210__en-us_topic_0000001251588444_p625214402349">A function using a DDS trigger will be triggered every time a database table is updated. For details about the DDS event source, see section "Supported Event Sources".</p>
|
|
<div class="section" id="functiongraph_01_0210__en-us_topic_0000001251588444_section134592267445"><h4 class="sectiontitle">Prerequisites</h4><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p244611039529">Before creating a trigger, ensure that you have prepared the following:</p>
|
|
<ul id="functiongraph_01_0210__en-us_topic_0000001251588444_ul10299171374519"><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li9624103216418">You have created a function. For details, see <a href="functiongraph_01_0153.html#functiongraph_01_0153">Creating a Function from Scratch</a>.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li2074581653516">You have enabled VPC access for the function. For details, see <a href="functiongraph_01_0222.html#functiongraph_01_0222">Configuring the Network</a>.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li19782151385815">You have created a DDS DB instance.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li192736181143">You have created a DDS database.</li></ul>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_0210__en-us_topic_0000001251588444_section3956183013126"><h4 class="sectiontitle">Creating a DDS Trigger</h4><ol id="functiongraph_01_0210__en-us_topic_0000001251588444_ol1451315571315"><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li188271311715"><span>Log in to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001251907924_b033610517502">Functions</strong> > <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001251907924_b183361950502">Function List</strong>.</span></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li488219139177"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0210__li48821313121717"><span>Choose <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b289510228329">Configuration</strong> > <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b156971032183216">Triggers</strong> and click <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001298507405_en-us_topic_0000001251588440_b98432283337">Create Trigger</strong>.</span><p><div class="fignone" id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001298507405_en-us_topic_0000001251588440_fig546212168431"><span class="figcap"><b>Figure 1 </b>Creating a trigger</span><br><span><img id="functiongraph_01_0210__en-us_topic_0000001251588444_en-us_topic_0000001298507405_en-us_topic_0000001251588440_image94621716114320" src="en-us_image_0000001679340817.png"></span></div>
|
|
</p></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li1576351912448"><span>Set the following parameters:</span><p><ul id="functiongraph_01_0210__en-us_topic_0000001251588444_ul1875218195446"><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li1275291944414"><strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b5322171013177">Trigger Type</strong>: Select <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b7577616131712">Document Database Service (DDS)</strong>.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li165351737174417"><strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b147781127181712">DB Instance</strong>: Select a DDS DB instance.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li87212604520"><strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b898594921710">Password</strong>: Enter the password of DDS DB instance administrator <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b6451105615473">rwuser</strong>.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li162318283457"><strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b18912113213188">Database</strong>: Enter the name of a database. Note that <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b122289296550">admin</strong>, <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b117350257556">local</strong>, and <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b3589132415515">config</strong> are reserved database names and cannot be used here.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li11360155774512"><strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b15517124132120">Collection</strong>: Enter the name of a database collection.</li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li1322713107460"><strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b527832972217">Batch Size</strong>: Set the number of records to be read from the database at a time.</li></ul>
|
|
</p></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li522552101114"><span>Click <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b1859311412225">OK</strong>.</span><p><div class="note" id="functiongraph_01_0210__en-us_topic_0000001251588444_note98311553266"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p1630531211513">After VPC access is enabled, you need to configure corresponding subnet permissions for the DDS security group. For details about how to configure VPC access, see <a href="functiongraph_01_0222.html#functiongraph_01_0222">Configuring the Network</a>.</p>
|
|
</div></div>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="functiongraph_01_0210__en-us_topic_0000001251588444_section8958730121211"><h4 class="sectiontitle">Configuring a DDS Event to Trigger the Function</h4><ol id="functiongraph_01_0210__en-us_topic_0000001251588444_ol1450442693518"><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li1520416101968"><span>Return to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b50972949291527">Functions</strong> > <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b96253940791527">Function List</strong>.</span></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li1080841135117"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li13470153605820"><span>On the function details page, select a version, and click <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b969816153915">Test</strong>. The <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b121910375397">Configure Test Event</strong> dialog box is displayed.</span></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li9686135433718"><span>Set the parameters described in <a href="#functiongraph_01_0210__en-us_topic_0000001251588444_table15199135171812">Table 1</a> and click <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b46535466223">Save</strong>.</span><p>
|
|
<div class="tablenoborder"><a name="functiongraph_01_0210__en-us_topic_0000001251588444_table15199135171812"></a><a name="en-us_topic_0000001251588444_table15199135171812"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_0210__en-us_topic_0000001251588444_table15199135171812" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Test event information</caption><thead align="left"><tr id="functiongraph_01_0210__en-us_topic_0000001251588444_row31976510182"><th align="left" class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.3.5.2.4.2.1.2.3.1.1"><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p71977514187">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="72%" id="mcps1.3.5.2.4.2.1.2.3.1.2"><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p8197165171812">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="functiongraph_01_0210__en-us_topic_0000001251588444_row219735171814"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.5.2.4.2.1.2.3.1.1 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p3197850189">Configure Test Event</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.5.2.4.2.1.2.3.1.2 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p819718513189">You can choose to create a test event or edit an existing one.</p>
|
|
<p id="functiongraph_01_0210__en-us_topic_0000001251588444_p019785141810">Use the default option <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b104194975910">Create new test event</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_0210__en-us_topic_0000001251588444_row019845151817"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.5.2.4.2.1.2.3.1.1 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p1619715519182">Event Template</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.5.2.4.2.1.2.3.1.2 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p519812511182">Select <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b842352706162159">dds-event-template</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_0210__en-us_topic_0000001251588444_row01981653188"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.5.2.4.2.1.2.3.1.1 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p619865201814">Event Name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.5.2.4.2.1.2.3.1.2 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p171981253182">The event name can contain 1 to 25 characters and must start with a letter and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. For example, <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b128143499174">dds-123test</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="functiongraph_01_0210__en-us_topic_0000001251588444_row71991752189"><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.5.2.4.2.1.2.3.1.1 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p81983518186">Event data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.3.5.2.4.2.1.2.3.1.2 "><p id="functiongraph_01_0210__en-us_topic_0000001251588444_p1419810515185">The system automatically loads the built-in DDS event template, which is used in this example without modifications.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</p></li><li id="functiongraph_01_0210__en-us_topic_0000001251588444_li13199125191818"><span>Click <strong id="functiongraph_01_0210__en-us_topic_0000001251588444_b14276539191811">Test</strong>. The function test result is displayed.</span></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_01_0200.html">Creating Triggers</a></div>
|
|
</div>
|
|
</div>
|
|
|