mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-17 02:21:04 +00:00
integrating with http-server
This commit is contained in:
parent
436e646473
commit
0562353fd9
@ -119,7 +119,7 @@ type Request struct {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
||||||
request, ok := payload.(Request)
|
request, ok := payload.(*Request)
|
||||||
if !ok {
|
if !ok {
|
||||||
request = Request{Param:[]byte(""), Result: make(chan []byte)}
|
request = Request{Param:[]byte(""), Result: make(chan []byte)}
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
request := Request{Param: param, Result: make(chan []byte)}
|
request := &Request{Param: param, Result: make(chan []byte)}
|
||||||
|
|
||||||
// Throttle the requests with ants pool. This process is asynchronous and
|
// Throttle the requests with ants pool. This process is asynchronous and
|
||||||
// you can receive a result from the channel defined outside.
|
// you can receive a result from the channel defined outside.
|
||||||
|
|||||||
@ -118,7 +118,7 @@ type Request struct {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
pool, _ := ants.NewPoolWithFunc(100, func(payload interface{}) {
|
||||||
request, ok := payload.(Request)
|
request, ok := payload.(*Request)
|
||||||
if !ok {
|
if !ok {
|
||||||
request = Request{Param:[]byte(""), Result: make(chan []byte)}
|
request = Request{Param:[]byte(""), Result: make(chan []byte)}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
request := Request{Param: param, Result: make(chan []byte)}
|
request := &Request{Param: param, Result: make(chan []byte)}
|
||||||
|
|
||||||
// Throttle the requests with ants pool. This process is asynchronous and
|
// Throttle the requests with ants pool. This process is asynchronous and
|
||||||
// you can receive a result from the channel defined outside.
|
// you can receive a result from the channel defined outside.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user