-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
56 lines (47 loc) · 1.04 KB
/
server.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
// Copyright 2016 F. Alan Jones. All rights reserved.
// Use of this source code is governed by a Mozilla
// license that can be found in the LICENSE file.
package ketch
import (
"net/http"
"github.com/satori/go.uuid"
"github.com/watercraft/ketch/api"
)
type ServerMgr struct {
ResourceMgr
}
func (k *Ketch) installServerMgr() {
m := &ServerMgr{
ResourceMgr: ResourceMgr{
myType: api.TypeServer,
assignIDs: false,
named: true,
persist: false,
},
}
m.Init(k, m)
}
func (m *ServerMgr) InitResource(in api.Resource) (error, int) {
return nil, http.StatusOK
}
func (m *ServerMgr) GetList() api.ResourceList {
nodes := m.k.list.Members()
var list api.ResourceList
for _, node := range nodes {
server := &api.Server{
Common: api.Common{
Name: node.Name,
ID: uuid.FromBytesOrNil(node.Meta),
},
Endpoint: api.Endpoint{
Addr: node.Addr,
Port: node.Port,
},
}
list = append(list, server)
}
return list
}
func (m *ServerMgr) UpdateAfterLoad(resource api.Resource) bool {
return false
}