👔 Make the just added service status up & running
This commit is contained in:
parent
488793a2dc
commit
69012b9cc3
@ -2,14 +2,15 @@ package directory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/internal/kv"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/rs/zerolog/log"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
const ServiceInfoKvPrefix = "nexus.service/"
|
||||
@ -22,6 +23,7 @@ func AddServiceInstance(in *ServiceInstance) error {
|
||||
}
|
||||
|
||||
_, err = kv.Kv.Put(context.Background(), key, string(data))
|
||||
SetServiceStatus(in.Type, true)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,10 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var statusOfServices = make(map[string]bool)
|
||||
var statusLock sync.Mutex
|
||||
var (
|
||||
statusOfServices = make(map[string]bool)
|
||||
statusLock sync.Mutex
|
||||
)
|
||||
|
||||
func GetServiceStatus() map[string]bool {
|
||||
out := make(map[string]bool)
|
||||
@ -25,6 +27,12 @@ func GetServiceStatus() map[string]bool {
|
||||
return out
|
||||
}
|
||||
|
||||
func SetServiceStatus(t string, status bool) {
|
||||
statusLock.Lock()
|
||||
defer statusLock.Unlock()
|
||||
statusOfServices[t] = status
|
||||
}
|
||||
|
||||
func ValidateServices() {
|
||||
statusLock.Lock()
|
||||
defer statusLock.Unlock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user