MCPcopy Create free account
hub / github.com/coder/coder / peerUpdate

Method peerUpdate

enterprise/tailnet/pgcoord.go:1080–1098  ·  view source on GitHub ↗

peerUpdate is work scheduled in response to a new peer->binding. We need to find out all the other peers that share a tunnel with the indicated peer, and then schedule a mapping update on each, so that they can find out about the new binding.

(peers []uuid.UUID)

Source from the content-addressed store, hash-verified

1078// other peers that share a tunnel with the indicated peer, and then schedule a mapping update on
1079// each, so that they can find out about the new binding.
1080func (q *querier) peerUpdate(peers []uuid.UUID) error {
1081 q.logger.Debug(q.ctx, "batch querying peers that share tunnels",
1082 slog.F("num_peers", len(peers)))
1083 others, err := q.store.GetTailnetTunnelPeerIDsBatch(q.ctx, peers)
1084 if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
1085 return xerrors.Errorf("get tunnel peer IDs batch: %w", err)
1086 }
1087 q.logger.Debug(q.ctx, "batch queried tunnel peers",
1088 slog.F("num_results", len(others)))
1089 q.mu.Lock()
1090 for _, other := range others {
1091 mk := mKey(other.PeerID)
1092 if _, ok := q.mappers[mk]; ok {
1093 q.mappingQ.enqueue(mk)
1094 }
1095 }
1096 q.mu.Unlock()
1097 return nil
1098}
1099
1100// mappingQuery queries the database for all the mappings that the given peers should know about,
1101// that is, all the peers that it shares a tunnel with and their current node mappings (if they

Callers 1

peerUpdateWorkerMethod · 0.95

Calls 7

mKeyTypeAlias · 0.85
enqueueMethod · 0.80
IsMethod · 0.45
ErrorfMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected