Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding cloudant change listener #66

Merged
merged 22 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ is demonstrating.
[Virtual Server Instances (VSIs)]((https://www.ibm.com/cloud/virtual-servers))
in your IBM Cloud account and run workload on them.

#### Daemon Jobs
groezing marked this conversation as resolved.
Show resolved Hide resolved
groezing marked this conversation as resolved.
Show resolved Hide resolved
- [cloudant-change-listener](cloudant_change_listener)<br>


#### Function

- [function-inline-nodejs](helloworld-samples/function-inline-nodejs)
Expand Down
2 changes: 2 additions & 0 deletions cloudant_change_listener/.ceignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
images
1 change: 1 addition & 0 deletions cloudant_change_listener/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions cloudant_change_listener/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM icr.io/codeengine/node:20-alpine
WORKDIR /usr/job
COPY . /usr/job/
RUN npm install
CMD [ "node", "cloudant_change_listener.mjs" ]
286 changes: 286 additions & 0 deletions cloudant_change_listener/README.md

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions cloudant_change_listener/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Env Vars:
# REGISTRY: name of the image registry/namespace to store the images
# NOCACHE: set this to "--no-cache" to turn off the Docker build cache
#
# NOTE: to run this you MUST set the REGISTRY environment variable to
# your own image registry/namespace otherwise the `docker push` commands
# will fail due to an auth failure. Which means, you also need to be logged
# into that registry before you run it.

set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}

docker build ${NOCACHE} -t ${REGISTRY}/cloudant-change-listener . --platform linux/amd64
docker push ${REGISTRY}/cloudant-change-listener
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function main(args) {
const body = {
args,
env: process.env,
};

console.log(`Return body: ${JSON.stringify(body, null, 2)}`);

return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
},
body,
};
}

module.exports.main = main;

577 changes: 577 additions & 0 deletions cloudant_change_listener/cloudant_change_listener.mjs

Large diffs are not rendered by default.

