Skip to content

Commit

Permalink
RHINENG-10032: extend repack admin API with columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Dugowitch committed Sep 6, 2024
1 parent 409d1ca commit 9cea067
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manager/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func InitAdmin(app *gin.Engine, enableTurnpikeAuth bool) {
api.GET("/sessions", admin.GetActiveSessionsHandler)
api.GET("/sessions/:search", admin.GetActiveSessionsHandler)
api.DELETE("/sessions/:pid", admin.TerminateSessionHandler)
api.GET("/repack/:table_name", admin.RepackHandler)
api.GET("/repack/:table_name/*columns", admin.RepackHandler)

pprof := api.Group("/pprof")
pprof.GET("/evaluator_upload/:param", admin.GetEvaluatorUploadPprof)
Expand Down
10 changes: 6 additions & 4 deletions turnpike/controllers/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,22 @@ func TerminateSessionHandler(c *gin.Context) {
// @Accept json
// @Produce json
// @Param table_name path string true "Table to reindex"
// @Param columns path string false "Comma-separated columns to cluster by"
// @Success 200 {object} string
// @Failure 409 {object} string
// @Failure 500 {object} map[string]interface{}
// @Router /repack/{table_name} [get]
// @Router /repack/{table_name}/{columns} [get]
func RepackHandler(c *gin.Context) {
utils.LogInfo("manual repack called...")

param := c.Param("table_name")
if param == "" {
tableName := c.Param("table_name")
if tableName == "" {
c.JSON(http.StatusBadRequest, utils.ErrorResponse{Error: "table_name param not found"})
return
}
columns := c.Param("columns")

err := repack.Repack(param)
err := repack.Repack(tableName, columns[1:]) // skip the initial '/'
if err != nil {
utils.LogError("err", err.Error(), "manual repack call failed")
c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
Expand Down

0 comments on commit 9cea067

Please sign in to comment.