EVEN MORE POWER
This commit is contained in:
parent
9a5f281239
commit
2fcdc91587
|
@ -34,6 +34,12 @@ func (_ *RequestContext[T]) Do() func(r *RequestContext[T]) *RequestContext[T] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_ *RequestContext[T]) FilterErr() func(r *RequestContext[T]) bool {
|
||||||
|
return func(r *RequestContext[T]) bool {
|
||||||
|
return r.err == nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type someResult struct {
|
type someResult struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
|
@ -47,9 +53,7 @@ func main() {
|
||||||
req: *r,
|
req: *r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results := lambda.Filter(parallel.Map(requests, requests[0].Do(), 4), func(r *RequestContext[someResult]) bool {
|
results := lambda.Filter(parallel.Map(requests, requests[0].Do(), 4), requests[0].FilterErr())
|
||||||
return r.err == nil
|
|
||||||
})
|
|
||||||
for _, v := range results {
|
for _, v := range results {
|
||||||
log.Printf("%s", v)
|
log.Printf("%s", v)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue