MCPcopy Index your code
hub / github.com/koding/kite / Add

Method Add

kontrol/etcd.go:102–138  ·  view source on GitHub ↗
(k *protocol.Kite, v *kontrolprotocol.RegisterValue)

Source from the content-addressed store, hash-verified

100}
101
102func (e *Etcd) Add(k *protocol.Kite, v *kontrolprotocol.RegisterValue) error {
103 etcdKey := KitesPrefix + k.String()
104 etcdIDKey := KitesPrefix + "/" + k.ID
105
106 p, err := json.Marshal(v)
107 if err != nil {
108 return err
109 }
110
111 value := string(p)
112
113 // Set the kite key.
114 // Example "/koding/production/os/0.0.1/sj/kontainer1.sj.koding.com/1234asdf..."
115 _, err = e.client.Set(context.TODO(),
116 etcdKey,
117 value,
118 &etcd.SetOptions{
119 TTL: KeyTTL,
120 PrevExist: etcd.PrevIgnore,
121 },
122 )
123 if err != nil {
124 return err
125 }
126
127 // Also store the the kite.Key Id for easy lookup
128 _, err = e.client.Set(context.TODO(),
129 etcdIDKey,
130 value,
131 &etcd.SetOptions{
132 TTL: KeyTTL,
133 PrevExist: etcd.PrevIgnore,
134 },
135 )
136
137 return err
138}
139
140func (e *Etcd) Update(k *protocol.Kite, v *kontrolprotocol.RegisterValue) error {
141 etcdKey := KitesPrefix + k.String()

Callers 2

UpsertMethod · 0.95
UpdateMethod · 0.95

Calls 2

StringMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected