KiteFromKey returns a *protocol.Kite from an etcd key. etcd key is like: "/kites/devrim/env/mathworker/1/localhost/tardis.local/id"
()
| 67 | // KiteFromKey returns a *protocol.Kite from an etcd key. etcd key is like: |
| 68 | // "/kites/devrim/env/mathworker/1/localhost/tardis.local/id" |
| 69 | func (n *Node) KiteFromKey() (*protocol.Kite, error) { |
| 70 | // TODO replace "kites" with KitesPrefix constant |
| 71 | fields := strings.Split(strings.TrimPrefix(n.Node.Key, "/"), "/") |
| 72 | if len(fields) != 8 || (len(fields) > 0 && fields[0] != "kites") { |
| 73 | return nil, fmt.Errorf("kontrol: invalid kite %s", n.Node.Key) |
| 74 | } |
| 75 | |
| 76 | return &protocol.Kite{ |
| 77 | Username: fields[1], |
| 78 | Environment: fields[2], |
| 79 | Name: fields[3], |
| 80 | Version: fields[4], |
| 81 | Region: fields[5], |
| 82 | Hostname: fields[6], |
| 83 | ID: fields[7], |
| 84 | }, nil |
| 85 | } |
| 86 | |
| 87 | // Value returns the value associated with the current node. |
| 88 | func (n *Node) Value() (kontrolprotocol.RegisterValue, error) { |
no outgoing calls
no test coverage detected