summaryrefslogtreecommitdiffstats
path: root/dcaeapplib/README.md
diff options
context:
space:
mode:
authorAndrew Gauld <ag1282@att.com>2018-02-16 12:22:23 -0500
committerAndrew Gauld <ag1282@att.com>2018-02-19 16:17:09 -0500
commit8c776e128cf557490db59525b29a608e30e637be (patch)
treeb2fbf6962758ed40e587ca9ab498823e5bc13eb8 /dcaeapplib/README.md
parentcc30700ae44acf28f6ce2106cb275c4ba0f0af1b (diff)
Initial version of dcaeapplib package
Change-Id: I54db903e59a67eb4423cacf10ea957d148b4f853 Issue-ID: DCAEGEN2-354 Signed-off-by: Andrew Gauld <ag1282@att.com>
Diffstat (limited to 'dcaeapplib/README.md')
-rw-r--r--dcaeapplib/README.md64
1 files changed, 64 insertions, 0 deletions
diff --git a/dcaeapplib/README.md b/dcaeapplib/README.md
new file mode 100644
index 0000000..81fd825
--- /dev/null
+++ b/dcaeapplib/README.md
@@ -0,0 +1,64 @@
+# dcaeapplib
+
+Library for building DCAE analytics applications
+
+# Example use:
+
+```
+
+class myapp:
+ def __init__(self):
+ # get the environment, and register callbacks for health checks and
+ # configuration changes
+ self.dcaeenv = dcaeapplib.DcaeEnv(healthCB=self.isHealthy, reconfigCB=self.reconfigure)
+ # simulate a configuration change - we want the initial configuration
+ self.reconfigure()
+ # start the environment (to wait for health checks and config changes)
+ self.dcaeenv.start()
+ # begin processing loop
+ while True:
+ if self.configchanged:
+ # fetch the updated configuration
+ self.conig = self.dcaeenv.getconfig()
+ self.configchanged = False
+ # do any setup relevant to the configuration
+ data = self.dcaeenv.getdata('myinputstream')
+ # Data is a UTF-8 string, 'myinputstream' is this application's logical
+ # name for this (one of potentially several) data sources.
+ # Can also specify timeout_ms and limit as arguments.
+ # timeout_ms (default 15,000) is the maximum time getdata() will block
+ # limit is the maximum number of records retrieved at a time.
+ # If no data is retrieved (timeout) the return will be None.
+ if data is not None:
+ # do something to process the data
+ self.dcaeenv.senddata('myoutputstream', 'somepartitionkey', data)
+ # data is a string, 'myoutputstream' is the application's logical
+ # name for this (one of potentially several) data sinks.
+ # somepartitionkey is used, by Kafka, to assign the data to a partition.
+
+ def isHealthy(self):
+ # return the health of the application (True/False)
+ return True
+
+ def reconfigure(self):
+ # Do whatever needs to be done to handle a configuration change
+ self.configchanged = True
+```
+
+# Environment Variables
+
+This library uses the onap-dcae-cbs-docker-client library to fetch
+configuration. That library relies on the HOSTNAME and CONSUL_HOST
+environment variables to find the configuration.
+
+This library provides an HTTP interface for health checks. By default this
+listens on port 80 but can be overridden to use another port by setting the
+DCAEPORT environment variable. The HTTP interface supports getting 2 URLs:
+/healthcheck, which will return a status of 202 (Accepted) for healthy,
+and 503 (Service Unavailable) for unhealthy, and /reconfigure, which triggers
+the library to check for updated configuration.
+
+# Console Commands
+
+This library provides a single console command "reconfigure.sh" which
+performs an HTTP get of the /reconfigure URL