-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstance.go
More file actions
25 lines (23 loc) · 906 Bytes
/
Copy pathinstance.go
File metadata and controls
25 lines (23 loc) · 906 Bytes
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
package wind
// Instance describes a single service instance registered with (or discovered
// from) a service registry. It carries the information a client needs to
// connect: identity, version, network endpoints and arbitrary metadata.
//
// App.Instance returns a populated [*Instance] for the caller to use with
// their chosen registry implementation in go-wind-plugins.
type Instance struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Endpoints []string `json:"endpoints"`
Metadata map[string]string `json:"metadata"`
}
// FirstEndpoint returns the first endpoint URL or an empty string if the
// instance has no endpoints. This is a convenience for the common
// single-endpoint case.
func (i *Instance) FirstEndpoint() string {
if len(i.Endpoints) > 0 {
return i.Endpoints[0]
}
return ""
}