feedx 0.5.3 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/consumer.go +33 -33
- data/feedx.gemspec +1 -1
- data/go.mod +1 -3
- data/go.sum +4 -121
- data/producer.go +24 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e5d88effb5a873a2cb2e16d4c7f824b824ef2f93bc306c500b3f97314b7d91c
|
4
|
+
data.tar.gz: be78ba37f5869fc6c2e026f2c1809dd083e7a0d02a55f66be3e9d555a6c7dc58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dab374c591498c3a23a0f2fab33fc8268c3c6028205b83c5483a4ebe27e468f00b05dfeb1200b237f358997f1d01654bec61fc1bb6fdd5c89fe317dba1e562d
|
7
|
+
data.tar.gz: 71d086bc0f43ef382e354c710badb8b0f10f3cab75dca6f79abda448add5115c2c82ab26ab9a4b503cab23960918fd768d4b505d3ebb4a66156341d334525de1
|
data/Gemfile.lock
CHANGED
data/consumer.go
CHANGED
@@ -18,7 +18,7 @@ type ConsumerOptions struct {
|
|
18
18
|
|
19
19
|
// AfterSync callbacks are triggered after each sync, receiving
|
20
20
|
// the updated status and error (if occurred).
|
21
|
-
AfterSync func(updated bool, err error)
|
21
|
+
AfterSync func(updated bool, consumer Consumer, err error)
|
22
22
|
}
|
23
23
|
|
24
24
|
func (o *ConsumerOptions) norm(name string) error {
|
@@ -74,7 +74,7 @@ func NewConsumerForRemote(ctx context.Context, remote *bfs.Object, opt *Consumer
|
|
74
74
|
}
|
75
75
|
|
76
76
|
ctx, stop := context.WithCancel(ctx)
|
77
|
-
|
77
|
+
c := &consumer{
|
78
78
|
remote: remote,
|
79
79
|
opt: o,
|
80
80
|
ctx: ctx,
|
@@ -83,15 +83,15 @@ func NewConsumerForRemote(ctx context.Context, remote *bfs.Object, opt *Consumer
|
|
83
83
|
}
|
84
84
|
|
85
85
|
// run initial sync
|
86
|
-
if _, err :=
|
87
|
-
_ =
|
86
|
+
if _, err := c.sync(true); err != nil {
|
87
|
+
_ = c.Close()
|
88
88
|
return nil, err
|
89
89
|
}
|
90
90
|
|
91
91
|
// start continuous loop
|
92
|
-
go
|
92
|
+
go c.loop()
|
93
93
|
|
94
|
-
return
|
94
|
+
return c, nil
|
95
95
|
}
|
96
96
|
|
97
97
|
type consumer struct {
|
@@ -109,82 +109,82 @@ type consumer struct {
|
|
109
109
|
}
|
110
110
|
|
111
111
|
// Data implements Consumer interface.
|
112
|
-
func (
|
113
|
-
return
|
112
|
+
func (c *consumer) Data() interface{} {
|
113
|
+
return c.data.Load()
|
114
114
|
}
|
115
115
|
|
116
116
|
// NumRead implements Consumer interface.
|
117
|
-
func (
|
118
|
-
return int(atomic.LoadInt64(&
|
117
|
+
func (c *consumer) NumRead() int {
|
118
|
+
return int(atomic.LoadInt64(&c.numRead))
|
119
119
|
}
|
120
120
|
|
121
121
|
// LastSync implements Consumer interface.
|
122
|
-
func (
|
123
|
-
return timestamp(atomic.LoadInt64(&
|
122
|
+
func (c *consumer) LastSync() time.Time {
|
123
|
+
return timestamp(atomic.LoadInt64(&c.lastSync)).Time()
|
124
124
|
}
|
125
125
|
|
126
126
|
// LastModified implements Consumer interface.
|
127
|
-
func (
|
128
|
-
return timestamp(atomic.LoadInt64(&
|
127
|
+
func (c *consumer) LastModified() time.Time {
|
128
|
+
return timestamp(atomic.LoadInt64(&c.lastMod)).Time()
|
129
129
|
}
|
130
130
|
|
131
131
|
// Close implements Consumer interface.
|
132
|
-
func (
|
133
|
-
|
134
|
-
if
|
135
|
-
return
|
132
|
+
func (c *consumer) Close() error {
|
133
|
+
c.stop()
|
134
|
+
if c.ownRemote {
|
135
|
+
return c.remote.Close()
|
136
136
|
}
|
137
137
|
return nil
|
138
138
|
}
|
139
139
|
|
140
|
-
func (
|
140
|
+
func (c *consumer) sync(force bool) (bool, error) {
|
141
141
|
defer func() {
|
142
|
-
atomic.StoreInt64(&
|
142
|
+
atomic.StoreInt64(&c.lastSync, timestampFromTime(time.Now()).Millis())
|
143
143
|
}()
|
144
144
|
|
145
145
|
// retrieve original last modified time
|
146
|
-
lastMod, err := remoteLastModified(
|
146
|
+
lastMod, err := remoteLastModified(c.ctx, c.remote)
|
147
147
|
if err != nil {
|
148
148
|
return false, err
|
149
149
|
}
|
150
150
|
|
151
151
|
// skip update if not forced or modified
|
152
|
-
if lastMod.Millis() == atomic.LoadInt64(&
|
152
|
+
if lastMod.Millis() == atomic.LoadInt64(&c.lastMod) && !force {
|
153
153
|
return false, nil
|
154
154
|
}
|
155
155
|
|
156
156
|
// open remote reader
|
157
|
-
reader, err := NewReader(
|
157
|
+
reader, err := NewReader(c.ctx, c.remote, &c.opt.ReaderOptions)
|
158
158
|
if err != nil {
|
159
159
|
return false, err
|
160
160
|
}
|
161
161
|
defer reader.Close()
|
162
162
|
|
163
163
|
// consume feed
|
164
|
-
data, err :=
|
164
|
+
data, err := c.cfn(reader)
|
165
165
|
if err != nil {
|
166
166
|
return false, err
|
167
167
|
}
|
168
168
|
|
169
169
|
// update stores
|
170
|
-
|
171
|
-
atomic.StoreInt64(&
|
172
|
-
atomic.StoreInt64(&
|
170
|
+
c.data.Store(data)
|
171
|
+
atomic.StoreInt64(&c.numRead, int64(reader.NumRead()))
|
172
|
+
atomic.StoreInt64(&c.lastMod, lastMod.Millis())
|
173
173
|
return true, nil
|
174
174
|
}
|
175
175
|
|
176
|
-
func (
|
177
|
-
ticker := time.NewTicker(
|
176
|
+
func (c *consumer) loop() {
|
177
|
+
ticker := time.NewTicker(c.opt.Interval)
|
178
178
|
defer ticker.Stop()
|
179
179
|
|
180
180
|
for {
|
181
181
|
select {
|
182
|
-
case <-
|
182
|
+
case <-c.ctx.Done():
|
183
183
|
return
|
184
184
|
case <-ticker.C:
|
185
|
-
updated, err :=
|
186
|
-
if
|
187
|
-
|
185
|
+
updated, err := c.sync(false)
|
186
|
+
if c.opt.AfterSync != nil {
|
187
|
+
c.opt.AfterSync(updated, c, err)
|
188
188
|
}
|
189
189
|
}
|
190
190
|
}
|
data/feedx.gemspec
CHANGED
data/go.mod
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module github.com/bsm/feedx
|
2
2
|
|
3
3
|
require (
|
4
|
-
github.com/bsm/bfs v0.6.
|
4
|
+
github.com/bsm/bfs v0.6.3
|
5
5
|
github.com/gogo/protobuf v1.2.1
|
6
6
|
github.com/golang/protobuf v1.3.1
|
7
7
|
github.com/onsi/ginkgo v1.8.0
|
8
8
|
github.com/onsi/gomega v1.5.0
|
9
|
-
golang.org/x/net v0.0.0-20190514140710-3ec191127204 // indirect
|
10
|
-
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438 // indirect
|
11
9
|
)
|
data/go.sum
CHANGED
@@ -1,159 +1,45 @@
|
|
1
|
-
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
2
|
-
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
3
|
-
cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
|
4
|
-
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
5
|
-
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
6
|
-
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
7
|
-
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
8
|
-
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
9
|
-
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
10
|
-
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
11
|
-
github.com/aws/aws-sdk-go v1.19.19/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
12
|
-
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
13
1
|
github.com/bmatcuk/doublestar v1.1.1 h1:YroD6BJCZBYx06yYFEWvUuKVWQn3vLLQAVmDmvTSaiQ=
|
14
2
|
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
15
|
-
github.com/bsm/bfs v0.6.
|
16
|
-
github.com/bsm/bfs v0.6.
|
17
|
-
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
18
|
-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
19
|
-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
20
|
-
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
21
|
-
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
22
|
-
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
3
|
+
github.com/bsm/bfs v0.6.3 h1:qHOkJIx5W971wlnFLeJfiGGO0TUdB9JpTJ9RTAVntVg=
|
4
|
+
github.com/bsm/bfs v0.6.3/go.mod h1:bRNSGIGvKb0MlboBpb7Aa3/Kaxmhes/6Be6wD+fsnKc=
|
23
5
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
24
6
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
25
|
-
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
26
|
-
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
27
|
-
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
28
|
-
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
29
|
-
github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI=
|
30
|
-
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
31
7
|
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
32
8
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
33
|
-
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
34
|
-
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
35
|
-
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
36
9
|
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
37
10
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
38
11
|
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
39
12
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
40
|
-
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
41
|
-
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
42
|
-
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
43
|
-
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
44
|
-
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
45
|
-
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
46
|
-
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
47
|
-
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
48
|
-
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
49
|
-
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
50
13
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
51
14
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
52
|
-
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
53
|
-
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
54
|
-
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
55
15
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
56
16
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
57
|
-
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
58
|
-
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
59
17
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
60
18
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
61
19
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
62
20
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
63
21
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
64
|
-
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
65
|
-
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
66
22
|
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
|
67
23
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
68
|
-
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
|
69
|
-
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
70
24
|
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
|
71
25
|
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
72
|
-
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
|
73
|
-
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
74
26
|
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
|
75
27
|
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
76
|
-
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
77
|
-
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
78
|
-
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
79
|
-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
80
|
-
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
81
|
-
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
82
|
-
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
83
|
-
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
84
|
-
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
85
|
-
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
86
|
-
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
87
|
-
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
88
|
-
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
89
|
-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
90
|
-
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
91
|
-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
92
|
-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
93
|
-
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
94
|
-
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
95
|
-
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
96
28
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
97
|
-
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
98
|
-
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
99
|
-
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
100
|
-
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
101
|
-
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
102
|
-
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
103
|
-
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
104
29
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
105
|
-
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
106
|
-
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
107
|
-
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
108
|
-
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
109
|
-
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
110
|
-
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 h1:FP8hkuE6yUEaJnK7O2eTuejKWwW+Rhfj80dQ2JcKxCU=
|
111
|
-
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
112
30
|
golang.org/x/net v0.0.0-20190514140710-3ec191127204 h1:4yG6GqBtw9C+UrLp6s2wtSniayy/Vd/3F7ffLE427XI=
|
113
31
|
golang.org/x/net v0.0.0-20190514140710-3ec191127204/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
114
|
-
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
115
|
-
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
116
|
-
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
117
32
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
118
|
-
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
|
119
|
-
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
120
|
-
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
121
|
-
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
122
|
-
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
123
|
-
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
124
33
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
125
|
-
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
126
|
-
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
127
34
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
128
|
-
golang.org/x/sys v0.0.0-
|
129
|
-
golang.org/x/sys v0.0.0-
|
130
|
-
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
35
|
+
golang.org/x/sys v0.0.0-20190516110030-61b9204099cb h1:k07iPOt0d6nEnwXF+kHB+iEg+WSuKe/SOQuFM2QoD+E=
|
36
|
+
golang.org/x/sys v0.0.0-20190516110030-61b9204099cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
131
37
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
132
38
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
133
|
-
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
134
39
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
135
40
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
136
|
-
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
137
41
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
138
|
-
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
139
42
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
140
|
-
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
141
|
-
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
142
|
-
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
143
|
-
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
144
|
-
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
145
|
-
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
146
|
-
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
147
|
-
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
148
|
-
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
149
|
-
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
150
|
-
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
151
|
-
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
152
|
-
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
153
|
-
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
154
|
-
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
155
|
-
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
156
|
-
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
157
43
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
158
44
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
159
45
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
@@ -165,6 +51,3 @@ gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
|
|
165
51
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
166
52
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
167
53
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
168
|
-
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
169
|
-
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
170
|
-
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
data/producer.go
CHANGED
@@ -24,8 +24,8 @@ type ProducerOptions struct {
|
|
24
24
|
LastModCheck func(context.Context) (time.Time, error)
|
25
25
|
|
26
26
|
// AfterPush callbacks are triggered after each push cycle, receiving
|
27
|
-
//
|
28
|
-
AfterPush func(error)
|
27
|
+
// the updated status and error (if occurred).
|
28
|
+
AfterPush func(updated bool, consumer *Producer, err error)
|
29
29
|
}
|
30
30
|
|
31
31
|
func (o *ProducerOptions) norm(name string) error {
|
@@ -85,7 +85,7 @@ func NewProducerForRemote(ctx context.Context, remote *bfs.Object, opt *Producer
|
|
85
85
|
}
|
86
86
|
|
87
87
|
// run initial push
|
88
|
-
if err := p.push(); err != nil {
|
88
|
+
if _, err := p.push(); err != nil {
|
89
89
|
_ = p.Close()
|
90
90
|
return nil, err
|
91
91
|
}
|
@@ -120,41 +120,49 @@ func (p *Producer) Close() error {
|
|
120
120
|
return nil
|
121
121
|
}
|
122
122
|
|
123
|
-
func (p *Producer) push() error {
|
123
|
+
func (p *Producer) push() (bool, error) {
|
124
124
|
start := time.Now()
|
125
125
|
atomic.StoreInt64(&p.lastPush, timestampFromTime(start).Millis())
|
126
126
|
|
127
|
+
// setup write options
|
127
128
|
wopt := p.opt.WriterOptions
|
128
129
|
wopt.LastMod = start
|
129
130
|
if p.opt.LastModCheck != nil {
|
130
131
|
modTime, err := p.opt.LastModCheck(p.ctx)
|
131
132
|
if err != nil {
|
132
|
-
return err
|
133
|
+
return false, err
|
133
134
|
}
|
134
135
|
wopt.LastMod = modTime
|
135
136
|
}
|
136
137
|
|
138
|
+
// retrieve original last modified time
|
139
|
+
lastMod, err := remoteLastModified(p.ctx, p.remote)
|
140
|
+
if err != nil {
|
141
|
+
return false, err
|
142
|
+
}
|
143
|
+
|
144
|
+
// skip push if not modified
|
145
|
+
if lastMod.Time().Equal(wopt.LastMod) {
|
146
|
+
return false, nil
|
147
|
+
}
|
148
|
+
|
137
149
|
writer, err := NewWriter(p.ctx, p.remote, &wopt)
|
138
150
|
if err != nil {
|
139
|
-
return err
|
151
|
+
return false, err
|
140
152
|
}
|
141
153
|
defer writer.Discard()
|
142
154
|
|
143
155
|
if err := p.pfn(writer); err != nil {
|
144
|
-
return err
|
145
|
-
}
|
146
|
-
|
147
|
-
if writer.NumWritten() == 0 {
|
148
|
-
return nil
|
156
|
+
return false, err
|
149
157
|
}
|
150
158
|
|
151
159
|
if err := writer.Commit(); err != nil {
|
152
|
-
return err
|
160
|
+
return false, err
|
153
161
|
}
|
154
162
|
|
155
163
|
atomic.StoreInt64(&p.numWritten, int64(writer.NumWritten()))
|
156
164
|
atomic.StoreInt64(&p.lastMod, timestampFromTime(wopt.LastMod).Millis())
|
157
|
-
return nil
|
165
|
+
return true, nil
|
158
166
|
}
|
159
167
|
|
160
168
|
func (p *Producer) loop() {
|
@@ -166,8 +174,9 @@ func (p *Producer) loop() {
|
|
166
174
|
case <-p.ctx.Done():
|
167
175
|
return
|
168
176
|
case <-ticker.C:
|
169
|
-
|
170
|
-
|
177
|
+
updated, err := p.push()
|
178
|
+
if p.opt.AfterPush != nil {
|
179
|
+
p.opt.AfterPush(updated, p, err)
|
171
180
|
}
|
172
181
|
}
|
173
182
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Black Square Media Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bfs
|