rom-kafka 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 4d9a99ade5720d02866116b79501fe55db215d7b
4
- data.tar.gz: 158384e1135ce7d407432a5aaba796b11c31e60f
3
+ metadata.gz: 3d8631833883999ca97e9adf2b6380a3e196af95
4
+ data.tar.gz: 79d40d534a95243e578606d73c177abd70ecddb8
5
5
  SHA512:
6
- metadata.gz: ac20ac252417b721d88d75be5e83896311429f155d2e1317e100e4c32f8d384739e471b512167a04bb7cedcdfaf4516c32b0f262cabe212681e3de84a160bff0
7
- data.tar.gz: a5bcca9a39c7a45b6c6862cfe6f919c44f02d33a80137d663d6176bf05da44d3d3c00f9d9535f66f20af25a45159bc2fa5fd607caa10d9b2304679e0f25084a0
6
+ metadata.gz: 979b7e2bc84945296660524cb654e934024d8154dae17c3eeb940399b3e679b0b1c14e1c1410181a690cb216622fb67eae94a9a85aa0fb5f96666a67f12b8804
7
+ data.tar.gz: f6779f28c402cb6dfddf92aecb0bf00557a685e62e904107504803affba54cc038174cd86165e9dc3eff3f3a49740222fa30a40d7bc4b1689eaa865216182389
data/.travis.yml CHANGED
@@ -17,16 +17,12 @@ before_install:
17
17
  - ./bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic scholars --partitions 3 --replication-factor 1
18
18
  - cd ../
19
19
  rvm:
20
- - '1.9.3'
21
- - '2.0'
22
20
  - '2.1'
23
21
  - '2.2'
22
+ - '2.3.0'
24
23
  - ruby-head
25
- - rbx-2 --1.9
26
- - rbx-2 --2.1
27
- - jruby-1.7-19mode
28
- - jruby-1.7-21mode
29
- - jruby-9.0.0.0
24
+ - rbx-2
25
+ - jruby-9000
30
26
  - jruby-head
31
27
  matrix:
32
28
  allow_failures:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v0.0.2 to be released
2
+
3
+ ### Added
4
+
5
+ * Thread-safety for connections (both producer and consumer) (nepalez)
6
+
7
+ [Compare v0.0.1...HEAD](https://github.com/rom-rb/rom-kafka/compare/v0.0.1...HEAD)
8
+
1
9
  ## v0.0.1 2015-09-16
2
10
 
3
11
  First public alpha-release.
data/Guardfile CHANGED
@@ -11,4 +11,4 @@ guard :rspec, cmd: "bundle exec rspec", all_on_start: true do
11
11
  watch("lib/rom-kafka.rb") { "spec" }
12
12
  watch("spec/spec_helper.rb") { "spec" }
13
13
 
14
- end # guard :rspec
14
+ end
data/README.md CHANGED
@@ -44,7 +44,7 @@ Compatibility
44
44
 
45
45
  Compatible to [ROM][rom] 0.9+, [Apache Kafka][kafka] 0.8+.
46
46
 
47
- Tested under [rubies compatible to MRI 1.9.3+][rubies].
47
+ Tested under [rubies supported by ROM][rubies].
48
48
 
49
49
  Uses [RSpec][rspec] 3.0+ for testing and [hexx-suit][hexx-suit] for dev/test tools collection.
50
50
 
data/lib/rom-kafka.rb CHANGED
@@ -1,3 +1 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "rom/kafka"
data/lib/rom/kafka.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require "attributes_dsl"
3
2
  require "poseidon"
4
3
  require "rom"
@@ -8,22 +7,18 @@ require "rom"
8
7
  # @see http://rom-rb.org/
9
8
  #
10
9
  module ROM
11
-
12
10
  # Apache Kafka support for ROM
13
11
  #
14
12
  # @see http://kafka.apache.org/
15
13
  #
16
14
  module Kafka
17
-
18
15
  require_relative "kafka/brokers"
19
16
  require_relative "kafka/connection"
20
17
  require_relative "kafka/dataset"
21
18
  require_relative "kafka/gateway"
22
19
  require_relative "kafka/relation"
23
20
  require_relative "kafka/create"
24
-
25
- end # module Kafka
21
+ end
26
22
 
27
23
  register_adapter(:kafka, Kafka)
28
-
29
- end # module ROM
24
+ end
@@ -1,9 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "brokers/broker"
4
2
 
5
3
  module ROM::Kafka
6
-
7
4
  # Value object describing a collection of brokers (host:port)
8
5
  #
9
6
  # Knows how to extract brokers from address lines and options
@@ -23,7 +20,6 @@ module ROM::Kafka
23
20
  # @author Andrew Kozin <Andrew.Kozin@gmail.com>
24
21
  #
25
22
  class Brokers
26
-
27
23
  include Equalizer.new(:to_a)
28
24
 
29
25
  # @!method initialize(lines, options)
@@ -37,11 +33,9 @@ module ROM::Kafka
37
33
  # @option options [#to_s, Array<#to_s>] :hosts
38
34
  # @option options [#to_i] :port
39
35
  #
40
- def initialize(*lines)
36
+ def initialize(*lines) # @todo: refactor using factories
41
37
  hosts, port = extract_hosts_and_port(lines)
42
38
  @brokers = extract_brokers(hosts, port)
43
-
44
- IceNine.deep_freeze(self)
45
39
  end
46
40
 
47
41
  # Returns array of string representations of brokers
@@ -66,7 +60,5 @@ module ROM::Kafka
66
60
  brokers = hosts.map { |host| Broker.new(host: host, port: port) }
67
61
  brokers.any? ? brokers : [Broker.new]
68
62
  end
69
-
70
- end # class Brokers
71
-
72
- end # module ROM::Kafka
63
+ end
64
+ end
@@ -1,9 +1,5 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  class Brokers
6
-
7
3
  # Describes an address to a brocker
8
4
  #
9
5
  # @example
@@ -19,7 +15,6 @@ module ROM::Kafka
19
15
  # @author Andrew Kozin <Andrew.Kozin@gmail.com>
20
16
  #
21
17
  class Broker
22
-
23
18
  include Equalizer.new(:port, :host)
24
19
 
25
20
  # Regex to extract host from address line
@@ -49,8 +44,6 @@ module ROM::Kafka
49
44
  line = options.fetch(:host) { "localhost" }
50
45
  @host = line[HOST]
51
46
  @port = (line[PORT] || options.fetch(:port) { 9092 }).to_i
52
-
53
- IceNine.deep_freeze(self)
54
47
  end
55
48
 
56
49
  # Returns the string representation of the broker in "host:port" format
@@ -60,9 +53,6 @@ module ROM::Kafka
60
53
  def to_s
61
54
  "#{host}:#{port}"
62
55
  end
63
-
64
- end # class Broker
65
-
66
- end # class Brokers
67
-
68
- end # module ROM::Kafka
56
+ end
57
+ end
58
+ end
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  # Describes the connection to Kafka cluster
6
3
  #
7
4
  # This is a base abstract class for producer and concumer connections.
@@ -11,12 +8,9 @@ module ROM::Kafka
11
8
  # @author Andrew Kozin <Andrew.Kozin@gmail.com>
12
9
  #
13
10
  class Connection
14
-
15
11
  extend AttributesDSL
16
12
 
17
13
  require_relative "connection/producer"
18
14
  require_relative "connection/consumer"
19
-
20
- end # class Connection
21
-
22
- end # module ROM::Kafka
15
+ end
16
+ end
@@ -1,9 +1,5 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  class Connection
6
-
7
3
  # The consumer-specific connection to Kafka cluster
8
4
  #
9
5
  # It is wrapped around `Poseidon::Consumer` driver, and responsible for
@@ -16,7 +12,6 @@ module ROM::Kafka
16
12
  # @api private
17
13
  #
18
14
  class Consumer < Connection
19
-
20
15
  include Enumerable
21
16
 
22
17
  # The 'poseidon'-specific class describing consumers
@@ -60,10 +55,12 @@ module ROM::Kafka
60
55
  # How long to block until the server sends data.
61
56
  # NOTE: This is only enforced if min_bytes is > 0.
62
57
  #
58
+ # @todo: refactor usinng factory method Connection.build_consumer
63
59
  def initialize(opts)
64
60
  super # takes declared attributes from options
65
61
  args = opts.values_at(:client_id, :brokers, :topic, :partition, :offset)
66
62
  @connection = DRIVER.consumer_for_partition(*args, attributes)
63
+ @mutex = Mutex.new
67
64
  end
68
65
 
69
66
  # Fetches a single portion of messages and converts them to tuple
@@ -71,8 +68,7 @@ module ROM::Kafka
71
68
  # @return [Array<Hash{Symbol => String, Integer}>]
72
69
  #
73
70
  def fetch
74
- result = @connection.fetch
75
- result.map(&method(:tuple))
71
+ @mutex.synchronize { @connection.fetch }.map(&method(:tuple))
76
72
  end
77
73
 
78
74
  # Iterates through Kafka messages
@@ -97,9 +93,6 @@ module ROM::Kafka
97
93
  def tuple(msg)
98
94
  { value: msg.value, topic: msg.topic, key: msg.key, offset: msg.offset }
99
95
  end
100
-
101
- end # class Consumer
102
-
103
- end # class Connection
104
-
105
- end # module ROM::Kafka
96
+ end
97
+ end
98
+ end
@@ -1,9 +1,5 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  class Connection
6
-
7
3
  # The producer-specific connection to Kafka cluster
8
4
  #
9
5
  # It is wrapped around `Poseidon::Producer` driver, and responsible for
@@ -73,11 +69,12 @@ module ROM::Kafka
73
69
  # @option options [Integer] :socket_timeout_ms (10_000)
74
70
  # How long the producer/consumer socket waits for any reply from server.
75
71
  #
76
- def initialize(options)
72
+ def initialize(options) # @todo: Refactor using factory method Connection.build_producer
77
73
  super # takes declared attributes only, skipping brokers and client_id
78
- brokers = options.fetch(:brokers)
79
- client = options.fetch(:client_id)
74
+ brokers = options.fetch(:brokers)
75
+ client = options.fetch(:client_id)
80
76
  @connection = DRIVER.new(brokers, client, attributes)
77
+ @mutex = Mutex.new
81
78
  end
82
79
 
83
80
  # Sends tuples to the underlying connection
@@ -90,9 +87,9 @@ module ROM::Kafka
90
87
  # The list of published tuples
91
88
  #
92
89
  def publish(*data)
93
- tuples = data.flatten.map(&method(:stringify_keys))
94
- @connection.send_messages tuples.map(&method(:message))
95
-
90
+ tuples = data.flatten.map(&method(:stringify_keys))
91
+ messages = tuples.map(&method(:message))
92
+ @mutex.synchronize { @connection.send_messages messages }
96
93
  tuples
97
94
  end
98
95
 
@@ -106,9 +103,6 @@ module ROM::Kafka
106
103
  def message(tuple)
107
104
  MESSAGE.new(*tuple.values_at(:topic, :value, :key))
108
105
  end
109
-
110
- end # class Producer
111
-
112
- end # class Connection
113
-
114
- end # module ROM::Kafka
106
+ end
107
+ end
108
+ end
@@ -1,11 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  # The namespace for Kafka-specific ROM commands
6
3
  #
7
4
  module Commands
8
-
9
5
  # The Kafka-specific implementation of ROM::Commands::Create
10
6
  #
11
7
  # @example
@@ -67,9 +63,6 @@ module ROM::Kafka
67
63
  def tuple(text)
68
64
  { value: text.to_s, topic: dataset.topic, key: key }
69
65
  end
70
-
71
- end # class Create
72
-
73
- end # module Commands
74
-
75
- end # module ROM::Kafka
66
+ end
67
+ end
68
+ end
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  # The dataset describes Kafka topic
6
3
  #
7
4
  # @api private
@@ -75,7 +72,7 @@ module ROM::Kafka
75
72
  @topic = topic.to_s
76
73
  @gateway = gateway
77
74
  @producer = gateway.producer
78
- @consumer = prepare_consumer
75
+ @consumer = prepare_consumer # @todo: refactor using a factory
79
76
  end
80
77
 
81
78
  # Returns a new dataset with updated consumer attributes
@@ -126,7 +123,5 @@ module ROM::Kafka
126
123
  enum = consumer.each
127
124
  limit.times { yield(enum.next) }
128
125
  end
129
-
130
- end # class Dataset
131
-
132
- end # module ROM::Kafka
126
+ end
127
+ end
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  # Describes the gateway to Kafka
6
3
  #
7
4
  # The gateway has 3 responsibilities:
@@ -112,12 +109,12 @@ module ROM::Kafka
112
109
  # How long to block until the server sends data.
113
110
  # NOTE: This is only enforced if min_bytes is > 0.
114
111
  #
115
- def initialize(*addresses)
112
+ def initialize(*addresses) # @todo: refactor the fat initializer
116
113
  options = Hash[addresses.pop]
117
- brokers = Brokers.new(addresses, options).to_a
114
+ brokers = Brokers.new(addresses, options).to_a # @todo: refactor using a factory
118
115
  super options.merge(brokers: brokers) # prepares #attributes
119
116
 
120
- @producer = Connection::Producer.new(attributes)
117
+ @producer = Connection::Producer.new(attributes) # @todo: refactor using a factory
121
118
  @datasets = {}
122
119
  end
123
120
 
@@ -159,7 +156,5 @@ module ROM::Kafka
159
156
  def dataset?(topic)
160
157
  self[topic] ? true : false
161
158
  end
162
-
163
- end # class Gateway
164
-
165
- end # module ROM::Kafka
159
+ end
160
+ end
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
2
-
3
1
  module ROM::Kafka
4
-
5
2
  # The Kafka-specific implementation of ROM::Relation
6
3
  #
7
4
  # @example
@@ -22,6 +19,7 @@ module ROM::Kafka
22
19
  class Relation < ROM::Relation
23
20
 
24
21
  adapter :kafka
22
+ forward :using
25
23
 
26
24
  # Kafka-specific alias for the ROM `.dataset` helper method.
27
25
  #
@@ -62,17 +60,5 @@ module ROM::Kafka
62
60
  def limit(value)
63
61
  using(limit: value)
64
62
  end
65
-
66
- # Returns new relation where dataset is updated with given attributes
67
- #
68
- # @param [Hash] attributes
69
- #
70
- # @return [ROM::Kafka::Relation]
71
- #
72
- def using(attributes)
73
- self.class.new dataset.using(attributes)
74
- end
75
-
76
- end # class Relation
77
-
78
- end # module ROM::Kafka
63
+ end
64
+ end
data/rom-kafka.gemspec CHANGED
@@ -1,12 +1,6 @@
1
- # encoding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "rom/kafka/version"
5
-
6
1
  Gem::Specification.new do |gem|
7
-
8
2
  gem.name = "rom-kafka"
9
- gem.version = ROM::Kafka::VERSION.dup
3
+ gem.version = "0.0.2"
10
4
  gem.author = ["Andrew Kozin"]
11
5
  gem.email = ["andrew.kozin@gmail.com"]
12
6
  gem.summary = "Kafka support for Ruby Object Mapper"
@@ -14,20 +8,19 @@ Gem::Specification.new do |gem|
14
8
  gem.homepage = "https://rom-rb.org"
15
9
  gem.license = "MIT"
16
10
 
17
- gem.files = `git ls-files -z`.split("\x0")
11
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
12
  gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
- gem.extra_rdoc_files = Dir["README.md", "LICENSE"]
13
+ gem.test_files = gem.files.grep(/^spec/)
14
+ gem.extra_rdoc_files = Dir["README.md", "LICENSE", "CHANGELOG.md"]
21
15
  gem.require_paths = ["lib"]
22
16
 
23
- gem.required_ruby_version = "~> 1.9", ">= 1.9.3"
17
+ gem.required_ruby_version = ">= 1.9.3"
24
18
 
25
- gem.add_runtime_dependency "rom", "~> 0.9", ">= 0.9.1"
26
- gem.add_runtime_dependency "poseidon", "~> 0.0", ">= 0.0.5"
27
- gem.add_runtime_dependency "attributes_dsl", "~> 0.0", ">= 0.0.2"
19
+ gem.add_runtime_dependency "rom", "~> 1.0"
20
+ gem.add_runtime_dependency "poseidon", "~> 0.0.5"
21
+ gem.add_runtime_dependency "attributes_dsl", "~> 0.1.0", ">= 0.1.1"
28
22
 
29
23
  gem.add_development_dependency "hexx-rspec", "~> 0.5"
30
24
  gem.add_development_dependency "inflecto", "~> 0.0", ">= 0.0.2"
31
25
  gem.add_development_dependency "timecop", "~> 0.8"
32
-
33
- end # Gem::Specification
26
+ end
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
1
  require "shared/scholars_topic"
3
2
 
4
3
  describe "Basic Usage" do
5
-
6
4
  include_context :scholars_topic
7
5
 
8
6
  let(:add_scholars) { insert.with(key: 0) }
@@ -54,5 +52,4 @@ describe "Basic Usage" do
54
52
  # To start from the next offset, we should set it explicitly.
55
53
  expect(scholars.call.to_a).to eql []
56
54
  end
57
-
58
- end # describe Basic Usage
55
+ end
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
1
  require "shared/scholars_topic"
3
2
 
4
3
  describe "Keys Usage" do
5
-
6
4
  include_context :scholars_topic
7
5
 
8
6
  it "works" do
@@ -30,5 +28,4 @@ describe "Keys Usage" do
30
28
  { value: "Philip", topic: "scholars", key: "5", offset: 1 }
31
29
  ]
32
30
  end
33
-
34
- end # describe Keys Usage
31
+ end
@@ -1,28 +1,19 @@
1
- # encoding: utf-8
2
-
3
1
  shared_examples :scholars_topic do
4
-
5
2
  let!(:rom) do
6
- env = ROM::Environment.new
7
- env.use :auto_registration
8
-
9
- setup = env.setup(
10
- :kafka, "localhost:9092",
3
+ options = {
11
4
  client_id: "admin",
12
- # use the number of partition as a key
13
- partitioner: -> key, total { key.to_i % total }
14
- )
5
+ partitioner: proc { |key, total| key.to_i % total }
6
+ }
7
+ ROM.container(:kafka, "localhost:9092", options) do |config|
8
+ config.use(:macros)
15
9
 
16
- setup.relation(:scholars)
17
- setup.commands(:scholars) do
18
- define(:create)
10
+ config.relation(:scholars)
11
+ config.commands(:scholars) do
12
+ define(:create)
13
+ end
19
14
  end
20
-
21
- setup.finalize
22
- setup.env
23
15
  end
24
16
 
25
17
  let(:scholars) { rom.relation(:scholars) }
26
18
  let(:insert) { rom.command(:scholars).create }
27
-
28
- end # shared_examples
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  begin
4
2
  require "hexx-suit"
5
3
  Hexx::Suit.load_metrics_for(self)
@@ -1,15 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Brokers::Broker do
4
2
 
5
3
  let(:broker) { described_class.new }
6
4
 
7
- describe ".new" do
8
- subject { broker }
9
-
10
- it { is_expected.to be_frozen }
11
- end # describe .new
12
-
13
5
  describe "#host" do
14
6
  subject { broker.host }
15
7
 
@@ -28,7 +20,7 @@ describe ROM::Kafka::Brokers::Broker do
28
20
 
29
21
  it { is_expected.to eql "localhost" }
30
22
  end
31
- end # describe #host
23
+ end
32
24
 
33
25
  describe "#port" do
34
26
  subject { broker.port }
@@ -56,13 +48,13 @@ describe ROM::Kafka::Brokers::Broker do
56
48
  expect(subject).to eql 9092
57
49
  end
58
50
  end
59
- end # describe #port
51
+ end
60
52
 
61
53
  describe "#to_s" do
62
54
  subject { described_class.new(host: :"127.0.0.1:9093").to_s }
63
55
 
64
56
  it { is_expected.to eql "127.0.0.1:9093" }
65
- end # describe #to_s
57
+ end
66
58
 
67
59
  describe "#==" do
68
60
  subject { broker == other }
@@ -84,6 +76,5 @@ describe ROM::Kafka::Brokers::Broker do
84
76
 
85
77
  it { is_expected.to eql false }
86
78
  end
87
- end # describe #==
88
-
89
- end # describe ROM::Kafka::Brokers::Broker
79
+ end
80
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Brokers do
4
2
 
5
3
  let(:default_brokers) { described_class.new }
@@ -7,12 +5,6 @@ describe ROM::Kafka::Brokers do
7
5
  described_class.new "foo", "bar:9093", hosts: ["baz:9092"], port: 9094
8
6
  end
9
7
 
10
- describe ".new" do
11
- subject { default_brokers }
12
-
13
- it { is_expected.to be_frozen }
14
- end # describe .new
15
-
16
8
  describe "#to_a" do
17
9
  context "by default" do
18
10
  subject { default_brokers.to_a }
@@ -25,7 +17,7 @@ describe ROM::Kafka::Brokers do
25
17
 
26
18
  it { is_expected.to eql ["foo:9094", "bar:9093", "baz:9092"] }
27
19
  end
28
- end # describe #to_a
20
+ end
29
21
 
30
22
  describe "#==" do
31
23
  subject { default_brokers == other }
@@ -41,6 +33,5 @@ describe ROM::Kafka::Brokers do
41
33
 
42
34
  it { is_expected.to eql false }
43
35
  end
44
- end # describe #==
45
-
46
- end # describe ROM::Kafka::Brokers
36
+ end
37
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Connection::Consumer do
4
2
 
5
3
  # ============================================================================
@@ -34,7 +32,7 @@ describe ROM::Kafka::Connection::Consumer do
34
32
  subject { consumer }
35
33
 
36
34
  it { is_expected.to be_kind_of Enumerable }
37
- end # describe .new
35
+ end
38
36
 
39
37
  describe "#connection" do
40
38
  subject { consumer.connection }
@@ -46,7 +44,7 @@ describe ROM::Kafka::Connection::Consumer do
46
44
 
47
45
  expect(subject).to eql(connection)
48
46
  end
49
- end # describe #connection
47
+ end
50
48
 
51
49
  describe "#fetch" do
52
50
  subject { consumer.fetch }
@@ -57,7 +55,7 @@ describe ROM::Kafka::Connection::Consumer do
57
55
  expect(connection).to receive(:fetch)
58
56
  expect(subject).to eql [tuple]
59
57
  end
60
- end # describe #fetch
58
+ end
61
59
 
62
60
  describe "#each" do
63
61
 
@@ -85,6 +83,5 @@ describe ROM::Kafka::Connection::Consumer do
85
83
  expect(subject).to eq [tuple, tuple]
86
84
  end
87
85
  end
88
- end # describe #each
89
-
90
- end # describe ROM::Kafka::Connection::Consumer
86
+ end
87
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Connection::Producer do
4
2
 
5
3
  # ============================================================================
@@ -44,7 +42,7 @@ describe ROM::Kafka::Connection::Producer do
44
42
  expect(driver).to receive(:new).with(brokers, client, attributes)
45
43
  expect(subject).to eql(connection)
46
44
  end
47
- end # describe #connection
45
+ end
48
46
 
49
47
  describe "#publish" do
50
48
  subject { producer.publish(*input) }
@@ -74,6 +72,5 @@ describe ROM::Kafka::Connection::Producer do
74
72
  it "returns the plain array of tuples" do
75
73
  expect(subject).to eql output
76
74
  end
77
- end # describe #publish
78
-
79
- end # describe ROM::Kafka::Connection::Producer
75
+ end
76
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Commands::Create do
4
2
 
5
3
  let(:command) { described_class.new relation }
@@ -12,19 +10,19 @@ describe ROM::Kafka::Commands::Create do
12
10
  subject { described_class.adapter }
13
11
 
14
12
  it { is_expected.to eql(:kafka) }
15
- end # describe .adapter
13
+ end
16
14
 
17
15
  describe ".new" do
18
16
  subject { command }
19
17
 
20
18
  it { is_expected.to be_kind_of ROM::Commands::Create }
21
- end # describe .new
19
+ end
22
20
 
23
21
  describe "#key" do
24
22
  subject { command.key }
25
23
 
26
24
  it { is_expected.to be_nil }