577 changes: 577 additions & 0 deletions cloudant_change_listener/db_listener.mjs

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<mxfile modified="2023-11-29T08:23:25.923Z" host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0" etag="3NCi9ePOaxr3Jc2k8PcM" version="22.1.4" type="device">
<diagram id="WI9T0HZ2pTsCkuznbFz-" name="Page-1">
<mxGraphModel dx="613" dy="376" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-4" value="Listening Feed&amp;nbsp;&lt;br&gt;on document&amp;nbsp; changes&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="207" y="219.5" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-5" value="&lt;b&gt;&lt;font style=&quot;font-size: 13px;&quot;&gt;Cloudant Change listener&lt;/font&gt;&lt;/b&gt;&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="353" y="244.26999999999998" width="150.43" height="69.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-7" value="&lt;b style=&quot;font-size: 13px;&quot;&gt;Cloudant DB&lt;br&gt;&quot;customer owned&quot;&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=29.777768452962235;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
<mxGeometry x="54" y="60" width="156" height="228" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-9" value="Database Name&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;" style="whiteSpace=wrap;html=1;shape=mxgraph.basic.document" parent="1" vertex="1">
<mxGeometry x="87" y="135" width="100" height="133" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-8" value="" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#E7157B;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.documents;" parent="1" vertex="1">
<mxGeometry x="107" y="183.5" width="60" height="73.13" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-10" value="" style="strokeWidth=1;outlineConnect=0;dashed=0;align=center;html=1;fontSize=8;shape=mxgraph.eip.dataChannel;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;" parent="1" vertex="1">
<mxGeometry x="184.5" y="195" width="168.5" height="28.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-13" value="" style="image;sketch=0;aspect=fixed;html=1;points=[];align=center;fontSize=12;image=img/lib/mscae/App_Services.svg;" parent="1" vertex="1">
<mxGeometry x="366.13" y="148.07" width="106.87" height="106.87" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-17" value="" style="html=1;shadow=0;dashed=0;align=center;verticalAlign=middle;shape=mxgraph.arrows2.arrow;dy=0.6;dx=40;notch=0;fillColor=#f8cecc;gradientColor=#ea6b66;strokeColor=#b85450;" parent="1" vertex="1">
<mxGeometry x="495" y="178.32" width="180" height="49.75" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-18" value="Invoke function" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="497.43" y="213" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-19" value="&amp;nbsp;Code Engine Job (Daemon)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="347" y="88" width="150.43" height="53.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-20" value="&lt;span style=&quot;font-size: 13px;&quot;&gt;&lt;b&gt;customer&#39;s function&lt;/b&gt;&lt;/span&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="707" y="232.53" width="150.43" height="69.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-22" value="&amp;nbsp;Code Engine Function" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="697" y="116.46" width="150.43" height="49.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-23" value="" style="shape=image;html=1;verticalAlign=top;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;imageAspect=0;aspect=fixed;image=https://cdn3.iconfinder.com/data/icons/snowish/128x128/mimetypes/application-x-executable.png" parent="1" vertex="1">
<mxGeometry x="725" y="151.63" width="99.75" height="99.75" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<mxfile modified="2023-11-29T08:23:25.923Z" host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0" etag="3NCi9ePOaxr3Jc2k8PcM" version="22.1.4" type="device">
<diagram id="WI9T0HZ2pTsCkuznbFz-" name="Page-1">
<mxGraphModel dx="613" dy="376" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-4" value="Listening Feed&amp;nbsp;&lt;br&gt;on document&amp;nbsp; changes&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="207" y="219.5" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-5" value="&lt;b&gt;&lt;font style=&quot;font-size: 13px;&quot;&gt;Cloudant Change listener&lt;/font&gt;&lt;/b&gt;&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="353" y="244.26999999999998" width="150.43" height="69.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-7" value="&lt;b style=&quot;font-size: 13px;&quot;&gt;Cloudant DB&lt;br&gt;&quot;customer owned&quot;&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=29.777768452962235;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
<mxGeometry x="54" y="60" width="156" height="228" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-9" value="Database Name&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;" style="whiteSpace=wrap;html=1;shape=mxgraph.basic.document" parent="1" vertex="1">
<mxGeometry x="87" y="135" width="100" height="133" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-8" value="" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#E7157B;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.documents;" parent="1" vertex="1">
<mxGeometry x="107" y="183.5" width="60" height="73.13" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-10" value="" style="strokeWidth=1;outlineConnect=0;dashed=0;align=center;html=1;fontSize=8;shape=mxgraph.eip.dataChannel;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;" parent="1" vertex="1">
<mxGeometry x="184.5" y="195" width="168.5" height="28.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-13" value="" style="image;sketch=0;aspect=fixed;html=1;points=[];align=center;fontSize=12;image=img/lib/mscae/App_Services.svg;" parent="1" vertex="1">
<mxGeometry x="366.13" y="148.07" width="106.87" height="106.87" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-17" value="" style="html=1;shadow=0;dashed=0;align=center;verticalAlign=middle;shape=mxgraph.arrows2.arrow;dy=0.6;dx=40;notch=0;fillColor=#f8cecc;gradientColor=#ea6b66;strokeColor=#b85450;" parent="1" vertex="1">
<mxGeometry x="495" y="178.32" width="180" height="49.75" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-18" value="Invoke function" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="497.43" y="213" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-19" value="&amp;nbsp;Code Engine Job (Daemon)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="347" y="88" width="150.43" height="53.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-20" value="&lt;span style=&quot;font-size: 13px;&quot;&gt;&lt;b&gt;customer&#39;s function&lt;/b&gt;&lt;/span&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="707" y="232.53" width="150.43" height="69.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-22" value="&amp;nbsp;Code Engine Function" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="697" y="116.46" width="150.43" height="49.5" as="geometry" />
</mxCell>
<mxCell id="G4HeOA5Qhhuc0p_CGNJW-23" value="" style="shape=image;html=1;verticalAlign=top;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;imageAspect=0;aspect=fixed;image=https://cdn3.iconfinder.com/data/icons/snowish/128x128/mimetypes/application-x-executable.png" parent="1" vertex="1">
<mxGeometry x="725" y="151.63" width="99.75" height="99.75" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cloudant_change_listener/images/log_OK.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading