-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (54 loc) · 960 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"context"
_ "github.com/warpstreamlabs/bento/public/components/io"
"github.com/warpstreamlabs/bento/public/service"
"golang.org/x/sync/errgroup"
)
const (
syncConfig = `
input:
generate:
count: 10
interval: ""
mapping: |
root = {
"id": uuid_v4(),
"created_at": now(),
"updated_at": now()
}
pipeline:
threads: -1
processors: []
output:
label: ""
stdout:
codec: lines
`
)
func main() {
errgrp := errgroup.Group{}
errgrp.Go(func() error {
return sync(syncConfig)
})
errgrp.Go(func() error {
return sync(syncConfig)
})
err := errgrp.Wait()
if err != nil {
panic(err)
}
}
func sync(config string) error {
env := service.NewEnvironment()
streambldr := env.NewStreamBuilder()
err := streambldr.SetYAML(config)
if err != nil {
return err
}
stream, err := streambldr.Build()
if err != nil {
return err
}
return stream.Run(context.Background())
}