integrating with http-server

This commit is contained in:
Andy Pan 2018-12-03 10:13:53 +08:00
parent 436e646473
commit 0562353fd9
2 changed files with 4 additions and 4 deletions

View File

@ -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.

View File

@ -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.