tonysun83 commented on a change in pull request #1432: Support callback module
data provider
URL: https://github.com/apache/couchdb/pull/1432#discussion_r202256855
##########
File path: src/couch_epi/README.md
##########
@@ -65,6 +66,38 @@ There are also additional functions to get the same data in
various formats
- `couch_epi:keys(Handle)` - returns list of configured keys
- `couch_epi:subscribers(Handle)` - return list of known subscribers
+The difference between `static_module` and `callback_module` providers is in
how
+couch_epi detects the changes. `static_module` is designed for the cases when
you
+have your data hardcoded in the module. For example you might have the
following:
+
+```
+-export([data/0]).
+
+data() ->
+ [
+ {[complex, key, 2], [
+ {type, counter},
+ {desc, bar}
+ ]},
+ {[complex, key, 1], [
+ {type, counter},
+ {desc, updated_foo}
+ ]}
+ ].
+```
+
+The changes are detected by relying on `vsn` module attribute. Therefore we
+would notice the change only when data source module is recompiled.
+
+The `callback_module` provider uses the return value from `data/0` to detect
+changes and it is useful for cases when the data term is constructed
dynamically.
+For example to cache values of CouchDB config one could use the following:
+
+```
+-export([data/0]).
+data() ->
+ config:get("dreyfus").
Review comment:
change this to ```config:get("dreyfus", "foo")```?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services