forked from alfoudari/manifold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (41 loc) · 1.2 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
47
48
49
50
51
package main
import (
"os"
"os/signal"
"github.com/abstractpaper/manifold/stream"
swissOS "github.com/abstractpaper/swissarmy/os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
log "github.com/sirupsen/logrus"
)
func main() {
// interrupt channel for OS signals
interrupt := make(chan os.Signal, 1)
// register interrupt channel to receive SIGINT and SIGKILL
signal.Notify(interrupt, os.Interrupt, os.Kill)
// aws config
awsRegion := swissOS.GetEnv("MANIFOLD_AWS_REGION", "us-east-1")
awsAccessKey := swissOS.GetEnv("MANIFOLD_AWS_ACCESS_KEY", "")
awsSecretKey := swissOS.GetEnv("MANIFOLD_AWS_SECRET_KEY", "")
// AWS setup
sess, err := session.NewSession(&aws.Config{
Region: aws.String(awsRegion),
Credentials: credentials.NewStaticCredentials(awsAccessKey, awsSecretKey, ""),
})
if err != nil {
log.Fatalln("Error creating session: ", err)
}
src := stream.Stdio{}
dest := stream.Kinesis{
AWSSess: sess,
Args: map[string]string{
"partitionKey": "partition1",
"streamName": "test",
},
}
stream.Flow(&src, nil, &dest)
// wait for interrupt signals
<-interrupt
log.Info("Interrupt received.")
}