-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
43 lines (38 loc) · 904 Bytes
/
application.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
package processor
import (
"github.com/margostino/anfield/configuration"
"github.com/margostino/anfield/db"
"github.com/margostino/anfield/domain"
"github.com/margostino/anfield/kafka"
"github.com/margostino/anfield/scrapper"
"sync"
"time"
)
type Channels struct {
commentary map[string]chan *domain.Commentary
matchDate map[string]chan time.Time
lineups map[string]chan *domain.Lineups
}
type App struct {
kafka *kafka.Producer
db *db.Database
scrapper *scrapper.Scrapper
configuration *configuration.Configuration
channels *Channels
waitGroups sync.Map
logger *Logger
}
func (a App) Start() error {
var urls []string
if a.configuration.HasPredefinedEvents() {
urls = a.getUrlsByConfig()
} else {
urls = a.getUrlsByScrapper()
}
return a.Process(urls)
}
func (a App) Close() {
a.db.Close()
a.kafka.Close()
a.scrapper.Close()
}