freddy 0.6.2 → 0.6.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: 44a7f8f93979bd780da752a3006932c11eb672f0
4
- data.tar.gz: fe7adb97b77d247ccf74b1188d3e9daa790571a0
3
+ metadata.gz: 8f97109147edff0d5b3632c66652601b61c6c476
4
+ data.tar.gz: f2d777e287b18015d886646957f622310feb2042
5
5
  SHA512:
6
- metadata.gz: 568ac400f07f7e4d94135d773dbf2f901937cde49e52d86df36793c7841f6d9780ed7d0b592018919ec271ab1d74256a5388159bd3a35e80a73ac98ab7a2b3ca
7
- data.tar.gz: cbee9c29ee173a7aab987edbe5d04d8ad214089572959cf55f986e92992f71d43d529480f64cf407fe012c0542cea8dce01409a49ff0ffe4e716f844a4b1543b
6
+ metadata.gz: 699e54d1b6a0fbde8c0bdde435b0177984ff3b0a80ad9f1d5698a98ef75ba32798475fda4cf16cdeb38e9ff7abebaac33347f2226ef1285dc7fe99dac09438ed
7
+ data.tar.gz: 8179925e34bd321be85ba9219513f7279c57b525efcea941beb5584fe6bfda0af4aa4ed149f427645969ee3f51c4babaff497152fe01c4f23783c041de13e01f
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  gem 'rspec'
4
4
  gem 'pry'
5
5
  gem 'codeclimate-test-reporter'
6
+ gem 'hamster', '~> 3.0'
6
7
 
7
8
  gemspec
data/freddy.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  else
9
9
  spec.name = "freddy"
10
10
  end
11
- spec.version = '0.6.2'
11
+ spec.version = '0.6.3'
12
12
  spec.authors = ["Urmas Talimaa"]
13
13
  spec.email = ["urmas.talimaa@gmail.com"]
14
14
  spec.description = %q{Messaging API}
@@ -31,6 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "oj", "~> 2.13"
32
32
  end
33
33
 
34
- spec.add_dependency "hamster", "~> 1.0.1.pre.rc3"
35
34
  spec.add_dependency "thread", "~> 0.1"
36
35
  end
data/lib/freddy.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'json'
2
2
  require 'thread/pool'
3
- require 'hamster/mutable_hash'
4
3
 
5
4
  Dir[File.dirname(__FILE__) + '/freddy/*.rb'].each(&method(:require))
6
5
 
@@ -1,23 +1,31 @@
1
1
  class Freddy
2
2
  class RequestManager
3
3
  def initialize(logger)
4
- @requests = Hamster.mutable_hash
4
+ @requests = ConcurrentHash.new
5
5
  @logger = logger
6
6
  end
7
7
 
8
8
  def no_route(correlation_id)
9
9
  if request = @requests[correlation_id]
10
- @requests.delete correlation_id
10
+ delete(correlation_id)
11
11
  request[:callback].call({error: 'Specified queue does not exist'}, nil)
12
12
  end
13
13
  end
14
14
 
15
15
  def store(correlation_id, opts)
16
- @requests.store(correlation_id, opts)
16
+ @requests[correlation_id] = opts
17
17
  end
18
18
 
19
19
  def delete(correlation_id)
20
20
  @requests.delete(correlation_id)
21
21
  end
22
+
23
+ class ConcurrentHash < Hash
24
+ # CRuby hash does not need any locks. Only adding when using JRuby.
25
+ if RUBY_PLATFORM == 'java'
26
+ require 'jruby/synchronized'
27
+ include JRuby::Synchronized
28
+ end
29
+ end
22
30
  end
23
31
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'hamster/experimental/mutable_set'
2
3
 
3
4
  describe 'Concurrency' do
4
5
  let(:freddy1) { Freddy.build(logger, config) }
@@ -88,7 +89,7 @@ describe 'Concurrency' do
88
89
  context 'concurrent executions of deliver_with_response' do
89
90
  let(:nr_of_threads) { 50 }
90
91
  let(:payload) { {pay: 'load'} }
91
- let(:msg_counter) { Hamster.mutable_set }
92
+ let(:msg_counter) { Hamster::MutableSet[] }
92
93
  let(:queue_name) { random_destination }
93
94
 
94
95
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urmas Talimaa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-10 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.13'
69
- - !ruby/object:Gem::Dependency
70
- name: hamster
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.0.1.pre.rc3
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.0.1.pre.rc3
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: thread
85
71
  requirement: !ruby/object:Gem::Requirement