-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (37 loc) · 1.14 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
package main
import (
"flag"
"fmt"
"log"
"net/http"
"time"
"bitbucket.org/hftloai/hftlapiconnector"
)
var serv *server
var max = flag.Int("hist", 10, "number of historical events to generate")
var p = flag.Duration("period", 1*time.Minute, "how frequently to generate new alerts")
var port = flag.Int("port", 8000, "http port")
var apiServer = flag.String("api", "http://127.0.0.1:8081/", "http port")
var apiToken = flag.String("token", "debug_token", "http port")
func main() {
flag.Parse()
serv = newServer()
serv.apiConn = new(hftlapiconnector.APIClient)
serv.apiConn.APIKey = *apiToken
serv.apiConn.BaseURL = *apiServer
serv.apiConn.UserID = "kim"
serv.apiConn.InitREST()
// populate 10 events up front
serv.seed(*max)
// emit period events starting now
go serv.generate(*p)
// go serv.latencyLoop()
// initialize routes, and start http server
http.HandleFunc("/", cors(serv.root))
http.HandleFunc("/annotations", cors(serv.annotations))
http.HandleFunc("/query", cors(serv.queries))
http.HandleFunc("/search", cors(serv.searches))
if err := http.ListenAndServe(fmt.Sprintf(":%d", *port), nil); err != nil {
log.Fatal(err)
}
}