@@ -2,13 +2,17 @@ package syncconnector
2
2
3
3
import (
4
4
"github.com/curusarn/resh/internal/histcli"
5
- "github.com/curusarn/resh/internal/record"
6
5
"github.com/curusarn/resh/internal/recordint"
7
6
"go.uber.org/zap"
8
7
"net/url"
8
+ "path"
9
9
"time"
10
10
)
11
11
12
+ const storeEndpoint = "/store"
13
+ const historyEndpoint = "/history"
14
+ const latestEndpoint = "/latest"
15
+
12
16
type SyncConnector struct {
13
17
sugar * zap.SugaredLogger
14
18
@@ -37,18 +41,29 @@ func New(sugar *zap.SugaredLogger, address string, authToken string, pullPeriodS
37
41
// TODO: propagate signals
38
42
go func (sc * SyncConnector ) {
39
43
for _ = range time .Tick (time .Second * time .Duration (pullPeriodSeconds )) {
40
- sc .sugar .Infow ("checking remote" )
44
+ sc .sugar .Debug ("checking remote" )
45
+
46
+ recs , err := sc .downloadRecords (map [string ]string {})
47
+ if err != nil {
48
+ continue
49
+ }
50
+
51
+ sc .sugar .Debugf ("Got %d records" , len (recs ))
41
52
42
- // Add fake record (this will be produced by the sync connector)
43
- sc .history .AddRecord (& recordint.Indexed {
44
- Rec : record.V1 {
45
- CmdLine : "__fake_test__" ,
46
- DeviceID : "__test__" ,
47
- },
48
- })
53
+ for _ , rec := range recs {
54
+ sc .history .AddRecord (& recordint.Indexed {
55
+ Rec : rec ,
56
+ })
57
+ }
49
58
50
59
}
51
60
}(sc )
52
61
53
62
return sc , nil
54
63
}
64
+
65
+ func (sc SyncConnector ) getAddressWithPath (endpoint string ) string {
66
+ address := * sc .address
67
+ address .Path = path .Join (address .Path , endpoint )
68
+ return address .String ()
69
+ }
0 commit comments