bps 0.1.3 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bps.gemspec +1 -0
- data/lib/bps/publisher/abstract.rb +7 -2
- data/lib/bps/subscriber/abstract.rb +5 -2
- data/spec/bps/coercer_spec.rb +6 -5
- data/spec/bps/publisher/in_mem_spec.rb +14 -10
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b847f3ea372fc96092c28682121ac372020b85f91c0b176793231a73df0635e
|
4
|
+
data.tar.gz: 7d8df242d22c18ba9da98af088cbd88cfd76bdabe3f551765e854b9258a46088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97392c6a859a06beaecd19a6ad9ba016f69712aeba82f4f11e8595210d4beefe37a9ebc21c549565fbfd8a66d6aa275be4876404cb47804e49a67775fa2ad772
|
7
|
+
data.tar.gz: b8c1868b3088043874130cdfa28fdbb0e6129d7dc652171ed87b219214a2f73d2017df47f1f3ec25f05411aad10252a4e48339fa153966e0c28003b6582aeb3c
|
data/bps.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
module BPS
|
2
4
|
module Publisher
|
3
5
|
class Abstract
|
@@ -12,7 +14,8 @@ module BPS
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def initialize
|
15
|
-
|
17
|
+
@uuid = SecureRandom.uuid
|
18
|
+
ObjectSpace.define_finalizer(@uuid, proc { close })
|
16
19
|
end
|
17
20
|
|
18
21
|
# Retrieve a topic handle.
|
@@ -22,7 +25,9 @@ module BPS
|
|
22
25
|
end
|
23
26
|
|
24
27
|
# Close the publisher.
|
25
|
-
def close
|
28
|
+
def close
|
29
|
+
ObjectSpace.undefine_finalizer(@uuid)
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end
|
@@ -2,7 +2,8 @@ module BPS
|
|
2
2
|
module Subscriber
|
3
3
|
class Abstract
|
4
4
|
def initialize
|
5
|
-
|
5
|
+
@uuid = SecureRandom.uuid
|
6
|
+
ObjectSpace.define_finalizer(@uuid, proc { close })
|
6
7
|
end
|
7
8
|
|
8
9
|
# Subscribe to a topic
|
@@ -12,7 +13,9 @@ module BPS
|
|
12
13
|
end
|
13
14
|
|
14
15
|
# Close the subscriber.
|
15
|
-
def close
|
16
|
+
def close
|
17
|
+
ObjectSpace.undefine_finalizer(@uuid)
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
data/spec/bps/coercer_spec.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe BPS::Coercer do
|
4
|
-
subject
|
4
|
+
subject { coercer }
|
5
|
+
|
6
|
+
let(:coercer) do
|
5
7
|
described_class.new(
|
6
8
|
name: :string,
|
7
9
|
codec: :symbol,
|
@@ -11,7 +13,6 @@ RSpec.describe BPS::Coercer do
|
|
11
13
|
tags: [:string],
|
12
14
|
)
|
13
15
|
end
|
14
|
-
|
15
16
|
let :options do
|
16
17
|
{
|
17
18
|
name: 123,
|
@@ -24,13 +25,13 @@ RSpec.describe BPS::Coercer do
|
|
24
25
|
}
|
25
26
|
end
|
26
27
|
|
27
|
-
it '
|
28
|
+
it 'validates' do
|
28
29
|
expect { described_class.new(name: :unknown) }.to raise_error(ArgumentError, /Unknown type :unknown/)
|
29
30
|
expect { described_class.new(bad: []) }.to raise_error(ArgumentError, /Array types must have exactly one entry/)
|
30
31
|
end
|
31
32
|
|
32
|
-
it '
|
33
|
-
expect(
|
33
|
+
it 'coerces options' do
|
34
|
+
expect(coercer.coerce(options)).to eq(
|
34
35
|
name: '123',
|
35
36
|
codec: :snappy,
|
36
37
|
retries: 4,
|
@@ -1,22 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe BPS::Publisher::InMem do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
expect(
|
10
|
-
expect(
|
4
|
+
subject { publisher }
|
5
|
+
|
6
|
+
let(:publisher) { described_class.new }
|
7
|
+
|
8
|
+
it 'maintains topics' do
|
9
|
+
expect(publisher.topic('x')).to be_a(described_class::Topic)
|
10
|
+
expect(publisher.topic_names).to eq(%w[x])
|
11
|
+
expect(publisher.topic('z')).to be_a(described_class::Topic)
|
12
|
+
expect(publisher.topic_names).to eq(%w[x z])
|
13
|
+
expect(publisher.topic('y')).to be_a(described_class::Topic)
|
14
|
+
expect(publisher.topic_names).to eq(%w[x y z])
|
11
15
|
end
|
12
16
|
|
13
|
-
it '
|
14
|
-
topic =
|
17
|
+
it 'publishes' do
|
18
|
+
topic = publisher.topic('x')
|
15
19
|
topic.publish('foo')
|
16
20
|
topic.publish('bar')
|
17
21
|
expect(topic.messages).to eq(%w[foo bar])
|
18
22
|
|
19
23
|
expect { topic.flush }.not_to raise_error
|
20
|
-
expect(
|
24
|
+
expect(publisher.topic('x').messages).to eq(%w[foo bar])
|
21
25
|
end
|
22
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Black Square Media
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Minimalist abstraction for publish-subscribe
|
14
14
|
email: info@blacksquaremedia.com
|
@@ -27,7 +27,8 @@ files:
|
|
27
27
|
homepage: https://github.com/bsm/bps
|
28
28
|
licenses:
|
29
29
|
- Apache-2.0
|
30
|
-
metadata:
|
30
|
+
metadata:
|
31
|
+
rubygems_mfa_required: 'true'
|
31
32
|
post_install_message:
|
32
33
|
rdoc_options: []
|
33
34
|
require_paths:
|
@@ -43,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: '0'
|
45
46
|
requirements: []
|
46
|
-
rubygems_version: 3.
|
47
|
+
rubygems_version: 3.3.3
|
47
48
|
signing_key:
|
48
49
|
specification_version: 4
|
49
50
|
summary: Multi-platform pubsub adapter
|