StackStorm/st2 — pull request #934 by Kami (2014-12-26 19:31:47+00:00)
Title: [WIP] Allow sensors to store and retrive arbitrary data from a datastore

This pull request adds `get_value`, `set_value` and `delete_value` methods to the sensor service.

Using those methods, sensor can store and retrieve data in the datastore. This comes hany in many cases when sensor needs to persist temporary data.

A good example of that is Twitter sensor (https://github.com/StackStorm/st2contrib/blob/master/packs/twitter/sensors/twitter_search_sensor.py#L56) - we want to persist "last_id", so if the sensor service crashes or is restarted, we don't spam channel with duplicate messages which have already been posted.

As part of this pull request I've also changed datastore operations from "CRUD" to "get", "set" and "delete" - https://gist.github.com/Kami/024d268956d576a2a3b9

The reason for that is that datastore is presented as a key-value store, mostly behaves as a key-value store, but it doesn't expose key-value store like operations which makes it confusing.

TODO:

[ ] Generate temporary long-lived access token for each sensor instance (we will need to do a similar thing for Mistral workflows)
[ ] Update affected tests, client code and docs
[ ] Finish it up