ewohltman / pool Goto Github PK
View Code? Open in Web Editor NEWGo library that wraps http.Client to provide seamless higher-level connection pooling features
License: MIT License
Go library that wraps http.Client to provide seamless higher-level connection pooling features
License: MIT License
When I use this tool to query a lot of urls,urls will put the result to groutines,finally i find
resp, err := reqPool.PooledClient.Do(req)
will create a a lot of groutines,and memory is fastly Growing。
I wonder that goroutines can use an clientpool?
I don't understand the rateLimiter of PClient ?
Hi,
when i test code with bulk messages (nearly 1lakh), all messages are waiting in pool and getting responses after sometime but i want to get responses concurrently
Note: for single message, i'm getting response immediately
Sample Code:
` package main
import (
"net/http"
"bytes"
"strconv"
"encoding/json"
"github.com/ewohltman/pool"
)
var HTTPClient = &http.Client{}
var PoolClient = pool.NewPClient(HTTPClient,200,250)
func main() {
src:="123"
dest:=1234567890
msg:="dsjfhdkfhjd0"
bst:="http://test/callbackurl"
jsonStr := []byte(`{
"test1": {
"src": "`+src+`",
"dest": `+strconv.Itoa(dest)+`,
"msg": "`+msg+`",
"url": "`+bst+`"
}
"test2": {
"id": 82109
}
}
`)
apiUrl := "https://test/message"
jsonStr1,err:= json.Marshal(jsonStr)
req, err := http.NewRequest("POST", apiUrl, bytes.NewBuffer(jsonStr1))
if err!=nil{
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("requestid", "82109")
req.Header.Set("Authorization", "Bearer Mi84T0FBQUF5S1VHY2YvczU2MnNYTFYxV0RtVDVybjFHRGhqNXc1ZWo1QlpwRmRmUzhZPSIsImFtciI6WyJwd2QiXSwiYXBwaWQiOiIxZjIyNTdmZS1iM2I5LTRkNjctOTNmMi1kYzYzNjdkNjBjODAiLCJhcHBpZGFjciI6IjAiLCJpcGFkZHIiOiI0MC44MS43")
resp, err := PoolClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
}
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.