forked from yefengzhichen/nacos-sdk-go-v1x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
136 lines (120 loc) · 4.45 KB
/
service.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
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package model
import (
"time"
)
const (
StateRunning = iota
StateShutdown
)
type Instance struct {
Valid bool `json:"valid"`
Marked bool `json:"marked"`
InstanceId string `json:"instanceId"`
Port uint64 `json:"port"`
Ip string `json:"ip"`
Weight float64 `json:"weight"`
Metadata map[string]string `json:"metadata"`
ClusterName string `json:"clusterName"`
ServiceName string `json:"serviceName"`
Enable bool `json:"enabled"`
Healthy bool `json:"healthy"`
Ephemeral bool `json:"ephemeral"`
}
type Service struct {
Dom string `json:"dom"`
CacheMillis uint64 `json:"cacheMillis"`
UseSpecifiedURL bool `json:"useSpecifiedUrl"`
Hosts []Instance `json:"hosts"`
Checksum string `json:"checksum"`
LastRefTime uint64 `json:"lastRefTime"`
Env string `json:"env"`
Clusters string `json:"clusters"`
Metadata map[string]string `json:"metadata"`
Name string `json:"name"`
}
type ServiceDetail struct {
Service ServiceInfo `json:"service"`
Clusters []Cluster `json:"clusters"`
}
type ServiceInfo struct {
App string `json:"app"`
Group string `json:"group"`
HealthCheckMode string `json:"healthCheckMode"`
Metadata map[string]string `json:"metadata"`
Name string `json:"name"`
ProtectThreshold float64 `json:"protectThreshold"`
Selector ServiceSelector `json:"selector"`
}
type ServiceSelector struct {
Selector string
}
type Cluster struct {
ServiceName string `json:"serviceName"`
Name string `json:"name"`
HealthyChecker ClusterHealthChecker `json:"healthyChecker"`
DefaultPort uint64 `json:"defaultPort"`
DefaultCheckPort uint64 `json:"defaultCheckPort"`
UseIPPort4Check bool `json:"useIpPort4Check"`
Metadata map[string]string `json:"metadata"`
}
type ClusterHealthChecker struct {
Type string `json:"type"`
}
type SubscribeService struct {
ClusterName string `json:"clusterName"`
Enable bool `json:"enable"`
InstanceId string `json:"instanceId"`
Ip string `json:"ip"`
Metadata map[string]string `json:"metadata"`
Port uint64 `json:"port"`
ServiceName string `json:"serviceName"`
Valid bool `json:"valid"`
Weight float64 `json:"weight"`
Healthy bool `json:"healthy"`
}
type BeatInfo struct {
Ip string `json:"ip"`
Port uint64 `json:"port"`
Weight float64 `json:"weight"`
ServiceName string `json:"serviceName"`
Cluster string `json:"cluster"`
Metadata map[string]string `json:"metadata"`
Scheduled bool `json:"scheduled"`
Period time.Duration `json:"-"`
State int32 `json:"-"`
}
type ExpressionSelector struct {
Type string `json:"type"`
Expression string `json:"expression"`
}
type ServiceList struct {
Count int64 `json:"count"`
Doms []string `json:"doms"`
}
type CatalogService struct {
Name string `json:"name"`
GroupName string `json:"groupName"`
ClusterCount int32 `json:"clusterCount"`
IpCount int32 `json:"ipCount"`
HealthyInstanceCount int32 `json:"healthyInstanceCount"`
TriggerFlag bool `json:"triggerFlag"`
}
type CatalogServiceList struct {
Count string `json:"count"`
ServiceList []*CatalogService `json:"serviceList"`
}