MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / RequiredClusterShard

Function RequiredClusterShard

server/middleware/middleware.go:116–138  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

114}
115
116func RequiredClusterShard(c *gin.Context) {
117 s, _ := c.MustGet(consts.ContextKeyStore).(*store.ClusterStore)
118 cluster, err := s.GetCluster(c, c.Param("namespace"), c.Param("cluster"))
119 if err != nil {
120 helper.ResponseError(c, err)
121 return
122 }
123
124 shardIndex, err := strconv.Atoi(c.Param("shard"))
125 if err != nil {
126 helper.ResponseBadRequest(c, err)
127 return
128 }
129 shard, err := cluster.GetShard(shardIndex)
130 if err != nil {
131 helper.ResponseError(c, err)
132 return
133 }
134
135 c.Set(consts.ContextKeyCluster, cluster)
136 c.Set(consts.ContextKeyClusterShard, shard)
137 c.Next()
138}
139
140func RequiredRaftEngine(c *gin.Context) {
141 storage, _ := c.MustGet(consts.ContextKeyStore).(*store.ClusterStore)

Callers 3

TestNodeBasicsFunction · 0.92
TestShardBasicsFunction · 0.92
TestClusterFailoverFunction · 0.92

Calls 5

ResponseErrorFunction · 0.92
ResponseBadRequestFunction · 0.92
GetShardMethod · 0.80
GetClusterMethod · 0.65
SetMethod · 0.65

Tested by 3

TestNodeBasicsFunction · 0.74
TestShardBasicsFunction · 0.74
TestClusterFailoverFunction · 0.74