🔊 Verbose event broadcasting

This commit is contained in:
LittleSheep 2024-11-23 12:18:35 +08:00
parent 3236ffdebc
commit 73a8d11c7e
2 changed files with 10 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"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"
@ -115,6 +116,11 @@ func BroadcastEvent(event string, data any) error {
return err
}
log.Debug().
Int("destinations", len(resp.Kvs)).
Str("event", event).
Msg("Broadcasting event from internal...")
for _, val := range resp.Kvs {
var instance ServiceInstance
if err := json.Unmarshal(val.Value, &instance); err != nil {

View File

@ -102,6 +102,10 @@ func (v *ServiceRpcServer) RemoveService(ctx context.Context, request *proto.Rem
func (v *ServiceRpcServer) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*proto.EventResponse, error) {
services := ListServiceInstance()
log.Debug().
Int("destinations", len(services)).
Str("event", in.GetEvent()).
Msg("Broadcasting event...")
for _, service := range services {
conn, err := service.GetGrpcConn()
if err != nil {