Download goalert/devtools/simpleproxy/roundrobin.go from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 281 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/goalert/devtools/simpleproxy/roundrobin.go
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/goalert/devtools/simpleproxy/roundrobin.go
-
curl -L -o roundrobin.go https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/goalert/devtools/simpleproxy/roundrobin.go
281 Bytes
| package main | |
| import ( | |
| "net/http" | |
| "sync" | |
| ) | |
| type RR struct { | |
| h []http.Handler | |
| n int | |
| mx sync.Mutex | |
| } | |
| func (r *RR) ServeHTTP(w http.ResponseWriter, req *http.Request) { | |
| r.mx.Lock() | |
| handler := r.h[r.n] | |
| r.n = (r.n + 1) % len(r.h) | |
| r.mx.Unlock() | |
| handler.ServeHTTP(w, req) | |
| } | |