Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepone committed Feb 19, 2020
1 parent 1785a8e commit 7a64173
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ADD . /go/src/github.com/sandeepone/mysql-manticore
RUN cd /go/src/github.com/sandeepone/mysql-manticore \
&& COMMIT_SHA=$(git rev-parse --short HEAD) \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w \
-X main.version=0.2 \
-X main.version=0.3 \
-X main.revision=${COMMIT_SHA}" \
-a -tags netgo -installsuffix netgo -o mysql-manticore cmd/mysql-manticore/main.go

Expand Down
18 changes: 14 additions & 4 deletions river/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (s *stat) run() (err error) {
s.log.Errorf("error creating listener at addr %s: %v", addr, err)
return
}
s.log.Infof("started status http server at %s", addr)
s.log.Infof("Started status http server at %s", addr)

s.lastRowEvent = time.Now()
s.startedAt = time.Now()
Expand All @@ -232,9 +232,10 @@ func (s *stat) run() (err error) {
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))

mux.Handle("/rebuild", handleRebuildRedir())
mux.Handle("/rebuild/sync", handleRebuild(s.r, true))
mux.Handle("/rebuild/async", handleRebuild(s.r, false))
// mux.Handle("/rebuild", handleRebuildRedir())
// mux.Handle("/rebuild/sync", handleRebuild(s.r, true))
// mux.Handle("/rebuild/async", handleRebuild(s.r, false))

mux.Handle("/maint", handleMaint(s.r))
mux.Handle("/wait", handleWaitForGTID(s.r))

Expand Down Expand Up @@ -334,54 +335,63 @@ func handleRebuild(r *River, sync bool) http.HandlerFunc {
func handleMaint(r *River) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")

if req.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
w.Write([]byte("unexpected method\n"))
return
}

index := req.URL.Query().Get("index")
if index == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("index not specified\n"))
return
}

dataSource, exists := r.c.DataSource[index]
if !exists {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(fmt.Sprintf("index %s not found\n", index)))
return
}

err := r.sphinxService.CheckIndexForOptimize(index, dataSource.Parts)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(errors.ErrorStack(err) + "\n"))
return
}

w.WriteHeader(http.StatusNoContent)
})
}

func handleWaitForGTID(r *River) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")

if req.Method != http.MethodPost {
w.WriteHeader(http.StatusMethodNotAllowed)
w.Write([]byte("unexpected method\n"))
return
}

req.ParseForm()
gtidString := req.PostForm.Get("gtid")
if gtidString == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("gtid not specified\n"))
return
}

gtid, err := mysql.ParseGTIDSet(r.c.Flavor, gtidString)
if err != nil {
w.WriteHeader(http.StatusUnprocessableEntity)
w.Write([]byte("invalid gtid specified\n"))
return
}

timeoutString := req.PostForm.Get("timeout")
var timerC <-chan time.Time
if timeoutString != "" {
Expand Down

0 comments on commit 7a64173

Please sign in to comment.