rafka 0.0.2 → 0.0.3

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: e4861900561edde1a7a43bbb8319ec89c980e428
4
- data.tar.gz: 732c4291171910e6d85041533906978f81737319
3
+ metadata.gz: 99ead695e270579988fd23cf24916e200cd2b1ef
4
+ data.tar.gz: 81c104c0bb873885639a859769524376e9d8227f
5
5
  SHA512:
6
- metadata.gz: 3f96fcd1767372afbb7148322391588db0d88de704896a7fcc832ed4d630ebdd5992ede361817d4c9c959d227ad84733d6ddf784853c16722e7478fa5c773f6b
7
- data.tar.gz: a72191d83e658f7c98f32fdc17deab84f5dfc8f1ab157bddc71c7ba453ca7e3c3d0c13fa23ce038d9c886da7060d6469dafcab0f79efe117b27fa6cacf1af0a1
6
+ metadata.gz: d51fc45275b94bd15380da3ac7206cf5712be5721503ff7a2057f193f26ad0c3ab7ccd795ffa48933b204cc51c8359f7cb50dd2084e70a8332c70c9f93fb5042
7
+ data.tar.gz: 640b09f1ec736eb9388370452181a7d32567673d4ce668684a3ea9a0f3b4d883284cd54e864910f3aeb572af1d35af187058c522219a931ffa4f2cf475442b33
@@ -17,13 +17,10 @@ module Rafka
17
17
  # @option opts [String] :topic Kafka topic to consume (required)
18
18
  # @option opts [String] :group Kafka consumer group name (required)
19
19
  # @option opts [String] :id (random) Kafka consumer id
20
- # @option opts [Hash] :redis_opts ({}) Optional configuration for the
20
+ # @option opts [Hash] :redis ({}) Optional configuration for the
21
21
  # underlying Redis client
22
22
  def initialize(opts={})
23
- opts[:redis_opts] = {} if !opts[:redis_opts]
24
- opts = parse_opts(opts)
25
- client_id = "#{opts[:group]}:#{opts[:id]}"
26
- @redis = Redis.new(host: opts[:host], port: opts[:port], id: client_id)
23
+ @redis = Redis.new(parse_opts(opts))
27
24
  @topic = "topics:#{opts[:topic]}"
28
25
  end
29
26
 
@@ -66,14 +63,18 @@ module Rafka
66
63
 
67
64
  private
68
65
 
66
+ # @return [Hash]
69
67
  def parse_opts(opts)
70
- options = DEFAULTS.dup.merge(opts).merge(opts[:redis_opts])
71
- options[:id] = SecureRandom.hex if !options[:id]
72
-
73
68
  REQUIRED.each do |opt|
74
- raise "#{opt.inspect} option not provided" if !options[opt]
69
+ raise "#{opt.inspect} option not provided" if opts[opt].nil?
75
70
  end
76
71
 
72
+ rafka_opts = opts.reject { |k| k == :redis }
73
+ redis_opts = opts[:redis] || {}
74
+
75
+ options = DEFAULTS.dup.merge(rafka_opts).merge(redis_opts)
76
+ options[:id] = SecureRandom.hex if options[:id].nil?
77
+ options[:id] = "#{options[:group]}:#{options[:id]}"
77
78
  options
78
79
  end
79
80
  end
@@ -10,14 +10,12 @@ module Rafka
10
10
  # @param [Hash] opts
11
11
  # @option opts [String] :host ("localhost") server hostname
12
12
  # @option opts [Fixnum] :port (6380) server port
13
- # @options opts [Hash] :redis_opts Configuration options for the underlying
13
+ # @options opts [Hash] :redis Configuration options for the underlying
14
14
  # Redis client
15
15
  #
16
16
  # @return [Producer]
17
17
  def initialize(opts = {})
18
- opts[:redis_opts] = {} if !opts[:redis_opts]
19
- opts = parse_opts(opts)
20
- @redis = Redis.new(host: opts[:host], port: opts[:port])
18
+ @redis = Redis.new(parse_opts(opts))
21
19
  end
22
20
 
23
21
  # Produce a message. This is an asynchronous operation.
@@ -49,7 +47,9 @@ module Rafka
49
47
 
50
48
  # @return [Hash]
51
49
  def parse_opts(opts)
52
- DEFAULTS.dup.merge(opts).merge(opts[:redis_opts])
50
+ rafka_opts = opts.reject { |k| k == :redis }
51
+ redis_opts = opts[:redis] || {}
52
+ DEFAULTS.dup.merge(opts).merge(opts[:redis])
53
53
  end
54
54
  end
55
55
  end
data/lib/rafka/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rafka
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agis Anastasopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-06 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.3'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.3'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry-byebug
29
29
  requirement: !ruby/object:Gem::Requirement