mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
examples: fix news_fetcher.v
This commit is contained in:
parent
ef758a76dd
commit
115ecdd60a
1 changed files with 3 additions and 2 deletions
|
@ -30,12 +30,14 @@ fn main() {
|
||||||
println('failed to fetch data from /v0/topstories.json')
|
println('failed to fetch data from /v0/topstories.json')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println(resp.body)
|
// TODO bring back once json2 can decode []int
|
||||||
/*
|
/*
|
||||||
ids := json2.decode[[]int](resp.body) or {
|
ids := json2.decode[[]int](resp.body) or {
|
||||||
println('failed to decode topstories.json $err')
|
println('failed to decode topstories.json $err')
|
||||||
return
|
return
|
||||||
}#[0..10]
|
}#[0..10]
|
||||||
|
*/
|
||||||
|
ids := resp.body.replace_once('[', '').replace_once(']', '').split(',').map(it.int())
|
||||||
mut fetcher_pool := pool.new_pool_processor(
|
mut fetcher_pool := pool.new_pool_processor(
|
||||||
callback: worker_fetch
|
callback: worker_fetch
|
||||||
)
|
)
|
||||||
|
@ -45,5 +47,4 @@ fn main() {
|
||||||
// by setting the VJOBS environment variable too.
|
// by setting the VJOBS environment variable too.
|
||||||
// fetcher_pool.set_max_jobs( 4 )
|
// fetcher_pool.set_max_jobs( 4 )
|
||||||
fetcher_pool.work_on_items(ids)
|
fetcher_pool.work_on_items(ids)
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue