代码拉取完成,页面将自动刷新
package httpClient
import (
"sync"
)
type HttpClientMultiple struct {
clients []*HttpClient
}
// New New 实例化:批量请求对象
func (HttpClientMultiple) New() *HttpClientMultiple {
return &HttpClientMultiple{}
}
// Add 添加httpClient对象
func (receiver *HttpClientMultiple) Add(hc *HttpClient) *HttpClientMultiple {
receiver.clients = append(receiver.clients, hc)
return receiver
}
// SetClients 设置httpClient对象
func (receiver *HttpClientMultiple) SetClients(clients []*HttpClient) *HttpClientMultiple {
receiver.clients = clients
return receiver
}
// Send 批量发送
func (receiver *HttpClientMultiple) Send() *HttpClientMultiple {
if len(receiver.clients) > 0 {
var wg sync.WaitGroup
wg.Add(len(receiver.clients))
for _, client := range receiver.clients {
go func(client *HttpClient) {
defer wg.Done()
client.Send()
}(client)
}
wg.Wait()
}
return receiver
}
// GetClients 获取链接池
func (receiver *HttpClientMultiple) GetClients() []*HttpClient {
return receiver.clients
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。