feedx 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6a031f3dd500b1d022708f6997ce6b99fc1ca764c58d0d1a2d5c49430797975
4
- data.tar.gz: 3cb5fa9951cd4918bb9191c8c644cb422b9c9d9a00944b5f68afc247b80a5935
3
+ metadata.gz: ac561a2e9f403ede565104432d51ac3848c59fc8147e063e1fbdbba9486a1c34
4
+ data.tar.gz: ccf838177c08ac2d1247f61323561a3d06d43084466c34f214993f59743d646d
5
5
  SHA512:
6
- metadata.gz: b2e0b49aafcc5b0f8ddad15b7738f815d097057ed205709a19ce8f734f1aaa50aaf10add1d580412c4fb673decb706c6a73094f8fb6d624e5de15a95c21c74a0
7
- data.tar.gz: 96130e3b806c74c719fe6d31cbb4c3dcaa1dcbbdbb80e7a417df9d54a478b1eec166f6b4abeb4f665bf4c37c1f26a6640baaef3a9d3fb4c11afe233c6538a3a3
6
+ metadata.gz: 2de3eb9b314c84d556201d9cca545ea2c0b255c2dba0f0aba6e40e76a34092975f6ab8c8332028c22263cec358c7000e2fb188833dc45b9ba26bdb111ccda9c7
7
+ data.tar.gz: 2caa4db04fc18f4ad12b05171e1a6fd7afc9e8f52514100480e4d5762f8b7c4d1328643da9c2e39d08f005f22feefdfe5b976685729b6df2ea8c03572a694bc9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feedx (0.9.2)
4
+ feedx (0.10.0)
5
5
  bfs (>= 0.5.0)
6
6
 
7
7
  GEM
@@ -42,7 +42,7 @@ GEM
42
42
  rubocop-performance (1.5.2)
43
43
  rubocop (>= 0.71.0)
44
44
  ruby-progressbar (1.10.1)
45
- unicode-display_width (1.6.0)
45
+ unicode-display_width (1.6.1)
46
46
 
47
47
  PLATFORMS
48
48
  ruby
data/feedx.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'feedx'
3
- s.version = '0.9.2'
3
+ s.version = '0.10.0'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(Exchange data between components via feeds)
data/feedx_test.go CHANGED
@@ -31,12 +31,9 @@ var fixture = tbp.Message{
31
31
  }
32
32
 
33
33
  func writeMulti(obj *bfs.Object, numEntries int) error {
34
- w, err := feedx.NewWriter(context.Background(), obj, &feedx.WriterOptions{
34
+ w := feedx.NewWriter(context.Background(), obj, &feedx.WriterOptions{
35
35
  LastMod: time.Unix(1515151515, 123456789),
36
36
  })
37
- if err != nil {
38
- return err
39
- }
40
37
  defer w.Discard()
41
38
 
42
39
  for i := 0; i < numEntries; i++ {
data/go.mod CHANGED
@@ -1,8 +1,7 @@
1
1
  module github.com/bsm/feedx
2
2
 
3
3
  require (
4
- github.com/bmatcuk/doublestar v1.2.2 // indirect
5
- github.com/bsm/bfs v0.8.1
4
+ github.com/bsm/bfs v0.9.0
6
5
  github.com/gogo/protobuf v1.3.1
7
6
  github.com/golang/protobuf v1.3.2
8
7
  github.com/onsi/ginkgo v1.10.2
data/go.sum CHANGED
@@ -1,9 +1,7 @@
1
- github.com/bmatcuk/doublestar v1.1.5 h1:2bNwBOmhyFEFcoB3tGvTD5xanq+4kyOZlB8wFYbMjkk=
2
- github.com/bmatcuk/doublestar v1.1.5/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
3
1
  github.com/bmatcuk/doublestar v1.2.2 h1:oC24CykoSAB8zd7XgruHo33E0cHJf/WhQA/7BeXj+x0=
4
2
  github.com/bmatcuk/doublestar v1.2.2/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
5
- github.com/bsm/bfs v0.8.1 h1:PS+kH6Pu8IsKUrxOp8E/B6/ASLvGEz2kIeX0GM4DdPc=
6
- github.com/bsm/bfs v0.8.1/go.mod h1:cVv0jyqUY/jbHoG/WYPuWvOaOhW/HZ4jl7/JMlypvAE=
3
+ github.com/bsm/bfs v0.9.0 h1:7sUB3a5ZzzhBlCELY+2pqCaI6MbO7F2a0jhIgHihhFs=
4
+ github.com/bsm/bfs v0.9.0/go.mod h1:N3md8kQvlteRDcfc8tqw759yW98dhj+6seWEVcg4CmM=
7
5
  github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
8
6
  github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
9
7
  github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
data/producer.go CHANGED
@@ -147,10 +147,7 @@ func (p *Producer) push() (*ProducerPush, error) {
147
147
  return &ProducerPush{Producer: p}, nil
148
148
  }
149
149
 
150
- writer, err := NewWriter(p.ctx, p.remote, &wopt)
151
- if err != nil {
152
- return nil, err
153
- }
150
+ writer := NewWriter(p.ctx, p.remote, &wopt)
154
151
  defer writer.Discard()
155
152
 
156
153
  if err := p.pfn(writer); err != nil {
data/writer.go CHANGED
@@ -3,7 +3,6 @@ package feedx
3
3
  import (
4
4
  "bufio"
5
5
  "context"
6
- "errors"
7
6
  "io"
8
7
  "time"
9
8
 
@@ -40,33 +39,29 @@ func (o *WriterOptions) norm(name string) {
40
39
  // Writer encodes feeds to remote locations.
41
40
  type Writer struct {
42
41
  ctx context.Context
43
- cancel context.CancelFunc
44
-
45
42
  remote *bfs.Object
46
43
  opt WriterOptions
47
44
  num int
48
45
 
49
- bw io.WriteCloser // bfs writer
46
+ bw bfs.Writer
50
47
  cw io.WriteCloser // compression writer
51
48
  ww *bufio.Writer
52
49
  fe FormatEncoder
53
50
  }
54
51
 
55
52
  // NewWriter inits a new feed writer.
56
- func NewWriter(ctx context.Context, remote *bfs.Object, opt *WriterOptions) (*Writer, error) {
53
+ func NewWriter(ctx context.Context, remote *bfs.Object, opt *WriterOptions) *Writer {
57
54
  var o WriterOptions
58
55
  if opt != nil {
59
56
  o = *opt
60
57
  }
61
58
  o.norm(remote.Name())
62
59
 
63
- ctx, cancel := context.WithCancel(ctx)
64
60
  return &Writer{
65
61
  ctx: ctx,
66
- cancel: cancel,
67
62
  remote: remote,
68
63
  opt: o,
69
- }, nil
64
+ }
70
65
  }
71
66
 
72
67
  // Write write raw bytes to the feed.
@@ -114,16 +109,27 @@ func (w *Writer) NumWritten() int {
114
109
 
115
110
  // Discard closes the writer and discards the contents.
116
111
  func (w *Writer) Discard() error {
117
- w.cancel()
118
- if err := w.Commit(); err != nil && !errors.Is(err, context.Canceled) {
119
- return err
112
+ err := w.close()
113
+ if w.bw != nil {
114
+ if e := w.bw.Discard(); e != nil {
115
+ err = e
116
+ }
120
117
  }
121
- return nil
118
+ return err
122
119
  }
123
120
 
124
121
  // Commit closes the writer and persists the contents.
125
122
  func (w *Writer) Commit() error {
126
- var err error
123
+ err := w.close()
124
+ if w.bw != nil {
125
+ if e := w.bw.Commit(); e != nil {
126
+ err = e
127
+ }
128
+ }
129
+ return err
130
+ }
131
+
132
+ func (w *Writer) close() (err error) {
127
133
  if w.fe != nil {
128
134
  if e := w.fe.Close(); e != nil {
129
135
  err = e
@@ -139,11 +145,6 @@ func (w *Writer) Commit() error {
139
145
  err = e
140
146
  }
141
147
  }
142
- if w.bw != nil {
143
- if e := w.bw.Close(); e != nil {
144
- err = e
145
- }
146
- }
147
148
  return err
148
149
  }
149
150
 
data/writer_test.go CHANGED
@@ -21,10 +21,9 @@ var _ = Describe("Writer", func() {
21
21
  })
22
22
 
23
23
  It("should write plain", func() {
24
- w, err := feedx.NewWriter(context.Background(), plain, &feedx.WriterOptions{
24
+ w := feedx.NewWriter(context.Background(), plain, &feedx.WriterOptions{
25
25
  LastMod: time.Unix(1515151515, 123456789),
26
26
  })
27
- Expect(err).NotTo(HaveOccurred())
28
27
  defer w.Discard()
29
28
 
30
29
  Expect(w.Write(bytes.Repeat([]byte{'x'}, 10000))).To(Equal(10000))
@@ -37,10 +36,9 @@ var _ = Describe("Writer", func() {
37
36
  })
38
37
 
39
38
  It("should write compressed", func() {
40
- w, err := feedx.NewWriter(context.Background(), compressed, &feedx.WriterOptions{
39
+ w := feedx.NewWriter(context.Background(), compressed, &feedx.WriterOptions{
41
40
  LastMod: time.Unix(1515151515, 123456789),
42
41
  })
43
- Expect(err).NotTo(HaveOccurred())
44
42
  defer w.Discard()
45
43
 
46
44
  Expect(w.Write(bytes.Repeat([]byte{'x'}, 10000))).To(Equal(10000))
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.9.2
4
+ version: 0.10.0
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: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bfs