Last active
August 29, 2015 14:23
-
-
Save nrshrivatsan/35d5ca1342981ee6e593 to your computer and use it in GitHub Desktop.
Minor Load script on ETCD
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" | |
"net/http" | |
"io/ioutil" | |
"bytes" | |
"strconv" | |
"math/rand" | |
) | |
func hitETCD(value string) { | |
//ETCD Keys endpoint | |
endpoint := "http://127.0.0.1:2379/v2/keys/" | |
var jsonStr = []byte(value) | |
//HTTP POST method | |
req, err := http.NewRequest("POST", endpoint+strconv.Itoa(rand.Intn(200)), bytes.NewBuffer(jsonStr)) | |
client := &http.Client{} | |
resp, err := client.Do(req) | |
if err != nil { | |
panic(err) | |
} | |
defer resp.Body.Close() | |
fmt.Println("response Status:", resp.Status) | |
fmt.Println("response Headers:", resp.Header) | |
body, _ := ioutil.ReadAll(resp.Body) | |
fmt.Println("response Body:", string(body)) | |
} | |
func main() { | |
// fmt.Println("URL:>", url) | |
limit := 900000 | |
for i := 0; i < limit; i++ { | |
//Spawning an independent goroutine to make HTTP get calls | |
// go hitETCD(`{"value":"Hello World this is ETCD load script"}`) | |
hitETCD(`{"value":"New value"+strconv.Itoa(i)}`) | |
} | |
} |
Hit http://localhost:2379/v2/keys
to view the keys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE - Need to make go channels and MAX PROC changes if need be.