Created
April 24, 2018 11:01
-
-
Save mjs/42d3dee1a388c3b541f14a0f026e1bbe to your computer and use it in GitHub Desktop.
A fake influxd that is slow to respond
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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