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

Method replicas

enterprise/coderd/replicas.go:22–34  ·  view source on GitHub ↗

replicas returns the number of replicas that are active in Coder. @Summary Get active replicas @ID get-active-replicas @Security CoderSessionToken @Produce json @Tags Enterprise @Success 200 {array} codersdk.Replica @Router /api/v2/replicas [get]

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

20// @Success 200 {array} codersdk.Replica
21// @Router /api/v2/replicas [get]
22func (api *API) replicas(rw http.ResponseWriter, r *http.Request) {
23 if !api.AGPL.Authorize(r, policy.ActionRead, rbac.ResourceReplicas) {
24 httpapi.ResourceNotFound(rw)
25 return
26 }
27
28 replicas := api.replicaManager.AllPrimary()
29 res := make([]codersdk.Replica, 0, len(replicas))
30 for _, replica := range replicas {
31 res = append(res, convertReplica(replica))
32 }
33 httpapi.Write(r.Context(), rw, http.StatusOK, res)
34}
35
36func convertReplica(replica database.Replica) codersdk.Replica {
37 return codersdk.Replica{

Callers

nothing calls this directly

Calls 6

ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
convertReplicaFunction · 0.85
AllPrimaryMethod · 0.80
AuthorizeMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected