-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (46 loc) · 1.05 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"context"
"github.com/brunats/govid/formatters"
"github.com/brunats/govid/internal/cli"
"github.com/brunats/govid/processing"
"github.com/brunats/govid/providers"
"github.com/brunats/govid/providers/nowsh"
)
func main() {
cli.Parse()
// Register providers
providers.Register(nowsh.New())
ctx := ctx()
// Request providers
for _, provider := range providers.Providers() {
go provider.Request(ctx)
}
// Awaiting completion
for _, provider := range providers.Providers() {
provider.Wait()
}
// Merge results
var dataProviders []*providers.Data
for _, provider := range providers.Providers() {
dataProviders = append(dataProviders, provider.Response()...)
}
// Processing
for _, data := range dataProviders {
processing.Processing(data)
}
// Results
formatter := formatters.Selection(ctx)
formatter.Presentation(dataProviders)
}
func ctx() context.Context {
return context.WithValue(
context.WithValue(
context.Background(),
cli.CountryKey,
cli.Country(),
),
cli.FormatKey,
cli.Format(),
)
}