electric_slide 0.0.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/Gemfile +1 -1
- data/Guardfile +9 -0
- data/README.markdown +151 -1
- data/Rakefile +2 -3
- data/electric_slide.gemspec +6 -2
- data/lib/electric_slide.rb +45 -42
- data/lib/electric_slide/agent.rb +48 -0
- data/lib/electric_slide/agent_strategy/fixed_priority.rb +55 -0
- data/lib/electric_slide/agent_strategy/longest_idle.rb +39 -0
- data/lib/electric_slide/call_queue.rb +335 -0
- data/lib/electric_slide/plugin.rb +10 -0
- data/lib/electric_slide/version.rb +4 -0
- data/spec/electric_slide/agent_spec.rb +23 -0
- data/spec/electric_slide/agent_strategy/fixed_priority_spec.rb +43 -0
- data/spec/electric_slide/call_queue_spec.rb +42 -0
- data/spec/electric_slide_spec.rb +40 -0
- data/spec/spec_helper.rb +4 -11
- metadata +51 -34
- data/lib/electric_slide/queue_strategy.rb +0 -18
- data/lib/electric_slide/queued_call.rb +0 -24
- data/lib/electric_slide/round_robin.rb +0 -46
- data/lib/electric_slide/round_robin_meetme.rb +0 -34
- data/spec/electric_slide/queue_strategy_spec.rb +0 -16
- data/spec/electric_slide/queued_call_spec.rb +0 -42
- data/spec/electric_slide/round_robin_spec.rb +0 -87
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ElectricSlide::RoundRobin do
|
4
|
-
def dummy_queued_call
|
5
|
-
dqc = ElectricSlide::QueuedCall.new dummy_call
|
6
|
-
flexmock(dqc).should_receive(:hold).once
|
7
|
-
flexmock(dqc).should_receive(:make_ready!).once
|
8
|
-
dqc
|
9
|
-
end
|
10
|
-
|
11
|
-
before :each do
|
12
|
-
@queue = ElectricSlide::RoundRobin.new
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "Queue is empty at start" do
|
16
|
-
subject { ElectricSlide::RoundRobin.new }
|
17
|
-
its(:queue) { should have(0).items }
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should properly enqueue a call' do
|
21
|
-
call = ElectricSlide::QueuedCall.new dummy_call
|
22
|
-
flexmock(call).should_receive(:hold).once
|
23
|
-
@queue.enqueue call
|
24
|
-
@queue.instance_variable_get(:@queue).first.should be call
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should return the call object that is passed in' do
|
28
|
-
call = dummy_queued_call
|
29
|
-
@queue.enqueue call
|
30
|
-
@queue.next_call.should be call
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should block an agent requesting a call until a call becomes available' do
|
34
|
-
call = dummy_queued_call
|
35
|
-
agent_thread = Thread.new { @queue.next_call }
|
36
|
-
|
37
|
-
# Give the agent thread a chance to block...
|
38
|
-
sleep 0.5
|
39
|
-
|
40
|
-
@queue.agents_waiting.count.should == 1
|
41
|
-
|
42
|
-
@queue.enqueue call
|
43
|
-
|
44
|
-
# Give the agent thread a chance to retrieve the call...
|
45
|
-
sleep 0.5
|
46
|
-
@queue.agents_waiting.count.should == 0
|
47
|
-
agent_thread.kill
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should unblock only one agent per call entering the queue' do
|
51
|
-
call = dummy_queued_call
|
52
|
-
agent1_thread = Thread.new { @queue.next_call }
|
53
|
-
agent2_thread = Thread.new { @queue.next_call }
|
54
|
-
|
55
|
-
# Give the agent threads a chance to block...
|
56
|
-
sleep 0.5
|
57
|
-
|
58
|
-
@queue.agents_waiting.count.should == 2
|
59
|
-
|
60
|
-
@queue.enqueue call
|
61
|
-
|
62
|
-
# Give the agent thread a chance to retrieve the call...
|
63
|
-
sleep 0.5
|
64
|
-
@queue.agents_waiting.count.should == 1
|
65
|
-
agent1_thread.kill
|
66
|
-
agent2_thread.kill
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should properly enqueue calls and return them in the same order' do
|
70
|
-
call1 = dummy_queued_call
|
71
|
-
call2 = dummy_queued_call
|
72
|
-
call3 = dummy_queued_call
|
73
|
-
threads = {}
|
74
|
-
|
75
|
-
threads[:call1] = Thread.new { @queue.enqueue call1 }
|
76
|
-
sleep 0.5
|
77
|
-
threads[:call2] = Thread.new { @queue.enqueue call2 }
|
78
|
-
sleep 0.5
|
79
|
-
threads[:call3] = Thread.new { @queue.enqueue call3 }
|
80
|
-
sleep 0.5
|
81
|
-
|
82
|
-
|
83
|
-
@queue.next_call.should be call1
|
84
|
-
@queue.next_call.should be call2
|
85
|
-
@queue.next_call.should be call3
|
86
|
-
end
|
87
|
-
end
|