-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.go
72 lines (58 loc) · 1.32 KB
/
configure.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
package main
import (
"net"
"net/http"
"time"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
cs "github.com/webtor-io/common-services"
s "github.com/webtor-io/transcode-web-cache/services"
)
func configure(app *cli.App) {
app.Flags = []cli.Flag{}
cs.RegisterProbeFlags(app)
cs.RegisterS3ClientFlags(app)
s.RegisterS3StorageFlags(app)
s.RegisterWebFlags(app)
app.Action = run
}
func run(c *cli.Context) error {
// Setting HTTP Client
myTransport := &http.Transport{
MaxIdleConns: 500,
MaxIdleConnsPerHost: 50,
Dial: (&net.Dialer{
Timeout: 5 * time.Minute,
}).Dial,
}
cl := &http.Client{
Timeout: 5 * time.Minute,
Transport: myTransport,
}
// Setting S3 Client
s3cl := cs.NewS3Client(c, cl)
// Setting S3 Storage
s3st := s.NewS3Storage(c, s3cl)
// Setting TouchPool
tp := s.NewTouchPool(s3st)
// Setting DonePool
dp := s.NewDonePool(s3st)
// Setting Cache
cache := s.NewCache(s3st, dp)
// Setting LookaheadCache
lacache := s.NewLookaheadCache(cache)
// Setting ProbeService
probe := cs.NewProbe(c)
defer probe.Close()
// Setting WebService
web := s.NewWeb(c, lacache, tp, dp)
defer web.Close()
// Setting ServeService
serve := cs.NewServe(probe, web)
// And SERVE!
err := serve.Serve()
if err != nil {
log.WithError(err).Error("Got server error")
}
return nil
}