MCPcopy Index your code
hub / github.com/coder/coder / pingReplica

Function pingReplica

enterprise/wsproxy/wsproxy.go:589–606  ·  view source on GitHub ↗

pingReplica pings a replica over it's internal relay address to ensure it's reachable and alive for health purposes. It will try to ping the replica twice if the first ping fails, with a short delay between attempts.

(ctx context.Context, client http.Client, replica codersdk.Replica)

Source from the content-addressed store, hash-verified

587// reachable and alive for health purposes. It will try to ping the replica
588// twice if the first ping fails, with a short delay between attempts.
589func pingReplica(ctx context.Context, client http.Client, replica codersdk.Replica) error {
590 const attempts = 2
591 var err error
592 for i := 0; i < attempts; i++ {
593 err = replicasync.PingPeerReplica(ctx, client, replica.RelayAddress)
594 if err == nil {
595 return nil
596 }
597 if i < attempts-1 {
598 select {
599 case <-ctx.Done():
600 return ctx.Err()
601 case <-time.After(1 * time.Second):
602 }
603 }
604 }
605 return err
606}
607
608func (s *Server) handleRegisterFailure(err error) {
609 if s.ctx.Err() != nil {

Callers 1

pingSiblingReplicasFunction · 0.85

Calls 3

PingPeerReplicaFunction · 0.92
ErrMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected