feat: refactor.
This commit is contained in:
30
config/service_info.go
Normal file
30
config/service_info.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package config
|
||||
|
||||
import "os"
|
||||
|
||||
type ServiceInfo struct {
|
||||
Name string
|
||||
Version string
|
||||
Id string
|
||||
Metadata map[string]string
|
||||
}
|
||||
|
||||
func NewServiceInfo(name, version, id string) *ServiceInfo {
|
||||
if id == "" {
|
||||
id, _ = os.Hostname()
|
||||
}
|
||||
return &ServiceInfo{
|
||||
Name: name,
|
||||
Version: version,
|
||||
Id: id,
|
||||
Metadata: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServiceInfo) GetInstanceId() string {
|
||||
return s.Id + "." + s.Name
|
||||
}
|
||||
|
||||
func (s *ServiceInfo) SetMataData(k, v string) {
|
||||
s.Metadata[k] = v
|
||||
}
|
||||
Reference in New Issue
Block a user