-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (33 loc) · 772 Bytes
/
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
package main
import (
"fmt"
"log"
"stock-pick/listeners"
"stock-pick/readers"
)
func main() {
activityChannel := make(chan string)
StartListeners(activityChannel)
select {
case message := <-activityChannel:
fmt.Println(message)
}
}
//StartListeners gets all the symbols and creates listeners for them
func StartListeners(activityChannel chan string) {
reader, error := readers.NewReader(readers.InMemory)
if error != nil {
log.Fatal("Failure to create symbol reader")
}
symbols, error := reader.GetSymbols()
if error != nil {
log.Fatal("Failure to retrieve symbols")
}
for _, symbol := range symbols {
listener, err := listeners.NewListener()
if err != nil {
panic(err)
}
go listener.ListenToSymbol(symbol, activityChannel)
}
}