flynn/strowger — pull request #18 by miracle2k (2014-03-14 12:31:48+00:00)
Title: Complete work on etcd sync

Based on my previous comment (https://github.com/flynn/strowger/pull/4#issuecomment-37291917), here is an attempt to implement the sync with etcd.

It's 90% complete, but since I've had to make a growing number of design choices, I thought it best to check with you guys.

Crucially, what I am doing here, somewhat independently from the sync feature, is making the external API a simple wrapper around etcd - it does not touch the internal data structures. Those are updated only via the update stream from etcd.

This is so to not run the internal-apply code twice (I only realize now that it might have been possible to detect an update originating from the self instance via isLeader() or by looking at the etcd indices).

Relying on the update stream has a certain simple beauty to it, it makes sure the sync-code has to work properly even when a single strowger instance is used, which seems quite positive, though it raises a question for me:

Errors like "domain already exists" - can we implement error handling like that on top of the etcd interface, or should the API provide simple "set and overwrite only" functionality?