-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.go
46 lines (37 loc) · 863 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
44
45
46
package main
import (
"os"
ticker "github.com/OpenBazaar/tickerproxy"
"github.com/aws/aws-lambda-go/lambda"
"github.com/gocraft/health"
)
func main() {
lambda.Start(Fetch)
}
func Fetch() {
conf := ticker.NewConfig()
stream := health.NewStream()
stream.AddSink(&health.WriterSink{Writer: os.Stdout})
kvs := map[string]string{
"region": conf.AWSS3Region,
"bucket": conf.AWSS3Bucket,
"btcAvgPubKey": conf.BTCAVGPubkey,
}
writer, err := ticker.NewS3Writer(conf.AWSS3Region, conf.AWSS3Bucket)
if err != nil {
stream.EventErrKv("new_s3_writer", err, kvs)
os.Exit(1)
}
err = ticker.Fetch(stream, conf, writer)
if err != nil {
stream.EventErrKv("new_s3_writer", err, kvs)
os.Exit(1)
}
}
func getEnvString(key string, defaultVal string) string {
val := os.Getenv(key)
if val == "" {
val = defaultVal
}
return val
}