// Start the gossip layer g := gossip.New(context.Background(), gossip.TestStoreOptions()) defer g.Stop(context.Background()) // Gossip the metadata about a new table metadata := &MyTableMetadata{Name: "my_table", ColumnNames: []string{"col1", "col2"}, ...} g.GossipTables(context.Background(), metadata)
// Start the gossip layer g := gossip.New(context.Background(), gossip.TestStoreOptions()) defer g.Stop(context.Background()) // Watch for changes in node liveness g.RegisterCallback(gossip.MakePrefixPattern(gossip.KeyNodeLivenessPrefix), func(_ string, newValue roachpb.Value) { var liveness livenesspb.NodeLiveness if err := newValue.GetProto(&liveness); err != nil { // handle error } if liveness.Liveness != livenesspb.Alive { // node is dead } })Overall, the Gossip package provides a flexible way to exchange information between nodes in a distributed system. Its implementation is designed to be efficient and scalable, making it suitable for use in large clusters with many nodes.