The image on the right side shows Nikola Tesla observing a complicated electrical device. Waiting for push notifications.
An addon to tesla-microservice that allows to observe values in Apache ZooKeeper using zookeeper-clj. The values observed are by default transformed to a UTF8-String. Optionally a transform-function can be specified by the user. Write access is not included at the moment.
This addon can be used to to fetch data from zookeeper using the (observe! self key)
function. The result is stored in an in memory map and a listener is registered with zookeeper.
If the data in zookeeper is changed, the new value will be fetched asynchronously and updated in memory.
All subsequent observations of the same key hit the value cached in memory. Thus the data can be used from the application with high frequency (e.g. for every database access) without any performance penalty.
Since version 0.2.0 you can also set data using the (set! self key val)
function.
See tesla-examples/zookeeper-example for a usage example.
The configuration property zookeeper.connect
contains a zookeeper connection string (optionally including a chroot).
If you want to use multiple zookeeper-components in your system, which connect to different zookeepers you have to initialize your components with a name:
(new-zkobserver <zk-name>)
The name is then used to read the zookeeper-connect-string from your config:
<zk-name>.zookeeper.connect
Version 0.1.2
and above of this library is compatible with Versions 0.1.15
and above of tesla-microservice.
Instances of ZKObserver
have a dependency on the :config
-component of tesla-microservice.
Christian Stamm, Kai Brandes, Felix Bechstein, Ralf Sigmund, Florian Weyandt, Torsten Mangner
Apache License