discovery client check status (#375)

pull/325/head
Felix Hao 5 years ago committed by GitHub
parent f3c2ec2624
commit 049dcfc2f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      pkg/naming/discovery/discovery.go
  2. 2
      pkg/naming/naming.go

@ -374,7 +374,11 @@ func (d *Discovery) register(ctx context.Context, ins *naming.Instance) (err err
params.Add("addrs", addr)
}
params.Set("version", ins.Version)
params.Set("status", _statusUP)
if ins.Status == 0 {
params.Set("status", _statusUP)
} else {
params.Set("status", strconv.FormatInt(ins.Status, 10))
}
params.Set("metadata", string(metadata))
if err = d.httpClient.Post(ctx, uri, "", params, &res); err != nil {
d.switchNode()
@ -471,7 +475,7 @@ func (d *Discovery) set(ctx context.Context, ins *naming.Instance) (err error) {
params := d.newParams(conf)
params.Set("appid", ins.AppID)
params.Set("version", ins.Version)
params.Set("status", _statusUP)
params.Set("status", strconv.FormatInt(ins.Status, 10))
if ins.Metadata != nil {
var metadata []byte
if metadata, err = json.Marshal(ins.Metadata); err != nil {

@ -35,6 +35,8 @@ type Instance struct {
// Metadata is the information associated with Addr, which may be used
// to make load balancing decision.
Metadata map[string]string `json:"metadata"`
// Status instance status, eg: 1UP 2Waiting
Status int64 `json:"status"`
}
// Resolver resolve naming service

Loading…
Cancel
Save