MCPcopy
hub / github.com/Terry-Mao/goim / startPush

Function startPush

benchmarks/multi_push/main.go:95–121  ·  view source on GitHub ↗
(b, e int)

Source from the content-addressed store, hash-verified

93}
94
95func startPush(b, e int) {
96 l := make([]int64, 0, e-b)
97 for i := b; i < e; i++ {
98 l = append(l, int64(i))
99 }
100 msg := &pushsBodyMsg{Msg: json.RawMessage(testContent), UserIds: l}
101 body, err := json.Marshal(msg)
102 if err != nil {
103 panic(err)
104 }
105 for {
106 resp, err := httpPost(fmt.Sprintf("http://%s/goim/push/mids=%d", os.Args[3], b), "application/x-www-form-urlencoded", bytes.NewBuffer(body))
107 if err != nil {
108 lg.Printf("post error (%v)", err)
109 continue
110 }
111
112 body, err := ioutil.ReadAll(resp.Body)
113 if err != nil {
114 lg.Printf("post error (%v)", err)
115 return
116 }
117 resp.Body.Close()
118
119 lg.Printf("response %s", string(body))
120 }
121}
122
123func httpPost(url string, contentType string, body io.Reader) (*http.Response, error) {
124 req, err := http.NewRequest("POST", url, body)

Callers 1

mainFunction · 0.70

Calls 4

PrintfMethod · 0.80
httpPostFunction · 0.70
CloseMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected