-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
52 lines (48 loc) · 1008 Bytes
/
app.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
package main
import (
"net"
"net/http"
"time"
"github.com/tsuru/go-tsuruclient/pkg/client"
"github.com/tsuru/go-tsuruclient/pkg/tsuru"
)
func createTsuruClient(conf config) (*tsuru.APIClient, error) {
dialTimeout := 10 * time.Second
maxIdle := 100
dialer := &net.Dialer{
Timeout: dialTimeout,
KeepAlive: 30 * time.Second,
}
cli := &http.Client{
Transport: &http.Transport{
Dial: dialer.Dial,
TLSHandshakeTimeout: dialTimeout,
MaxIdleConnsPerHost: maxIdle,
MaxIdleConns: maxIdle,
IdleConnTimeout: 20 * time.Second,
},
Timeout: time.Minute,
}
return client.ClientFromEnvironment(&tsuru.Configuration{
BasePath: conf.tsuruHost,
HTTPClient: cli,
})
}
func startApp() error {
conf, err := readConfig()
if err != nil {
return err
}
client, err := createTsuruClient(conf)
if err != nil {
return err
}
_, err = newTeamsCollector(conf, client)
if err != nil {
return err
}
s := server{
config: conf,
}
return s.start()
}