feat: first version.

This commit is contained in:
tx7do
2023-05-21 10:04:15 +08:00
parent 3656de9753
commit 785443dd84
51 changed files with 15841 additions and 0 deletions

30
service_info.go Normal file
View File

@@ -0,0 +1,30 @@
package bootstrap
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
}