diggy
(Dgraph Bot)
October 9, 2019, 1:38pm
1
Moved from GitHub badger/1075
Posted by jarifibrahim :
The subscribe API
// Subscribe can be used to watch key changes for the given key prefixes.
// At least one prefix should be passed, or an error will be returned.
// You can use an empty prefix to monitor all changes to the DB.
// This function blocks until the given context is done or an error occurs.
// The given function will be called with a new KVList containing the modified keys and the
// corresponding values.
func (db *DB) Subscribe(ctx context.Context, cb func(kv *KVList), prefixes ...[]byte) error {
was added in badger via Add new API Subscribe to listen on update for the specified prefix (#… · dgraph-io/badger@26128a7 · GitHub but there is no documentation about it. We should also have an example of how to use the Subscribe API.
badger/db_test.go at f50343ff404d8198df6dc83755ec2eab863d5ff2 · dgraph-io/badger · GitHub can be used for inspiration.
diggy
(Dgraph Bot)
November 18, 2019, 9:45pm
3
kaustubhmallik commented :
@jarifibrahim is this still available to grab?
diggy
(Dgraph Bot)
November 18, 2019, 11:12pm
4
kaustubhmallik commented :
@jarifibrahim By documentation, you mean adding explanations and usage (code example) in the README directly, correct? As far as I have understood, this feature enables you to add a post-update behaviour (callback function) for certain set of keys, configured using the key’s prefix.
Also, as you said, the example can be directly quoted from the test you have written.