27
- end # describe #key
25
+ end
28
26
 
29
27
  describe "#with" do
30
28
  subject { command.with(key: "foo") }
@@ -40,7 +38,7 @@ describe ROM::Kafka::Commands::Create do
40
38
  it "updates the key" do
41
39
  expect(subject.key).to eql("foo")
42
40
  end
43
- end # describe #using
41
+ end
44
42
 
45
43
  describe "#call" do
46
44
  subject { command.call(:bar, ["baz"]) }
@@ -74,6 +72,5 @@ describe ROM::Kafka::Commands::Create do
74
72
  expect(subject).to eql output
75
73
  end
76
74
  end
77
- end # describe #call
78
-
79
- end # describe ROM::Kafka::Relation
75
+ end
76
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Dataset do
4
2
 
5
3
  let(:gateway_class) { ROM::Kafka::Gateway }
@@ -17,7 +15,7 @@ describe ROM::Kafka::Dataset do
17
15
  it "is initialized" do
18
16
  expect(subject).to eql gateway
19
17
  end
20
- end # describe #gateway
18
+ end
21
19
 
22
20
  describe "#topic" do
23
21
  subject { dataset.topic }
@@ -25,7 +23,7 @@ describe ROM::Kafka::Dataset do
25
23
  it "is initialized" do
26
24
  expect(subject).to eql topic
27
25
  end
28
- end # describe #topic
26
+ end
29
27
 
30
28
  describe "#attributes" do
31
29
  subject { dataset.attributes }
@@ -64,7 +62,7 @@ describe ROM::Kafka::Dataset do
64
62
  expect(subject).to eql attributes
65
63
  end
66
64
  end
67
- end # describe #attributes
65
+ end
68
66
 
69
67
  describe "#producer" do
70
68
  subject { dataset.producer }
@@ -72,7 +70,7 @@ describe ROM::Kafka::Dataset do
72
70
  it "is taken from #gateway" do
73
71
  expect(subject).to eql gateway.producer
74
72
  end
75
- end # describe #producer
73
+ end
76
74
 
77
75
  describe "#consumer" do
78
76
  subject { dataset.consumer }
@@ -102,7 +100,7 @@ describe ROM::Kafka::Dataset do
102
100
  expect(consumer_class).to receive(:new).with(options)
103
101
  expect(subject).to eql consumer
104
102
  end
105
- end # describe #consumer
103
+ end
106
104
 
107
105
  describe "#using" do
108
106
  subject { dataset.using(update) }
@@ -125,7 +123,7 @@ describe ROM::Kafka::Dataset do
125
123
  it "updates attributes" do
126
124
  expect(subject.attributes).to eql(dataset.attributes.merge(update))
127
125
  end
128
- end # describe #using
126
+ end
129
127
 
130
128
  describe "#each" do
131
129
  subject { dataset.to_a }
@@ -160,6 +158,5 @@ describe ROM::Kafka::Dataset do
160
158
 
161
159
  it { is_expected.to be_kind_of Enumerator }
162
160
  end
163
- end # describe #each
164
-
165
- end # describe ROM::Kafka::Dataset
161
+ end
162
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Gateway do
4
2
 
5
3
  let(:gateway) { described_class.new(client_id: :foo) }
@@ -18,7 +16,7 @@ describe ROM::Kafka::Gateway do
18
16
  expect { subject }.to raise_error ArgumentError
19
17
  end
20
18
  end
21
- end # describe .new
19
+ end
22
20
 
23
21
  describe "#brokers" do
24
22
  subject { gateway.brokers }
@@ -48,7 +46,7 @@ describe ROM::Kafka::Gateway do
48
46
 
49
47
  it { is_expected.to eql brokers }
50
48
  end
51
- end # describe #hosts
49
+ end
52
50
 
53
51
  describe "#attributes" do
54
52
  subject { gateway.attributes }
@@ -98,13 +96,13 @@ describe ROM::Kafka::Gateway do
98
96
 
99
97
  it { is_expected.to eql attributes }
100
98
  end
101
- end # describe #attributes
99
+ end
102
100
 
103
101
  describe "#[]" do
104
102
  subject { gateway[:foo] }
105
103
 
106
104
  it { is_expected.to eql(nil) }
107
- end # describe #[]
105
+ end
108
106
 
109
107
  describe "#dataset?" do
110
108
  before do
@@ -122,7 +120,7 @@ describe ROM::Kafka::Gateway do
122
120
 
123
121
  it { is_expected.to eql false }
124
122
  end
125
- end # describe #dataset
123
+ end
126
124
 
127
125
  describe "#dataset" do
128
126
  subject { gateway.dataset topic }
@@ -149,7 +147,7 @@ describe ROM::Kafka::Gateway do
149
147
  it "returns a dataset" do
150
148
  expect(subject).to eql(dataset)
151
149
  end
152
- end # describe #dataset
150
+ end
153
151
 
154
152
  describe "#producer" do
155
153
  subject { gateway.producer }
