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

Method cache

enterprise/tailnet/pgcoord.go:373–393  ·  view source on GitHub ↗
(update tunnel)

Source from the content-addressed store, hash-verified

371}
372
373func (t *tunneler) cache(update tunnel) {
374 t.mu.Lock()
375 defer t.mu.Unlock()
376 if update.active {
377 if _, ok := t.latest[update.src]; !ok {
378 t.latest[update.src] = map[uuid.UUID]tunnel{}
379 }
380 t.latest[update.src][update.dst] = update
381 } else {
382 // If inactive and dst is nil, it means clean up all tunnels.
383 if update.dst == uuid.Nil {
384 delete(t.latest, update.src)
385 } else {
386 delete(t.latest[update.src], update.dst)
387 // clean up the tunnel map if all the tunnels are gone.
388 if len(t.latest[update.src]) == 0 {
389 delete(t.latest, update.src)
390 }
391 }
392 }
393}
394
395// retrieveBinding gets the latest tunnel for a key.
396func (t *tunneler) retrieve(k tKey) tunnel {

Callers 1

handleMethod · 0.95

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected