-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
62 lines (53 loc) · 1.38 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
package main
import (
"github.com/ievgen-ma/remotejobapp/broadcasts"
"github.com/ievgen-ma/remotejobapp/feeds"
"github.com/ievgen-ma/remotejobapp/feeds/indeed"
"github.com/ievgen-ma/remotejobapp/feeds/remoteglobal"
"github.com/ievgen-ma/remotejobapp/feeds/remotive"
"github.com/ievgen-ma/remotejobapp/feeds/stackoverflow"
"github.com/ievgen-ma/remotejobapp/feeds/weworkremotely"
"github.com/joho/godotenv"
"log"
"os"
"os/signal"
)
func init() {
if err := godotenv.Load(); err != nil {
log.Fatal(err)
}
}
func createFeed(feedName string) feeds.PublicFeed {
switch feedName {
case "indeed":
return indeed.NewPublicFeed(feedName)
case "remoteglobal":
return remoteglobal.NewPublicFeed(feedName)
case "remotive":
return remotive.NewPublicFeed(feedName)
case "stackoverflow":
return stackoverflow.NewPublicFeed(feedName)
case "weworkremotely":
return weworkremotely.NewPublicFeed(feedName)
}
return nil
}
func parseDate() {
go createFeed("indeed").Connect()
go createFeed("remoteglobal").Connect()
go createFeed("remotive").Connect()
go createFeed("stackoverflow").Connect()
go createFeed("weworkremotely").Connect()
}
func broadcastData() {
if err := broadcasts.NewBroadcastHandler().SendPosts(10); err != nil {
log.Fatal(err)
}
}
func main() {
parseDate()
go broadcastData()
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt, os.Interrupt)
<-quit
}