github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/internal/cluster/gossip/delegate.go (about) 1 package gossipCluster 2 3 import ( 4 "hash/crc64" 5 6 "github.com/ronaksoft/rony/internal/msg" 7 "go.uber.org/zap" 8 "google.golang.org/protobuf/proto" 9 ) 10 11 /* 12 Creation Time: 2021 - Jan - 01 13 Created by: (ehsan) 14 Maintainers: 15 1. Ehsan N. Moosa (E2) 16 Auditor: Ehsan N. Moosa (E2) 17 Copyright Ronak Software Group 2020 18 */ 19 20 type clusterDelegate struct { 21 c *Cluster 22 } 23 24 func (d *clusterDelegate) nodeData() []byte { 25 n := &msg.EdgeNode{ 26 ServerID: d.c.localServerID, 27 Hash: crc64.Checksum(d.c.localServerID, crcTable), 28 ReplicaSet: d.c.cfg.ReplicaSet, 29 GatewayAddr: d.c.localGatewayAddr, 30 TunnelAddr: d.c.localTunnelAddr, 31 } 32 b, _ := proto.Marshal(n) 33 34 return b 35 } 36 37 func (d *clusterDelegate) NodeMeta(limit int) []byte { 38 b := d.nodeData() 39 if len(b) > limit { 40 d.c.cfg.Logger.Warn("Too Large Meta", zap.ByteString("ServerID", d.c.localServerID)) 41 42 return nil 43 } 44 45 return b 46 } 47 48 func (d *clusterDelegate) NotifyMsg(_ []byte) {} 49 50 func (d *clusterDelegate) GetBroadcasts(_, _ int) [][]byte { 51 return nil 52 } 53 54 func (d *clusterDelegate) LocalState(_ bool) []byte { 55 return nil 56 } 57 58 func (d *clusterDelegate) MergeRemoteState(_ []byte, _ bool) { 59 }