Skip to content

Instantly share code, notes, and snippets.

@mjs
Created April 24, 2018 11:01
Show Gist options
  • Save mjs/42d3dee1a388c3b541f14a0f026e1bbe to your computer and use it in GitHub Desktop.
Save mjs/42d3dee1a388c3b541f14a0f026e1bbe to your computer and use it in GitHub Desktop.
A fake influxd that is slow to respond
package main
import (
"fmt"
"log"
"net/http"
"time"
)
import "flag"
var port = flag.Int("port", 8087, "port to listen on")
var delay = flag.Duration("delay", 30*time.Second, "time to wait before responding to write requests")
func main() {
flag.Parse()
http.HandleFunc("/write", func(w http.ResponseWriter, _ *http.Request) {
time.Sleep(*delay)
w.WriteHeader(http.StatusNoContent)
})
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment