krakow 0.3.4 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c4b142c9d4c137f48a3f4c863185346d6111e37
4
+ data.tar.gz: 56732c8b17e13d4e9d0b77880ac6658642e8cac6
5
+ SHA512:
6
+ metadata.gz: c8eff9207bbb250463f617befeb032f3a609744d0341f44d797dae80d0eb934ee27a630e7472d0ac6c08ed41b5c5c8cad5fc832dae26cd932a9d0e80909b1bd0
7
+ data.tar.gz: 8cb47618a5ba19cf26b3194c9a983f7b4e399ea387d8fd0258b0eb2361f39313c1b8e04c10c14d412ac9c32e310d53bd7d5051a3f7741b16fa8187f915399e96
@@ -1,3 +1,9 @@
1
+ ## v0.3.6
2
+ * Allow `:options` key within `Producer` to set low level connection settings
3
+ * Make snappy an optional dependency
4
+ * Add initial support for authentication
5
+ * Update allowed types for optional notifier
6
+
1
7
  ## v0.3.4
2
8
  * Explicitly require version file (#11 and #12)
3
9
 
data/README.md CHANGED
@@ -159,6 +159,11 @@ consumer = Krakow::Consumer.new(
159
159
  )
160
160
  ```
161
161
 
162
+ *NOTE*: snappy support requires the snappy
163
+ gem and is not provided by default, so you
164
+ will need to ensure it is installed either
165
+ on the system, or within the bundle.
166
+
162
167
  ### I need Deflate compression!
163
168
 
164
169
  OK!
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.add_dependency 'celluloid-io'
14
14
  s.add_dependency 'http'
15
15
  s.add_dependency 'multi_json'
16
- s.add_dependency 'snappy'
17
16
  s.add_dependency 'digest-crc'
18
17
  s.files = Dir['lib/**/*'] + %w(krakow.gemspec README.md CHANGELOG.md CONTRIBUTING.md LICENSE)
19
18
  s.extra_rdoc_files = %w(CHANGELOG.md CONTRIBUTING.md LICENSE)
@@ -0,0 +1,36 @@
1
+ require 'krakow'
2
+
3
+ module Krakow
4
+ class Command
5
+ # Publish single message
6
+ class Auth < Command
7
+
8
+ # @!group Attributes
9
+
10
+ # @!macro [attach] attribute
11
+ # @!method $1
12
+ # @return [$2] the $1 $0
13
+ # @!method $1?
14
+ # @return [TrueClass, FalseClass] truthiness of the $1 $0
15
+ attribute :secret, String, :required => true
16
+
17
+ # @!endgroup
18
+
19
+ def to_line
20
+ scrt = secret.to_s
21
+ [name, "\n", scrt.length, scrt].pack('a*a*a*a*l>a*')
22
+ end
23
+
24
+ class << self
25
+ def ok
26
+ %w(OK)
27
+ end
28
+
29
+ def error
30
+ %w(E_AUTH_FAILED E_UNAUTHORIZED)
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -33,14 +33,15 @@ module Krakow
33
33
  :deflate_level,
34
34
  :max_deflate_level,
35
35
  :snappy,
36
- :sample_rate
36
+ :sample_rate,
37
+ :auth_required
37
38
  ]
38
39
 
39
40
  # List of features that may not be enabled together
40
41
  EXCLUSIVE_FEATURES = [[:snappy, :deflate]]
41
42
 
42
43
  # List of features that may be enabled by the client
43
- ENABLEABLE_FEATURES = [:tls_v1, :snappy, :deflate]
44
+ ENABLEABLE_FEATURES = [:tls_v1, :snappy, :deflate, :auth_required]
44
45
 
45
46
  finalizer :goodbye_my_love!
46
47
 
@@ -66,7 +67,7 @@ module Krakow
66
67
  attribute :queue, Queue, :default => ->{ Queue.new }
67
68
  attribute :callbacks, Hash, :default => ->{ Hash.new }
68
69
  attribute :responses, Queue, :default => ->{ Queue.new }
69
- attribute :notifier, Celluloid::Actor
70
+ attribute :notifier, [Celluloid::Signals, Celluloid::Condition, Celluloid::Actor]
70
71
  attribute :features, Hash, :default => ->{ Hash.new }
71
72
  attribute :response_wait, Numeric, :default => 1.0
72
73
  attribute :response_interval, Numeric, :default => 0.03
@@ -343,6 +344,21 @@ module Krakow
343
344
  true
344
345
  end
345
346
 
347
+ # Send authentication request for connection
348
+ #
349
+ # @return [TrueClass]
350
+ def auth_required
351
+ info 'Authentication required for this connection'
352
+ if(feature_args[:auth])
353
+ transmit(Command::Auth.new(:secret => feature_args[:auth]))
354
+ response = receive
355
+ true
356
+ else
357
+ error 'No authentication information provided for connection!'
358
+ abort 'Authentication failure. No authentication secret provided'
359
+ end
360
+ end
361
+
346
362
  # Enable snappy feature on underlying socket
347
363
  #
348
364
  # @return [TrueClass]
@@ -1,4 +1,9 @@
1
- require 'snappy'
1
+ begin
2
+ require 'snappy'
3
+ rescue LoadError
4
+ $stderr.puts 'ERROR: Failed to locate `snappy` gem. Install `snappy` gem into system or bundle.'
5
+ raise
6
+ end
2
7
  require 'digest/crc'
3
8
  require 'krakow'
4
9
 
@@ -31,7 +31,7 @@ module Krakow
31
31
  attribute :backoff_interval, Numeric
32
32
  attribute :discovery_interval, Numeric, :default => 30
33
33
  attribute :discovery_jitter, Numeric, :default => 10.0
34
- attribute :notifier, Celluloid::Actor
34
+ attribute :notifier, [Celluloid::Signals, Celluloid::Condition, Celluloid::Actor]
35
35
  attribute :connection_options, Hash, :default => ->{ Hash.new }
36
36
 
37
37
  # @!endgroup
@@ -36,7 +36,7 @@ module Krakow
36
36
 
37
37
  def initialize(args={})
38
38
  super
39
- arguments[:connection_options] = {:features => {}, :config => {}}.merge(
39
+ arguments[:connection_options] = {:features => {}, :config => {}, :options => {}}.merge(
40
40
  arguments.fetch(:connection_options, {})
41
41
  )
42
42
  connect
@@ -48,12 +48,17 @@ module Krakow
48
48
  def connect
49
49
  info "Establishing connection to: #{host}:#{port}"
50
50
  begin
51
- @connection = Connection.new(
52
- :host => host,
53
- :port => port,
54
- :features => connection_options[:features],
55
- :features_args => connection_options[:config]
56
- )
51
+ con_args = connection_options[:options].dup.tap do |args|
52
+ args[:host] = host
53
+ args[:port] = port
54
+ if(connection_options[:features])
55
+ args[:features] = connection_options[:features]
56
+ end
57
+ if(connection_options[:config])
58
+ args[:features_args] = connection_options[:config]
59
+ end
60
+ end
61
+ @connection = Connection.new(con_args)
57
62
  connection.init!
58
63
  self.link connection
59
64
  info "Connection established: #{connection}"
@@ -1,7 +1,4 @@
1
1
  module Krakow
2
- # Custom version
3
- class Version < Gem::Version
4
- end
5
2
  # Current version
6
- VERSION = Version.new('0.3.4')
3
+ VERSION = Gem::Version.new('0.3.6')
7
4
  end
metadata CHANGED
@@ -1,94 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krakow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
5
- prerelease:
4
+ version: 0.3.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Roberts
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-12-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: celluloid-io
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: http
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: multi_json
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: snappy
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
52
+ - - ">="
76
53
  - !ruby/object:Gem::Version
77
54
  version: '0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: digest-crc
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
- - - ! '>='
59
+ - - ">="
84
60
  - !ruby/object:Gem::Version
85
61
  version: '0'
86
62
  type: :runtime
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
- - - ! '>='
66
+ - - ">="
92
67
  - !ruby/object:Gem::Version
93
68
  version: '0'
94
69
  description: NSQ ruby library
@@ -100,67 +75,67 @@ extra_rdoc_files:
100
75
  - CONTRIBUTING.md
101
76
  - LICENSE
102
77
  files:
78
+ - CHANGELOG.md
79
+ - CONTRIBUTING.md
80
+ - LICENSE
81
+ - README.md
82
+ - krakow.gemspec
103
83
  - lib/krakow.rb
104
- - lib/krakow/consumer.rb
105
- - lib/krakow/frame_type.rb
106
84
  - lib/krakow/command.rb
107
- - lib/krakow/version.rb
108
- - lib/krakow/distribution.rb
109
- - lib/krakow/utils/lazy.rb
110
- - lib/krakow/utils/logging.rb
111
- - lib/krakow/producer.rb
112
- - lib/krakow/producer/http.rb
113
- - lib/krakow/distribution/default.rb
114
- - lib/krakow/frame_type/response.rb
115
- - lib/krakow/frame_type/error.rb
116
- - lib/krakow/frame_type/message.rb
117
- - lib/krakow/command/pub.rb
85
+ - lib/krakow/command/auth.rb
118
86
  - lib/krakow/command/cls.rb
119
- - lib/krakow/command/touch.rb
120
87
  - lib/krakow/command/fin.rb
121
88
  - lib/krakow/command/identify.rb
122
- - lib/krakow/command/req.rb
123
- - lib/krakow/command/nop.rb
124
89
  - lib/krakow/command/mpub.rb
125
- - lib/krakow/command/sub.rb
90
+ - lib/krakow/command/nop.rb
91
+ - lib/krakow/command/pub.rb
126
92
  - lib/krakow/command/rdy.rb
93
+ - lib/krakow/command/req.rb
94
+ - lib/krakow/command/sub.rb
95
+ - lib/krakow/command/touch.rb
127
96
  - lib/krakow/connection.rb
128
- - lib/krakow/exceptions.rb
129
- - lib/krakow/utils.rb
130
- - lib/krakow/discovery.rb
131
97
  - lib/krakow/connection_features.rb
132
- - lib/krakow/connection_features/ssl.rb
133
- - lib/krakow/connection_features/snappy_frames.rb
134
98
  - lib/krakow/connection_features/deflate.rb
135
- - krakow.gemspec
136
- - README.md
137
- - CHANGELOG.md
138
- - CONTRIBUTING.md
139
- - LICENSE
99
+ - lib/krakow/connection_features/snappy_frames.rb
100
+ - lib/krakow/connection_features/ssl.rb
101
+ - lib/krakow/consumer.rb
102
+ - lib/krakow/discovery.rb
103
+ - lib/krakow/distribution.rb
104
+ - lib/krakow/distribution/default.rb
105
+ - lib/krakow/exceptions.rb
106
+ - lib/krakow/frame_type.rb
107
+ - lib/krakow/frame_type/error.rb
108
+ - lib/krakow/frame_type/message.rb
109
+ - lib/krakow/frame_type/response.rb
110
+ - lib/krakow/producer.rb
111
+ - lib/krakow/producer/http.rb
112
+ - lib/krakow/utils.rb
113
+ - lib/krakow/utils/lazy.rb
114
+ - lib/krakow/utils/logging.rb
115
+ - lib/krakow/version.rb
140
116
  homepage: http://github.com/chrisroberts/krakow
141
117
  licenses:
142
118
  - Apache 2.0
119
+ metadata: {}
143
120
  post_install_message:
144
121
  rdoc_options: []
145
122
  require_paths:
146
123
  - lib
147
124
  required_ruby_version: !ruby/object:Gem::Requirement
148
- none: false
149
125
  requirements:
150
- - - ! '>='
126
+ - - ">="
151
127
  - !ruby/object:Gem::Version
152
128
  version: '0'
153
129
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
130
  requirements:
156
- - - ! '>='
131
+ - - ">="
157
132
  - !ruby/object:Gem::Version
158
133
  version: '0'
159
134
  requirements: []
160
135
  rubyforge_project:
161
- rubygems_version: 1.8.24
136
+ rubygems_version: 2.2.2
162
137
  signing_key:
163
- specification_version: 3
138
+ specification_version: 4
164
139
  summary: NSQ library
165
140
  test_files: []
166
141
  has_rdoc: