forked from vulcand/vulcand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
etcd.go
786 lines (693 loc) · 18.7 KB
/
etcd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
// package etcdng contains the implementation of the Etcd-backed engine, where all vulcand properties are implemented as directories or keys.
// this engine is capable of watching the changes and generating events.
package etcdng
import (
"encoding/json"
"fmt"
"regexp"
"strings"
"time"
"github.com/mailgun/vulcand/Godeps/_workspace/src/github.com/mailgun/go-etcd/etcd"
"github.com/mailgun/vulcand/Godeps/_workspace/src/github.com/mailgun/log"
"github.com/mailgun/vulcand/engine"
"github.com/mailgun/vulcand/plugin"
"github.com/mailgun/vulcand/secret"
)
type ng struct {
nodes []string
registry *plugin.Registry
etcdKey string
client *etcd.Client
cancelC chan bool
stopC chan bool
options Options
}
type Options struct {
EtcdConsistency string
Box *secret.Box
}
func New(nodes []string, etcdKey string, registry *plugin.Registry, options Options) (engine.Engine, error) {
n := &ng{
nodes: nodes,
registry: registry,
etcdKey: etcdKey,
cancelC: make(chan bool, 1),
stopC: make(chan bool, 1),
options: setDefaults(options),
}
if err := n.reconnect(); err != nil {
return nil, err
}
return n, nil
}
func (s *ng) Close() {
if s.client != nil {
s.client.Close()
}
}
func (n *ng) reconnect() error {
n.Close()
client := etcd.NewClient(n.nodes)
if err := client.SetConsistency(n.options.EtcdConsistency); err != nil {
return err
}
n.client = client
return nil
}
func (n *ng) GetRegistry() *plugin.Registry {
return n.registry
}
func (n *ng) GetHosts() ([]engine.Host, error) {
hosts := []engine.Host{}
vals, err := n.getDirs(n.etcdKey, "hosts")
if err != nil {
return nil, err
}
for _, hostKey := range vals {
host, err := n.GetHost(engine.HostKey{suffix(hostKey)})
if err != nil {
return nil, err
}
hosts = append(hosts, *host)
}
return hosts, nil
}
func (n *ng) GetHost(key engine.HostKey) (*engine.Host, error) {
hostKey := n.path("hosts", key.Name, "host")
var host *host
err := n.getJSONVal(hostKey, &host)
if err != nil {
return nil, err
}
var keyPair *engine.KeyPair
if len(host.Settings.KeyPair) != 0 {
if err := n.openSealedJSONVal(host.Settings.KeyPair, &keyPair); err != nil {
return nil, err
}
}
return engine.NewHost(key.Name, engine.HostSettings{Default: host.Settings.Default, KeyPair: keyPair})
}
func (n *ng) UpsertHost(h engine.Host) error {
if h.Name == "" {
return &engine.InvalidFormatError{Message: "hostname can not be empty"}
}
hostKey := n.path("hosts", h.Name, "host")
val := host{
Name: h.Name,
Settings: hostSettings{
Default: h.Settings.Default,
},
}
if h.Settings.KeyPair != nil {
bytes, err := n.sealJSONVal(h.Settings.KeyPair)
if err != nil {
return err
}
val.Settings.KeyPair = bytes
}
return n.setJSONVal(hostKey, val, noTTL)
}
func (n *ng) DeleteHost(key engine.HostKey) error {
if key.Name == "" {
return &engine.InvalidFormatError{Message: "hostname can not be empty"}
}
return n.deleteKey(n.path("hosts", key.Name))
}
func (n *ng) GetListeners() ([]engine.Listener, error) {
ls := []engine.Listener{}
vals, err := n.getVals(n.etcdKey, "listeners")
if err != nil {
return nil, err
}
for _, p := range vals {
l, err := n.GetListener(engine.ListenerKey{Id: suffix(p.Key)})
if err != nil {
return nil, err
}
ls = append(ls, *l)
}
return ls, nil
}
func (n *ng) GetListener(key engine.ListenerKey) (*engine.Listener, error) {
bytes, err := n.getVal(n.path("listeners", key.Id))
if err != nil {
return nil, err
}
l, err := engine.ListenerFromJSON([]byte(bytes), key.Id)
if err != nil {
return nil, err
}
return l, nil
}
func (n *ng) UpsertListener(listener engine.Listener) error {
if listener.Id == "" {
return &engine.InvalidFormatError{Message: "listener id can not be empty"}
}
return n.setJSONVal(n.path("listeners", listener.Id), listener, noTTL)
}
func (s *ng) DeleteListener(key engine.ListenerKey) error {
if key.Id == "" {
return &engine.InvalidFormatError{Message: "listener id can not be empty"}
}
return s.deleteKey(s.path("listeners", key.Id))
}
func (n *ng) UpsertFrontend(f engine.Frontend, ttl time.Duration) error {
if f.Id == "" {
return &engine.InvalidFormatError{Message: "frontend id can not be empty"}
}
if _, err := n.GetBackend(engine.BackendKey{Id: f.BackendId}); err != nil {
return err
}
if err := n.setJSONVal(n.path("frontends", f.Id, "frontend"), f, noTTL); err != nil {
return err
}
if ttl == 0 {
return nil
}
_, err := n.client.UpdateDir(n.path("frontends", f.Id), uint64(ttl/time.Second))
return convertErr(err)
}
func (n *ng) GetFrontends() ([]engine.Frontend, error) {
fs := []engine.Frontend{}
vals, err := n.getDirs(n.etcdKey, "frontends")
if err != nil {
return nil, err
}
for _, fPath := range vals {
f, err := n.GetFrontend(engine.FrontendKey{suffix(fPath)})
if err != nil {
return nil, err
}
fs = append(fs, *f)
}
return fs, nil
}
func (n *ng) GetFrontend(key engine.FrontendKey) (*engine.Frontend, error) {
frontendKey := n.path("frontends", key.Id, "frontend")
bytes, err := n.getVal(frontendKey)
if err != nil {
return nil, err
}
return engine.FrontendFromJSON([]byte(bytes), key.Id)
}
func (n *ng) DeleteFrontend(fk engine.FrontendKey) error {
if fk.Id == "" {
return &engine.InvalidFormatError{Message: "frontend id can not be empty"}
}
return n.deleteKey(n.path("frontends", fk.Id))
}
func (n *ng) GetBackends() ([]engine.Backend, error) {
backends := []engine.Backend{}
ups, err := n.getDirs(n.etcdKey, "backends")
if err != nil {
return nil, err
}
for _, backendKey := range ups {
b, err := n.GetBackend(engine.BackendKey{Id: suffix(backendKey)})
if err != nil {
return nil, err
}
backends = append(backends, *b)
}
return backends, nil
}
func (n *ng) GetBackend(key engine.BackendKey) (*engine.Backend, error) {
backendKey := n.path("backends", key.Id, "backend")
bytes, err := n.getVal(backendKey)
if err != nil {
return nil, err
}
return engine.BackendFromJSON([]byte(bytes), key.Id)
}
func (n *ng) UpsertBackend(b engine.Backend) error {
if b.Id == "" {
return &engine.InvalidFormatError{Message: "backend id can not be empty"}
}
return n.setJSONVal(n.path("backends", b.Id, "backend"), b, noTTL)
}
func (n *ng) DeleteBackend(bk engine.BackendKey) error {
if bk.Id == "" {
return &engine.InvalidFormatError{Message: "backend id can not be empty"}
}
fs, err := n.backendUsedBy(bk)
if err != nil {
return err
}
if len(fs) != 0 {
return fmt.Errorf("can not delete backend '%v', it is in use by %s", bk, fs)
}
_, err = n.client.Delete(n.path("backends", bk.Id), true)
return convertErr(err)
}
func (n *ng) GetMiddlewares(fk engine.FrontendKey) ([]engine.Middleware, error) {
ms := []engine.Middleware{}
keys, err := n.getVals(n.etcdKey, "frontends", fk.Id, "middlewares")
if err != nil {
return nil, err
}
for _, p := range keys {
m, err := n.GetMiddleware(engine.MiddlewareKey{Id: suffix(p.Key), FrontendKey: fk})
if err != nil {
return nil, err
}
ms = append(ms, *m)
}
return ms, nil
}
func (n *ng) GetMiddleware(key engine.MiddlewareKey) (*engine.Middleware, error) {
mKey := n.path("frontends", key.FrontendKey.Id, "middlewares", key.Id)
bytes, err := n.getVal(mKey)
if err != nil {
return nil, err
}
return engine.MiddlewareFromJSON([]byte(bytes), n.registry.GetSpec, key.Id)
}
func (n *ng) UpsertMiddleware(fk engine.FrontendKey, m engine.Middleware, ttl time.Duration) error {
if fk.Id == "" || m.Id == "" {
return &engine.InvalidFormatError{Message: "frontend id and middleware id can not be empty"}
}
if _, err := n.GetFrontend(fk); err != nil {
return err
}
return n.setJSONVal(n.path("frontends", fk.Id, "middlewares", m.Id), m, ttl)
}
func (n *ng) DeleteMiddleware(mk engine.MiddlewareKey) error {
if mk.FrontendKey.Id == "" || mk.Id == "" {
return &engine.InvalidFormatError{Message: "frontend id and middleware id can not be empty"}
}
return n.deleteKey(n.path("frontends", mk.FrontendKey.Id, "middlewares", mk.Id))
}
func (n *ng) UpsertServer(bk engine.BackendKey, s engine.Server, ttl time.Duration) error {
if s.Id == "" || bk.Id == "" {
return &engine.InvalidFormatError{Message: "backend id and server id can not be empty"}
}
if _, err := n.GetBackend(bk); err != nil {
return err
}
return n.setJSONVal(n.path("backends", bk.Id, "servers", s.Id), s, ttl)
}
func (n *ng) GetServers(bk engine.BackendKey) ([]engine.Server, error) {
svs := []engine.Server{}
keys, err := n.getVals(n.etcdKey, "backends", bk.Id, "servers")
if err != nil {
return nil, err
}
for _, p := range keys {
srv, err := n.GetServer(engine.ServerKey{Id: suffix(p.Key), BackendKey: bk})
if err != nil {
return nil, err
}
svs = append(svs, *srv)
}
return svs, nil
}
func (n *ng) GetServer(sk engine.ServerKey) (*engine.Server, error) {
bytes, err := n.getVal(n.path("backends", sk.BackendKey.Id, "servers", sk.Id))
if err != nil {
return nil, err
}
return engine.ServerFromJSON([]byte(bytes), sk.Id)
}
func (n *ng) DeleteServer(sk engine.ServerKey) error {
if sk.Id == "" || sk.BackendKey.Id == "" {
return &engine.InvalidFormatError{Message: "backend id and server id can not be empty"}
}
return n.deleteKey(n.path("backends", sk.BackendKey.Id, "servers", sk.Id))
}
func (n *ng) openSealedJSONVal(bytes []byte, val interface{}) error {
if n.options.Box == nil {
return fmt.Errorf("need secretbox to open sealed data")
}
sv, err := secret.SealedValueFromJSON([]byte(bytes))
if err != nil {
return err
}
unsealed, err := n.options.Box.Open(sv)
if err != nil {
return err
}
return json.Unmarshal(unsealed, val)
}
func (n *ng) sealJSONVal(val interface{}) ([]byte, error) {
if n.options.Box == nil {
return nil, fmt.Errorf("this backend does not support encryption")
}
bytes, err := json.Marshal(val)
if err != nil {
return nil, err
}
v, err := n.options.Box.Seal(bytes)
if err != nil {
return nil, err
}
return secret.SealedValueToJSON(v)
}
func (n *ng) backendUsedBy(bk engine.BackendKey) ([]engine.Frontend, error) {
fs, err := n.GetFrontends()
if err != nil {
return nil, err
}
for _, f := range fs {
if f.BackendId == bk.Id {
fs = append(fs, f)
}
}
return fs, nil
}
// Subscribe watches etcd changes and generates structured events telling vulcand to add or delete frontends, hosts etc.
// It is a blocking function.
func (n *ng) Subscribe(changes chan interface{}, cancelC chan bool) error {
// This index helps us to get changes in sequence, as they were performed by clients.
waitIndex := uint64(0)
for {
response, err := n.client.Watch(n.etcdKey, waitIndex, true, nil, cancelC)
if err != nil {
switch err {
case etcd.ErrWatchStoppedByUser:
log.Infof("Stop watching: graceful shutdown")
return nil
default:
log.Errorf("unexpected error: %s, stop watching", err)
return err
}
}
waitIndex = response.Node.ModifiedIndex + 1
log.Infof("%s", responseToString(response))
change, err := n.parseChange(response)
if err != nil {
log.Warningf("Ignore '%s', error: %s", responseToString(response), err)
continue
}
if change != nil {
log.Infof("%v", change)
select {
case changes <- change:
case <-cancelC:
return nil
}
}
}
}
type MatcherFn func(*etcd.Response) (interface{}, error)
// Dispatches etcd key changes changes to the etcd to the matching functions
func (s *ng) parseChange(response *etcd.Response) (interface{}, error) {
matchers := []MatcherFn{
// Host updates
s.parseHostChange,
// Listener updates
s.parseListenerChange,
// Frontend updates
s.parseFrontendChange,
s.parseFrontendMiddlewareChange,
// Backend updates
s.parseBackendChange,
s.parseBackendServerChange,
}
for _, matcher := range matchers {
a, err := matcher(response)
if a != nil || err != nil {
return a, err
}
}
return nil, nil
}
func (n *ng) parseHostChange(r *etcd.Response) (interface{}, error) {
out := regexp.MustCompile("/hosts/([^/]+)(?:/host)?$").FindStringSubmatch(r.Node.Key)
if len(out) != 2 {
return nil, nil
}
hostname := out[1]
switch r.Action {
case createA, setA:
host, err := n.GetHost(engine.HostKey{hostname})
if err != nil {
return nil, err
}
return &engine.HostUpserted{
Host: *host,
}, nil
case deleteA, expireA:
return &engine.HostDeleted{
HostKey: engine.HostKey{hostname},
}, nil
}
return nil, fmt.Errorf("unsupported action for host: %s", r.Action)
}
func (n *ng) parseListenerChange(r *etcd.Response) (interface{}, error) {
out := regexp.MustCompile("/listeners/([^/]+)").FindStringSubmatch(r.Node.Key)
if len(out) != 2 {
return nil, nil
}
key := engine.ListenerKey{Id: out[1]}
switch r.Action {
case createA, setA:
l, err := n.GetListener(key)
if err != nil {
return nil, err
}
return &engine.ListenerUpserted{
Listener: *l,
}, nil
case deleteA, expireA:
return &engine.ListenerDeleted{
ListenerKey: key,
}, nil
}
return nil, fmt.Errorf("unsupported action on the listener: %s", r.Action)
}
func (n *ng) parseFrontendChange(r *etcd.Response) (interface{}, error) {
out := regexp.MustCompile("/frontends/([^/]+)(?:/frontend)?$").FindStringSubmatch(r.Node.Key)
if len(out) != 2 {
return nil, nil
}
key := engine.FrontendKey{Id: out[1]}
switch r.Action {
case createA, setA:
f, err := n.GetFrontend(key)
if err != nil {
return nil, err
}
return &engine.FrontendUpserted{
Frontend: *f,
}, nil
case deleteA, expireA:
return &engine.FrontendDeleted{
FrontendKey: key,
}, nil
case updateA: // this happens when we set TTL on a dir, ignore as there's no action needed from us
return nil, nil
}
return nil, fmt.Errorf("unsupported action on the frontend: %v %v", r.Node.Key, r.Action)
}
func (s *ng) parseFrontendMiddlewareChange(r *etcd.Response) (interface{}, error) {
out := regexp.MustCompile("/frontends/([^/]+)/middlewares/([^/]+)$").FindStringSubmatch(r.Node.Key)
if len(out) != 3 {
return nil, nil
}
fk := engine.FrontendKey{Id: out[1]}
mk := engine.MiddlewareKey{FrontendKey: fk, Id: out[2]}
switch r.Action {
case createA, setA:
m, err := s.GetMiddleware(mk)
if err != nil {
return nil, err
}
return &engine.MiddlewareUpserted{
FrontendKey: fk,
Middleware: *m,
}, nil
case deleteA, expireA:
return &engine.MiddlewareDeleted{
MiddlewareKey: mk,
}, nil
}
return nil, fmt.Errorf("unsupported action on the rate: %s", r.Action)
}
func (n *ng) parseBackendChange(r *etcd.Response) (interface{}, error) {
out := regexp.MustCompile("/backends/([^/]+)(?:/backend)?$").FindStringSubmatch(r.Node.Key)
if len(out) != 2 {
return nil, nil
}
bk := engine.BackendKey{Id: out[1]}
switch r.Action {
case createA, setA:
b, err := n.GetBackend(bk)
if err != nil {
return nil, err
}
return &engine.BackendUpserted{
Backend: *b,
}, nil
case deleteA, expireA:
return &engine.BackendDeleted{
BackendKey: bk,
}, nil
}
return nil, fmt.Errorf("unsupported node action: %s", r.Action)
}
func (n *ng) parseBackendServerChange(r *etcd.Response) (interface{}, error) {
out := regexp.MustCompile("/backends/([^/]+)/servers/([^/]+)$").FindStringSubmatch(r.Node.Key)
if len(out) != 3 {
return nil, nil
}
sk := engine.ServerKey{BackendKey: engine.BackendKey{Id: out[1]}, Id: out[2]}
switch r.Action {
case setA, createA:
srv, err := n.GetServer(sk)
if err != nil {
return nil, err
}
return &engine.ServerUpserted{
BackendKey: sk.BackendKey,
Server: *srv,
}, nil
case deleteA, expireA:
return &engine.ServerDeleted{
ServerKey: sk,
}, nil
case cswapA: // ignore compare and swap attempts
return nil, nil
}
return nil, fmt.Errorf("unsupported action on the server: %s", r.Action)
}
func (n ng) path(keys ...string) string {
return strings.Join(append([]string{n.etcdKey}, keys...), "/")
}
func (n *ng) setJSONVal(key string, v interface{}, ttl time.Duration) error {
bytes, err := json.Marshal(v)
if err != nil {
return err
}
return n.setVal(key, bytes, ttl)
}
func (n *ng) setVal(key string, val []byte, ttl time.Duration) error {
_, err := n.client.Set(key, string(val), uint64(ttl/time.Second))
return convertErr(err)
}
func (n *ng) getJSONVal(key string, in interface{}) error {
val, err := n.getVal(key)
if err != nil {
return err
}
return json.Unmarshal([]byte(val), in)
}
func (n *ng) getVal(key string) (string, error) {
response, err := n.client.Get(key, false, false)
if err != nil {
return "", convertErr(err)
}
if isDir(response.Node) {
return "", &engine.NotFoundError{Message: fmt.Sprintf("missing key: %s", key)}
}
return response.Node.Value, nil
}
func (n *ng) getDirs(keys ...string) ([]string, error) {
var out []string
response, err := n.client.Get(strings.Join(keys, "/"), true, true)
if err != nil {
if notFound(err) {
return out, nil
}
return nil, err
}
if response == nil || !isDir(response.Node) {
return out, nil
}
for _, srvNode := range response.Node.Nodes {
if isDir(srvNode) {
out = append(out, srvNode.Key)
}
}
return out, nil
}
func (n *ng) getVals(keys ...string) ([]Pair, error) {
var out []Pair
response, err := n.client.Get(strings.Join(keys, "/"), true, true)
if err != nil {
if notFound(err) {
return out, nil
}
return nil, err
}
if !isDir(response.Node) {
return out, nil
}
for _, srvNode := range response.Node.Nodes {
if !isDir(srvNode) {
out = append(out, Pair{srvNode.Key, srvNode.Value})
}
}
return out, nil
}
func (n *ng) checkKeyExists(key string) error {
_, err := n.client.Get(key, false, false)
return convertErr(err)
}
func (n *ng) deleteKey(key string) error {
_, err := n.client.Delete(key, true)
return convertErr(err)
}
type Pair struct {
Key string
Val string
}
func suffix(key string) string {
vals := strings.Split(key, "/")
return vals[len(vals)-1]
}
func join(keys ...string) string {
return strings.Join(keys, "/")
}
func notFound(e error) bool {
err, ok := e.(*etcd.EtcdError)
return ok && err.ErrorCode == 100
}
func convertErr(e error) error {
if e == nil {
return nil
}
switch err := e.(type) {
case *etcd.EtcdError:
if err.ErrorCode == 100 {
return &engine.NotFoundError{Message: err.Error()}
}
if err.ErrorCode == 105 {
return &engine.AlreadyExistsError{Message: err.Error()}
}
}
return e
}
func isDir(n *etcd.Node) bool {
return n != nil && n.Dir == true
}
func isNotFoundError(err error) bool {
_, ok := err.(*engine.NotFoundError)
return ok
}
const encryptionSecretBox = "secretbox.v1"
func responseToString(r *etcd.Response) string {
return fmt.Sprintf("%s %s %d", r.Action, r.Node.Key, r.EtcdIndex)
}
const (
createA = "create"
setA = "set"
deleteA = "delete"
expireA = "expire"
updateA = "update"
cswapA = "compareAndSwap"
noTTL = 0
)
func setDefaults(o Options) Options {
if o.EtcdConsistency == "" {
o.EtcdConsistency = etcd.STRONG_CONSISTENCY
}
return o
}
type host struct {
Name string
Settings hostSettings
}
type hostSettings struct {
Default bool
KeyPair []byte
}