-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
92 lines (74 loc) · 2.35 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import (
"github.com/hinha/sometor/provider/api"
"github.com/hinha/sometor/provider/command"
"github.com/hinha/sometor/provider/infrastructure"
"github.com/hinha/sometor/provider/scheduler"
"github.com/hinha/sometor/provider/socket"
"github.com/hinha/sometor/provider/socket_stream"
"github.com/hinha/sometor/provider/socmed"
"github.com/hinha/sometor/provider/user"
"github.com/subosito/gotenv"
"os"
"strconv"
"time"
)
func init() {
_ = os.Setenv("TZ", "Asia/Jakarta")
loc, _ := time.LoadLocation(os.Getenv("TZ"))
time.Local = loc
}
func main() {
//CONSUMER_KEY = 'ROaXlUvhpKXxTDVTyXH3tKyOk'
//CONSUMER_SECRET = 'guuG1z0QLtUG6Aea28Hlub0hOgW5Ps0jh66u1YdSNhbUvyAP16'
//ACCESS_TOKEN = '1113019452319137794-2pn37DkirO4vcqDMa6lrIZaP5zCYtO'
//ACCESS_TOKEN_SECRET = 'GLhC7XyNmZKmvbjenhUFRmFMhN07Ce7JYAcsOybEtjD1T'
_ = gotenv.Load()
cmd := command.Fabricate()
// Infra
infra, err := infrastructure.Fabricate()
if err != nil {
panic(err)
}
defer infra.Close()
db, err := infra.DB()
if err != nil {
panic(err)
}
celery := infra.Celery()
s3Management, err := infra.S3()
if err != nil {
panic(err)
}
if err := infra.FabricateCommand(cmd); err != nil {
panic(err)
}
// User
userFabricate := user.FabricateStream(db)
keywordStream := user.FabricateStreamKeyword(db)
// API
portAPI, _ := strconv.Atoi(os.Getenv("PORT_API"))
apiEngine := api.Fabricate(portAPI)
apiEngine.FabricateCommand(cmd)
keywordStreamAPI := socmed.FabricateKeyword(keywordStream)
keywordStreamAPI.FabricateAPI(apiEngine)
// Socket
portSocket, _ := strconv.Atoi(os.Getenv("PORT_SOCKET"))
socketEngine := socket.Fabricate(portSocket)
socketEngine.FabricateCommand(cmd)
// Socket Stream Twitter, Instagram and facebook
twitterSocket := socket_stream.Fabricate(userFabricate)
twitterSocket.FabricateSocket(socketEngine)
// Scheduler Cron Local
cronJobLocal := scheduler.FabricateLocal("cron_local")
cronJobLocal.FabricateCommand(cmd)
cronJobServer := scheduler.FabricateServer("cron_server")
cronJobServer.FabricateCommand(cmd)
keywordJobLocal := scheduler.FabricateKeyword(userFabricate, celery, s3Management)
keywordJobLocal.FabricateSchedule(cronJobLocal)
keywordJobServer := scheduler.FabricateKeywordServer(userFabricate, celery, s3Management)
keywordJobServer.FabricateSchedule(cronJobServer)
if err := cmd.Execute(); err != nil {
panic(err)
}
}