pulsar-client 2.6.1.pre.beta.1 → 2.6.1.pre.beta.2
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/.travis.yml +11 -0
- data/Gemfile.lock +14 -14
- data/ext/bindings/client.cpp +20 -4
- data/ext/bindings/client.hpp +1 -1
- data/ext/bindings/consumer.cpp +4 -0
- data/ext/bindings/message.cpp +8 -0
- data/ext/bindings/message.hpp +2 -0
- data/ext/bindings/vector.cpp +16 -0
- data/ext/bindings/vector.hpp +10 -0
- data/lib/pulsar/client.rb +1 -1
- data/lib/pulsar/client/version.rb +1 -1
- data/lib/pulsar/consumer_configuration.rb +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40d7a5b7897e334ba7dcf34b17f5514ef342b9e8fba1ac1dfa54da846f0d5fe1
|
4
|
+
data.tar.gz: 91645d571180036f94d33c1d1a42e3e01425af4a4877fed79258ac7d52356e32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81dcc960831f5831aebd4eacdd83c0a3b30a19ae69c821a68b925feda627e79b77eea477ba79c0f10170ed43e5f68d14c6f2592c286a18b2f6eaf5c3f49699e4
|
7
|
+
data.tar.gz: 7f3208848c5f2e993dc3a0798a53071982d6f956babd1b4ab02ce1fe7655c4f2412326aabce142e3e98dea119097efeb918d70c6a9dd919888af5e15c5f442b5
|
data/.travis.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
dist: bionic # ubuntu 18.04
|
2
2
|
sudo: false
|
3
|
+
services:
|
4
|
+
- docker
|
3
5
|
language: ruby
|
4
6
|
rvm:
|
5
7
|
- 2.4.9 # oldest pre-install on bionic
|
@@ -12,5 +14,14 @@ install:
|
|
12
14
|
- sudo apt-get -y install ./apache-pulsar-client-dev.deb
|
13
15
|
- gem install bundler -v 1.16.1
|
14
16
|
- bundle install
|
17
|
+
before_script:
|
18
|
+
- docker run --name pulsar -d -p 6650:6650 -p 8080:8080 apachepulsar/pulsar:latest bin/pulsar standalone
|
19
|
+
- docker exec pulsar bash -c 'ready (){ (exec > /dev/tcp/$1/$2); }; i=0; while ! ready localhost 8080; do sleep 1; i=$((i+1)); [[ $i -gt 10 ]] && break; done'
|
20
|
+
- docker exec pulsar bin/pulsar-admin tenants create ruby-client
|
21
|
+
- docker exec pulsar bin/pulsar-admin namespaces create ruby-client/tests
|
22
|
+
env:
|
23
|
+
global:
|
24
|
+
PULSAR_BROKER_URI: pulsar://localhost:6650
|
25
|
+
PULSAR_CLIENT_RUBY_TEST_NAMESPACE: ruby-client/tests
|
15
26
|
script:
|
16
27
|
- rake
|
data/Gemfile.lock
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pulsar-client (2.6.1.pre.beta.
|
4
|
+
pulsar-client (2.6.1.pre.beta.2)
|
5
5
|
rake-compiler (~> 1.0)
|
6
6
|
rice (~> 2.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
diff-lcs (1.
|
11
|
+
diff-lcs (1.4.4)
|
12
12
|
rake (10.5.0)
|
13
13
|
rake-compiler (1.1.1)
|
14
14
|
rake
|
15
15
|
rice (2.2.0)
|
16
|
-
rspec (3.
|
17
|
-
rspec-core (~> 3.
|
18
|
-
rspec-expectations (~> 3.
|
19
|
-
rspec-mocks (~> 3.
|
20
|
-
rspec-core (3.
|
21
|
-
rspec-support (~> 3.
|
22
|
-
rspec-expectations (3.
|
16
|
+
rspec (3.10.0)
|
17
|
+
rspec-core (~> 3.10.0)
|
18
|
+
rspec-expectations (~> 3.10.0)
|
19
|
+
rspec-mocks (~> 3.10.0)
|
20
|
+
rspec-core (3.10.1)
|
21
|
+
rspec-support (~> 3.10.0)
|
22
|
+
rspec-expectations (3.10.1)
|
23
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.
|
25
|
-
rspec-mocks (3.
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-mocks (3.10.2)
|
26
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.
|
28
|
-
rspec-support (3.
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-support (3.10.2)
|
29
29
|
|
30
30
|
PLATFORMS
|
31
31
|
ruby
|
@@ -37,4 +37,4 @@ DEPENDENCIES
|
|
37
37
|
rspec (~> 3.0)
|
38
38
|
|
39
39
|
BUNDLED WITH
|
40
|
-
1.
|
40
|
+
1.17.3
|
data/ext/bindings/client.cpp
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
#include "client.hpp"
|
7
7
|
#include "logger.hpp"
|
8
8
|
#include "util.hpp"
|
9
|
+
#include "vector.hpp"
|
9
10
|
|
10
11
|
namespace pulsar_rb {
|
11
12
|
|
@@ -133,7 +134,7 @@ Producer::ptr Client::create_producer(Rice::String topic, const ProducerConfigur
|
|
133
134
|
|
134
135
|
typedef struct {
|
135
136
|
pulsar::Client& client;
|
136
|
-
const Rice::
|
137
|
+
const Rice::Array& topics;
|
137
138
|
const Rice::String& subscriptionName;
|
138
139
|
const pulsar::ConsumerConfiguration& config;
|
139
140
|
pulsar::Consumer consumer;
|
@@ -142,12 +143,27 @@ typedef struct {
|
|
142
143
|
|
143
144
|
void* client_subscribe_worker(void* taskPtr) {
|
144
145
|
client_subscribe_task& task = *(client_subscribe_task*)taskPtr;
|
145
|
-
|
146
|
+
|
147
|
+
const std::vector<std::string>& topics = from_ruby<std::vector<std::string>>(task.topics);
|
148
|
+
switch(topics.size()) {
|
149
|
+
case 0:
|
150
|
+
throw Rice::Exception(rb_eArgError, "Must have at least one topic");
|
151
|
+
break;
|
152
|
+
case 1: {
|
153
|
+
// Skip the MultiTopicsConsumer if there's only one.
|
154
|
+
task.result = task.client.subscribe(topics[0], task.subscriptionName.str(), task.config, task.consumer);
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
default: {
|
158
|
+
task.result = task.client.subscribe(topics, task.subscriptionName.str(), task.config, task.consumer);
|
159
|
+
break;
|
160
|
+
}
|
161
|
+
}
|
146
162
|
return nullptr;
|
147
163
|
}
|
148
164
|
|
149
|
-
Consumer::ptr Client::subscribe(Rice::
|
150
|
-
client_subscribe_task task = { _client,
|
165
|
+
Consumer::ptr Client::subscribe(Rice::Array topics, Rice::String subscriptionName, const ConsumerConfiguration& config) {
|
166
|
+
client_subscribe_task task = { _client, topics, subscriptionName, config };
|
151
167
|
rb_thread_call_without_gvl(&client_subscribe_worker, &task, RUBY_UBF_IO, nullptr);
|
152
168
|
CheckResult(task.result);
|
153
169
|
return Consumer::ptr(new Consumer(task.consumer));
|
data/ext/bindings/client.hpp
CHANGED
@@ -47,7 +47,7 @@ namespace pulsar_rb {
|
|
47
47
|
Client(Rice::String service_url, const ClientConfiguration& config);
|
48
48
|
|
49
49
|
Producer::ptr create_producer(Rice::String topic, const ProducerConfiguration& config);
|
50
|
-
Consumer::ptr subscribe(Rice::
|
50
|
+
Consumer::ptr subscribe(Rice::Array topics, Rice::String subscriptionName, const ConsumerConfiguration& config);
|
51
51
|
void close();
|
52
52
|
|
53
53
|
typedef Rice::Data_Object<Client> ptr;
|
data/ext/bindings/consumer.cpp
CHANGED
@@ -82,6 +82,10 @@ void bind_consumer(Module &module) {
|
|
82
82
|
.define_value("Failover", ConsumerFailover)
|
83
83
|
.define_value("KeyShared", ConsumerKeyShared);
|
84
84
|
|
85
|
+
define_enum<pulsar::InitialPosition>("InitialPosition", module)
|
86
|
+
.define_value("Latest", InitialPositionLatest)
|
87
|
+
.define_value("Earliest", InitialPositionEarliest);
|
88
|
+
|
85
89
|
define_class_under<pulsar_rb::ConsumerConfiguration>(module, "ConsumerConfiguration")
|
86
90
|
.define_constructor(Constructor<pulsar_rb::ConsumerConfiguration>())
|
87
91
|
.define_method("consumer_type", &ConsumerConfiguration::getConsumerType)
|
data/ext/bindings/message.cpp
CHANGED
@@ -41,6 +41,7 @@ Message::Message(const std::string& data, Rice::Object arg = Rice::Object()) {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
_msg = mb.build();
|
44
|
+
received = false;
|
44
45
|
}
|
45
46
|
|
46
47
|
Rice::String Message::getData() {
|
@@ -65,6 +66,12 @@ Rice::String Message::getOrderingKey() {
|
|
65
66
|
return to_ruby(_msg.getOrderingKey());
|
66
67
|
}
|
67
68
|
|
69
|
+
Rice::Object Message::getTopicName() {
|
70
|
+
// If the message topic hasn't been set (it gets set when received, not when
|
71
|
+
// built) getTopicName will try to dereference a null pointer.
|
72
|
+
return received ? to_ruby(_msg.getTopicName()) : Rice::Nil;
|
73
|
+
}
|
74
|
+
|
68
75
|
}
|
69
76
|
|
70
77
|
using namespace Rice;
|
@@ -84,5 +91,6 @@ void bind_message(Module& module) {
|
|
84
91
|
.define_method("properties", &pulsar_rb::Message::getProperties)
|
85
92
|
.define_method("partition_key", &pulsar_rb::Message::getPartitionKey)
|
86
93
|
.define_method("ordering_key", &pulsar_rb::Message::getOrderingKey)
|
94
|
+
.define_method("topic", &pulsar_rb::Message::getTopicName)
|
87
95
|
;
|
88
96
|
}
|
data/ext/bindings/message.hpp
CHANGED
@@ -21,6 +21,7 @@ namespace pulsar_rb {
|
|
21
21
|
class Message {
|
22
22
|
public:
|
23
23
|
pulsar::Message _msg;
|
24
|
+
bool received = true; // received from consumer rather than built with builder
|
24
25
|
Message(const pulsar::Message& msg) : _msg(msg) {};
|
25
26
|
Message(const std::string& data, Rice::Object opts);
|
26
27
|
|
@@ -29,6 +30,7 @@ namespace pulsar_rb {
|
|
29
30
|
Rice::Hash getProperties();
|
30
31
|
Rice::String getPartitionKey();
|
31
32
|
Rice::String getOrderingKey();
|
33
|
+
Rice::Object getTopicName();
|
32
34
|
|
33
35
|
typedef Rice::Data_Object<Message> ptr;
|
34
36
|
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#include "rice/Array.hpp"
|
2
|
+
|
3
|
+
#include "vector.hpp"
|
4
|
+
|
5
|
+
template<>
|
6
|
+
std::vector<std::string> from_ruby<std::vector<std::string>>(Rice::Object o)
|
7
|
+
{
|
8
|
+
Rice::Array a(o);
|
9
|
+
std::vector<std::string> v;
|
10
|
+
Rice::Array::iterator it = a.begin();
|
11
|
+
Rice::Array::iterator end = a.end();
|
12
|
+
for(; it != end; ++it) {
|
13
|
+
v.push_back(it->to_s().str());
|
14
|
+
}
|
15
|
+
return v;
|
16
|
+
}
|
data/lib/pulsar/client.rb
CHANGED
@@ -33,6 +33,12 @@ module Pulsar
|
|
33
33
|
:key_shared => Pulsar::ConsumerType::KeyShared
|
34
34
|
}
|
35
35
|
|
36
|
+
# aligns with the pulsar::InitialPosition enum in the C++ library
|
37
|
+
INITIAL_POSITIONS = {
|
38
|
+
:latest => Pulsar::InitialPosition::Latest,
|
39
|
+
:earliest => Pulsar::InitialPosition::Earliest
|
40
|
+
}
|
41
|
+
|
36
42
|
module RubySideTweaks
|
37
43
|
def initialize(config={})
|
38
44
|
super()
|
@@ -53,6 +59,21 @@ module Pulsar
|
|
53
59
|
end
|
54
60
|
super(type)
|
55
61
|
end
|
62
|
+
|
63
|
+
def subscription_initial_position
|
64
|
+
enum_value = super
|
65
|
+
INITIAL_POSITIONS.invert[enum_value]
|
66
|
+
end
|
67
|
+
|
68
|
+
def subscription_initial_position=(type)
|
69
|
+
unless type.is_a?(Pulsar::InitialPosition)
|
70
|
+
type = INITIAL_POSITIONS[type]
|
71
|
+
unless type
|
72
|
+
raise ArgumentError, "unrecognized subscription_initial_position"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
super(type)
|
76
|
+
end
|
56
77
|
end
|
57
78
|
|
58
79
|
prepend RubySideTweaks
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulsar-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.1.pre.beta.
|
4
|
+
version: 2.6.1.pre.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Fugal
|
@@ -119,6 +119,8 @@ files:
|
|
119
119
|
- ext/bindings/stringmap.hpp
|
120
120
|
- ext/bindings/util.cpp
|
121
121
|
- ext/bindings/util.hpp
|
122
|
+
- ext/bindings/vector.cpp
|
123
|
+
- ext/bindings/vector.hpp
|
122
124
|
- lib/pulsar/client.rb
|
123
125
|
- lib/pulsar/client/version.rb
|
124
126
|
- lib/pulsar/client_configuration.rb
|
@@ -145,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
147
|
- !ruby/object:Gem::Version
|
146
148
|
version: 1.3.1
|
147
149
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
150
|
+
rubygems_version: 3.0.3
|
149
151
|
signing_key:
|
150
152
|
specification_version: 4
|
151
153
|
summary: Apache Pulsar Ruby Client
|