-
Notifications
You must be signed in to change notification settings - Fork 2
/
struct.go
53 lines (40 loc) · 847 Bytes
/
struct.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
package main
import (
"database/sql"
"net/http"
"sync"
"github.com/inconshreveable/log15"
)
type syncer struct {
config *config
logger log15.Logger
httpAskgod *http.Client
httpDiscourse *http.Client
db *sql.DB
postsLock sync.Mutex
teamsLock sync.Mutex
}
func getSyncer(path string) (*syncer, error) {
s := syncer{}
// Setup logging
s.logger = log15.New()
// Setup config
config, err := parseConfig(path)
if err != nil {
return nil, err
}
s.config = config
// Setup askgod client
client, err := s.getClient(config.AskgodURL, config.AskgodCert)
if err != nil {
return nil, err
}
s.httpAskgod = client
// Setup discourse client
client, err = s.getClient(config.DiscourseURL, config.DiscourseCert)
if err != nil {
return nil, err
}
s.httpDiscourse = client
return &s, nil
}