Skip to content
Snippets Groups Projects
Commit e048a502 authored by Aleksandr Lyapunov's avatar Aleksandr Lyapunov Committed by Aleksandr Lyapunov
Browse files

Implement net.replicaset base watcher API

That's a MVP so only part of the design document is implemented.
Only `watch_leader` method is implemented.

Watch leader is a net.box-like subscription that receives events
only from known leader. If the leader is changed - there's a
short-time probability to receive a notification from the previous
one, but there's a guarantee that once a new leader becomes known
for the net.replicaset - a new update with the new leader will
be called. While the leader is not known (no or more than one RW
instance is known) - the subscription callback is not called.

The usage is quite simple:
```
local net_replicaset = require('internal.net.replicaset')
local rs = net_replicaset.connect(replicaset_name)

-- Define event handling function.
local function func(key, value, instance_name)
    ...
end

-- Watch some_key.
local watcher = rs:watch_leader(some_key, func)

-- Stop watch.
watcher:unregister()
```

Closes #9823

NO_DOC=internal
NO_CHANGELOG=internal
parent 1f27ae04
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment