/
syncer.go
50 lines (41 loc) · 970 Bytes
/
syncer.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
package syncer
import (
"time"
"github.com/alomerry/go-tools/modules/pusher/utils"
"github.com/spf13/cast"
"github.com/spf13/viper"
"golang.org/x/net/context"
)
type Syncer struct {
watcher *utils.Watcher
}
type config struct {
localPath string
remotePath string
interval time.Duration
}
func (s *Syncer) InitConfig() {
conf := &config{
localPath: cast.ToString(viper.GetStringMap("syncer")["local-path"]),
remotePath: cast.ToString(viper.GetStringMap("syncer")["remote-path"]),
interval: time.Second * time.Duration(cast.ToInt64(viper.GetStringMap("syncer")["interval"])),
}
s.watcher = utils.GenWatcher(conf)
}
func (s *Syncer) Run(ctx context.Context) error {
// TODO
return nil
}
func (s *Syncer) Done() bool {
// TODO
return true
}
func (c *config) GetLocalPath() string {
return c.localPath
}
func (c *config) GetRemotePath() string {
return c.remotePath
}
func (c *config) GetInterval() time.Duration {
return c.interval
}