-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
45 lines (36 loc) · 1.15 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
package main
import (
"context"
"fmt"
"os"
"github.com/numaproj/numaflow-go/pkg/sourcer"
"github.com/numaproj-contrib/redisstreams-source-go/pkg/config"
"github.com/numaproj-contrib/redisstreams-source-go/pkg/redisstreams"
"github.com/numaproj-contrib/redisstreams-source-go/pkg/utils"
)
func main() {
logger := utils.NewLogger()
config, err := getConfigFromFile() // todo: maybe turn into an environment variable
if err != nil {
logger.Panic("Failed to parse config file : ", err)
} else {
logger.Infof("Successfully parsed config file: %+v", config)
}
redisStreamsSource, err := redisstreams.New(config, logger)
if err != nil {
logger.Panic("Failed to create redis streams source : ", err)
}
defer redisStreamsSource.Close()
err = sourcer.NewServer(redisStreamsSource).Start(context.Background())
if err != nil {
logger.Panic("Failed to start source server : ", err)
}
}
func getConfigFromFile() (*config.RedisStreamsSourceConfig, error) {
parser := &config.YAMLConfigParser{}
content, err := os.ReadFile(fmt.Sprintf("%s/config.yaml", utils.ConfigVolumePath))
if err != nil {
return nil, err
}
return parser.Parse(string(content))
}