@@ -166,6 +164,5 @@ describe ROM::Kafka::Gateway do
166
164
  expect(subject).to eql producer
167
165
  expect(attributes).to eql gateway.attributes
168
166
  end
169
- end # describe #producer
170
-
171
- end # describe ROM::Kafka::Gateway
167
+ end
168
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  describe ROM::Kafka::Relation do
4
2
 
5
3
  let(:relation) { described_class.new dataset }
@@ -10,7 +8,7 @@ describe ROM::Kafka::Relation do
10
8
  subject { described_class.adapter }
11
9
 
12
10
  it { is_expected.to eql(:kafka) }
13
- end # describe .adapter
11
+ end
14
12
 
15
13
  describe ".topic" do
16
14
  subject { described_class.topic :foo }
@@ -21,19 +19,19 @@ describe ROM::Kafka::Relation do
21
19
  expect(described_class).to receive(:dataset).with(:foo)
22
20
  subject
23
21
  end
24
- end # describe .topic
22
+ end
25
23
 
26
24
  describe ".new" do
27
25
  subject { relation }
28
26
 
29
27
  it { is_expected.to be_kind_of ROM::Relation }
30
- end # describe .new
28
+ end
31
29
 
32
30
  describe "#dataset" do
33
31
  subject { relation.dataset }
34
32
 
35
33
  it { is_expected.to eql(dataset) }
36
- end # describe #dataset
34
+ end
37
35
 
38
36
  describe "#using" do
39
37
  subject { relation.using(options) }
@@ -48,7 +46,7 @@ describe ROM::Kafka::Relation do
48
46
  expect(dataset).to receive(:using).with(options)
49
47
  expect(subject.dataset).to eql(updated)
50
48
  end
51
- end # describe #using
49
+ end
52
50
 
53
51
  describe "#offset" do
54
52
  subject { relation.offset(value) }
@@ -63,7 +61,7 @@ describe ROM::Kafka::Relation do
63
61
  expect(dataset).to receive(:using).with(offset: value)
64
62
  expect(subject.dataset).to eql(updated)
65
63
  end
66
- end # describe #offset
64
+ end
67
65
 
68
66
  describe "#limit" do
69
67
  subject { relation.limit(value) }
@@ -78,7 +76,7 @@ describe ROM::Kafka::Relation do
78
76
  expect(dataset).to receive(:using).with(limit: value)
79
77
  expect(subject.dataset).to eql(updated)
80
78
  end
81
- end # describe #limit
79
+ end
82
80
 
83
81
  describe "#from" do
84
82
  subject { relation.from(3) }
@@ -91,6 +89,5 @@ describe ROM::Kafka::Relation do
91
89
  expect(dataset).to receive(:using).with(partition: 3)
92
90
  expect(subject.dataset).to eql(updated)
93
91
  end
94
- end # describe #where
95
-
96
- end # describe ROM::Kafka::Relation
92
+ end
93
+ end
metadata CHANGED
@@ -1,121 +1,109 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rom
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
- - - ">="
16
+ - - ~>
21
17
  - !ruby/object:Gem::Version
22
- version: 0.9.1
23
- type: :runtime
18
+ version: '1.0'
19
+ name: rom
24
20
  prerelease: false
21
+ type: :runtime
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0.9'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.9.1
26
+ version: '1.0'
33
27
  - !ruby/object:Gem::Dependency
34
- name: poseidon
35
28
  requirement: !ruby/object:Gem::Requirement
36
29
  requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '0.0'
40
- - - ">="
30
+ - - ~>
41
31
  - !ruby/object:Gem::Version
42
32
  version: 0.0.5
43
- type: :runtime
33
+ name: poseidon
44
34
  prerelease: false
35
+ type: :runtime
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '0.0'
50
- - - ">="
38
+ - - ~>
51
39
  - !ruby/object:Gem::Version
52
40
  version: 0.0.5
53
41
  - !ruby/object:Gem::Dependency
54
- name: attributes_dsl
55
42
  requirement: !ruby/object:Gem::Requirement
56
43
  requirements:
57
- - - "~>"
44
+ - - ~>
58
45
  - !ruby/object:Gem::Version
59
- version: '0.0'
60
- - - ">="
46
+ version: 0.1.0
47
+ - - '>='
61
48
  - !ruby/object:Gem::Version
62
- version: 0.0.2
63
- type: :runtime
49
+ version: 0.1.1
50
+ name: attributes_dsl
64
51
  prerelease: false
52
+ type: :runtime
65
53
  version_requirements: !ruby/object:Gem::Requirement
66
54
  requirements:
67
- - - "~>"
55
+ - - ~>
68
56
  - !ruby/object:Gem::Version
69
- version: '0.0'
70
- - - ">="
57
+ version: 0.1.0
58
+ - - '>='
71
59
  - !ruby/object:Gem::Version
72
- version: 0.0.2
60
+ version: 0.1.1
73
61
  - !ruby/object:Gem::Dependency
74
- name: hexx-rspec
75
62
  requirement: !ruby/object:Gem::Requirement
