🔊 Verbose event broadcasting
This commit is contained in:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user