Skip to content

Commit 8163358

Browse files
authored
feat: add service type to Peer struct and update validation in handlePatchInstance
1 parent 01345d2 commit 8163358

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/master.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ type Meta struct {
129129
// Peer 对端信息
130130
type Peer struct {
131131
Alias string `json:"alias"` // 服务别名
132+
Type string `json:"type"` // 服务类型
132133
SID string `json:"sid"` // 服务ID
133134
IID string `json:"iid"` // 实例ID
134135
MID string `json:"mid"` // 主控ID
@@ -1207,6 +1208,10 @@ func (m *Master) handlePatchInstance(w http.ResponseWriter, r *http.Request, id
12071208
httpError(w, fmt.Sprintf("Meta peer.alias exceeds maximum length %d", maxValueLen), http.StatusBadRequest)
12081209
return
12091210
}
1211+
if len(reqData.Meta.Peer.Type) > maxValueLen {
1212+
httpError(w, fmt.Sprintf("Meta peer.type exceeds maximum length %d", maxValueLen), http.StatusBadRequest)
1213+
return
1214+
}
12101215
if len(reqData.Meta.Peer.SID) > maxValueLen {
12111216
httpError(w, fmt.Sprintf("Meta peer.sid exceeds maximum length %d", maxValueLen), http.StatusBadRequest)
12121217
return
@@ -2055,6 +2060,7 @@ func (m *Master) generateOpenAPISpec() string {
20552060
"type": "object",
20562061
"properties": {
20572062
"alias": {"type": "string", "description": "Service alias"},
2063+
"type": {"type": "string", "description": "Service type"},
20582064
"sid": {"type": "string", "description": "Service ID"},
20592065
"iid": {"type": "string", "description": "Instance ID"},
20602066
"mid": {"type": "string", "description": "Master ID"}

0 commit comments

Comments
 (0)