76
63
  requirements:
77
- - - "~>"
64
+ - - ~>
78
65
  - !ruby/object:Gem::Version
79
66
  version: '0.5'
80
- type: :development
67
+ name: hexx-rspec
81
68
  prerelease: false
69
+ type: :development
82
70
  version_requirements: !ruby/object:Gem::Requirement
83
71
  requirements:
84
- - - "~>"
72
+ - - ~>
85
73
  - !ruby/object:Gem::Version
86
74
  version: '0.5'
87
75
  - !ruby/object:Gem::Dependency
88
- name: inflecto
89
76
  requirement: !ruby/object:Gem::Requirement
90
77
  requirements:
91
- - - "~>"
78
+ - - ~>
92
79
  - !ruby/object:Gem::Version
93
80
  version: '0.0'
94
- - - ">="
81
+ - - '>='
95
82
  - !ruby/object:Gem::Version
96
83
  version: 0.0.2
97
- type: :development
84
+ name: inflecto
98
85
  prerelease: false
86
+ type: :development
99
87
  version_requirements: !ruby/object:Gem::Requirement
100
88
  requirements:
101
- - - "~>"
89
+ - - ~>
102
90
  - !ruby/object:Gem::Version
103
91
  version: '0.0'
104
- - - ">="
92
+ - - '>='
105
93
  - !ruby/object:Gem::Version
106
94
  version: 0.0.2
107
95
  - !ruby/object:Gem::Dependency
108
- name: timecop
109
96
  requirement: !ruby/object:Gem::Requirement
110
97
  requirements:
111
- - - "~>"
98
+ - - ~>
112
99
  - !ruby/object:Gem::Version
113
100
  version: '0.8'
114
- type: :development
101
+ name: timecop
115
102
  prerelease: false
103
+ type: :development
116
104
  version_requirements: !ruby/object:Gem::Requirement
117
105
  requirements:
118
- - - "~>"
106
+ - - ~>
119
107
  - !ruby/object:Gem::Version
120
108
  version: '0.8'
121
109
  description: Kafka support for Ruby Object Mapper
@@ -126,14 +114,15 @@ extensions: []
126
114
  extra_rdoc_files:
127
115
  - README.md
128
116
  - LICENSE
117
+ - CHANGELOG.md
129
118
  files:
130
- - ".coveralls.yml"
131
- - ".gitignore"
132
- - ".metrics"
133
- - ".rspec"
134
- - ".rubocop.yml"
135
- - ".travis.yml"
136
- - ".yardopts"
119
+ - .coveralls.yml
120
+ - .gitignore
121
+ - .metrics
122
+ - .rspec
123
+ - .rubocop.yml
124
+ - .travis.yml
125
+ - .yardopts
137
126
  - CHANGELOG.md
138
127
  - Gemfile
139
128
  - Guardfile
@@ -162,7 +151,6 @@ files:
162
151
  - lib/rom/kafka/dataset.rb
163
152
  - lib/rom/kafka/gateway.rb
164
153
  - lib/rom/kafka/relation.rb
165
- - lib/rom/kafka/version.rb
166
154
  - rom-kafka.gemspec
167
155
  - spec/integration/basic_usage_spec.rb
168
156
  - spec/integration/keys_usage_spec.rb
@@ -180,27 +168,24 @@ homepage: https://rom-rb.org
180
168
  licenses:
181
169
  - MIT
182
170
  metadata: {}
183
- post_install_message:
171
+ post_install_message:
184
172
  rdoc_options: []
185
173
  require_paths:
186
174
  - lib
187
175
  required_ruby_version: !ruby/object:Gem::Requirement
188
176
  requirements:
189
- - - "~>"
190
- - !ruby/object:Gem::Version
191
- version: '1.9'
192
- - - ">="
177
+ - - '>='
193
178
  - !ruby/object:Gem::Version
194
179
  version: 1.9.3
195
180
  required_rubygems_version: !ruby/object:Gem::Requirement
196
181
  requirements:
197
- - - ">="
182
+ - - '>='
198
183
  - !ruby/object:Gem::Version
199
184
  version: '0'
200
185
  requirements: []
201
- rubyforge_project:
202
- rubygems_version: 2.4.8
203
- signing_key:
186
+ rubyforge_project:
187
+ rubygems_version: 2.4.5
188
+ signing_key:
204
189
  specification_version: 4
205
190
  summary: Kafka support for Ruby Object Mapper
206
191
  test_files:
@@ -216,4 +201,3 @@ test_files:
216
201
  - spec/unit/dataset_spec.rb
217
202
  - spec/unit/gateway_spec.rb
218
203
  - spec/unit/relation_spec.rb
219
- has_rdoc:
@@ -1,13 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module ROM
4
-
5
- module Kafka
6
-
7
- # The semantic version of the module.
8
- # @see http://semver.org/ Semantic versioning 2.0
9
- VERSION = "0.0.1".freeze
10
-
11
- end # module Kafka
12
-
13
- end # module ROM