Skip to content

Commit

Permalink
Revert "Merge pull request #512 from rqlite/ping_conn"
Browse files Browse the repository at this point in the history
This reverts commit c1a07a3, reversing
changes made to d16be5f.
  • Loading branch information
otoolep committed Jun 3, 2018
1 parent 97525ee commit 0e9d9b4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
22 changes: 0 additions & 22 deletions http/handlers.go
Expand Up @@ -13,25 +13,6 @@ import (
// Handler pattern contained here created by github.com/Merovius
// See https://blog.merovius.de/2017/06/18/how-not-to-use-an-http-router.html

type pingHandler struct{}

func (h *pingHandler) Handler(connID uint64, s *Service) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
stats.Add(numPings, 1)

if !s.CheckRequestPerm(r, PermConnections) {
w.WriteHeader(http.StatusUnauthorized)
return
}

if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
s.handlePing(connID, w, r)
})
}

type executeHandler struct{}

func (h *executeHandler) Handler(connID uint64, s *Service) http.Handler {
Expand Down Expand Up @@ -111,7 +92,6 @@ func (h *loadHandler) Handler(s *Service) http.Handler {
type connectionsHandler struct {
executeH executeHandler
queryH queryHandler
pingH pingHandler
}

func (h *connectionsHandler) Handler(s *Service) http.Handler {
Expand Down Expand Up @@ -152,8 +132,6 @@ func (h *connectionsHandler) Handler(s *Service) http.Handler {
h.executeH.Handler(id, s).ServeHTTP(w, r)
case "query":
h.queryH.Handler(id, s).ServeHTTP(w, r)
case "ping":
h.pingH.Handler(id, s).ServeHTTP(w, r)
default:
w.WriteHeader(http.StatusNotFound)
}
Expand Down
14 changes: 0 additions & 14 deletions http/service.go
Expand Up @@ -118,7 +118,6 @@ var stats *expvar.Map

const (
numConnections = "connections"
numPings = "pings"
numExecutions = "executions"
numQueries = "queries"
numBackups = "backups"
Expand Down Expand Up @@ -536,19 +535,6 @@ func (s *Service) handleStatus(w http.ResponseWriter, r *http.Request) {
}
}

// handlePing marks a connection as still in use, without executing any SQL command.
func (s *Service) handlePing(connID uint64, w http.ResponseWriter, r *http.Request) {
if connID == defaultConnID {
return
}
c, ok := s.store.Connection(connID)
if !ok {
http.Error(w, "connection not found", http.StatusNotFound)
return
}
c.SetLastUsedNow()
}

// handleExecute handles queries that modify the database.
func (s *Service) handleExecute(connID uint64, w http.ResponseWriter, r *http.Request) {
isAtomic, err := isAtomic(r)
Expand Down
3 changes: 0 additions & 3 deletions http/service_test.go
Expand Up @@ -347,7 +347,6 @@ func Test_401Routes_NoBasicAuth(t *testing.T) {
"/db/backup",
"/db/load",
"/db/connections",
"/db/connections/1234/pings",
"/join",
"/delete",
"/status",
Expand Down Expand Up @@ -389,7 +388,6 @@ func Test_401Routes_BasicAuthBadPassword(t *testing.T) {
"/db/backup",
"/db/load",
"/db/connections",
"/db/connections/1234/ping",
"/join",
"/status",
"/debug/vars",
Expand Down Expand Up @@ -436,7 +434,6 @@ func Test_401Routes_BasicAuthBadPerm(t *testing.T) {
"/db/backup",
"/db/load",
"/db/connections",
"/db/connections/1234/ping",
"/join",
"/status",
"/debug/vars",
Expand Down

0 comments on commit 0e9d9b4

Please sign in to comment.