forked from pydio/cells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetl-action.go
54 lines (45 loc) · 1.14 KB
/
etl-action.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
package actions
import (
"context"
"fmt"
"github.com/pydio/cells/common/etl"
"github.com/pydio/cells/common/etl/stores"
"github.com/pydio/cells/common/proto/jobs"
)
type etlAction struct {
params map[string]string
leftType string
rightType string
}
func (c *etlAction) ProvidesProgress() bool {
return true
}
func (c *etlAction) ParseStores(params map[string]string) error {
c.params = params
if r, o := params["left"]; o {
c.leftType = r
} else if t, o2 := params["type"]; o2 {
c.leftType = t
} else {
return fmt.Errorf("task sync user must take a left or type parameter")
}
if r, o := params["right"]; o {
c.rightType = r
} else {
// Use local as default target
c.rightType = "cells-local"
}
return nil
}
func (c *etlAction) initMerger(ctx context.Context, input jobs.ActionMessage) (*etl.Merger, error) {
options := stores.CreateOptions(ctx, c.params, input)
left, err := stores.LoadReadableStore(c.leftType, options)
if err != nil {
return nil, err
}
right, err := stores.LoadWritableStore(c.rightType, options)
if err != nil {
return nil, err
}
return etl.NewMerger(left, right, options.MergeOptions), nil
}