/
discovery.go
90 lines (76 loc) · 2.06 KB
/
discovery.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
//
// Last.Backend LLC CONFIDENTIAL
// __________________
//
// [2014] - [2018] Last.Backend LLC
// All Rights Reserved.
//
// NOTICE: All information contained herein is, and remains
// the property of Last.Backend LLC and its suppliers,
// if any. The intellectual and technical concepts contained
// herein are proprietary to Last.Backend LLC
// and its suppliers and may be covered by Russian Federation and Foreign Patents,
// patents in process, and are protected by trade secret or copyright law.
// Dissemination of this information or reproduction of this material
// is strictly forbidden unless prior written permission is obtained
// from Last.Backend LLC.
//
package types
import "fmt"
// swagger:ignore
type Discovery struct {
Runtime
Meta DiscoveryMeta `json:"meta"`
Status DiscoveryStatus `json:"status"`
Spec DiscoverySpec `json:"spec"`
}
type DiscoveryList struct {
Runtime
Items []*Discovery
}
type DiscoveryMap struct {
Runtime
Items map[string]*Discovery
}
// swagger:ignore
type DiscoveryMeta struct {
Meta
Node string `json:"node"`
}
// swagger:model types_discovery_info
type DiscoveryInfo struct {
Version string `json:"version"`
Hostname string `json:"hostname"`
Architecture string `json:"architecture"`
OSName string `json:"os_name"`
OSType string `json:"os_type"`
// RewriteIP - need to set true if you want to use an external ip
ExternalIP string `json:"external_ip"`
InternalIP string `json:"internal_ip"`
}
// swagger:model types_discovery_status
type DiscoveryStatus struct {
IP string `json:"ip"`
Port uint16 `json:"port"`
Ready bool `json:"ready"`
Online bool `json:"online"`
}
// swagger:ignore
type DiscoverySpec struct {
}
func (n *Discovery) SelfLink() string {
if n.Meta.SelfLink == "" {
n.Meta.SelfLink = fmt.Sprintf("%s", n.Meta.Name)
}
return n.Meta.SelfLink
}
func NewDiscoveryList() *DiscoveryList {
dm := new(DiscoveryList)
dm.Items = make([]*Discovery, 0)
return dm
}
func NewDiscoveryMap() *DiscoveryMap {
dm := new(DiscoveryMap)
dm.Items = make(map[string]*Discovery)
return dm
}