twirl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +1 -0
- data/examples/server.rb +37 -0
- data/lib/twirl.rb +8 -0
- data/lib/twirl/cluster.rb +317 -0
- data/lib/twirl/instrumentation/log_subscriber.rb +35 -0
- data/lib/twirl/instrumentation/statsd.rb +6 -0
- data/lib/twirl/instrumentation/statsd_subscriber.rb +28 -0
- data/lib/twirl/instrumentation/subscriber.rb +60 -0
- data/lib/twirl/instrumenters/memory.rb +26 -0
- data/lib/twirl/instrumenters/noop.rb +9 -0
- data/lib/twirl/item.rb +49 -0
- data/lib/twirl/server.rb +253 -0
- data/lib/twirl/version.rb +3 -0
- data/script/bootstrap +21 -0
- data/script/kestrel +34 -0
- data/script/release +42 -0
- data/script/test +25 -0
- data/script/watch +29 -0
- data/test/cluster_test.rb +469 -0
- data/test/helper.rb +65 -0
- data/test/instrumentation/log_subscriber_test.rb +51 -0
- data/test/instrumentation/statsd_test.rb +173 -0
- data/test/instrumenters/memory_test.rb +22 -0
- data/test/instrumenters/noop_test.rb +16 -0
- data/test/integration/cluster_test.rb +199 -0
- data/test/item_test.rb +43 -0
- data/test/support/fake_udp_socket.rb +27 -0
- data/test/twirl_test.rb +11 -0
- data/twirl.gemspec +23 -0
- metadata +121 -0
data/test/item_test.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "twirl/item"
|
3
|
+
|
4
|
+
class ItemTest < Minitest::Test
|
5
|
+
def test_initialize
|
6
|
+
client = Object.new
|
7
|
+
item = build(:item, "events", "data", client)
|
8
|
+
assert_equal "events", item.key
|
9
|
+
assert_equal "data", item.value
|
10
|
+
assert_equal client, item.client
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_close
|
14
|
+
key = "events"
|
15
|
+
client = Minitest::Mock.new
|
16
|
+
client.expect :close, :closed, [key]
|
17
|
+
|
18
|
+
item = build(:item, key, "data", client)
|
19
|
+
assert_equal :closed, item.close
|
20
|
+
|
21
|
+
client.verify
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_abort
|
25
|
+
key = "events"
|
26
|
+
client = Minitest::Mock.new
|
27
|
+
client.expect :abort, :aborted, [key]
|
28
|
+
|
29
|
+
item = build(:item, key, "data", client)
|
30
|
+
assert_equal :aborted, item.abort
|
31
|
+
|
32
|
+
client.verify
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_eql
|
36
|
+
client = Object.new
|
37
|
+
item = build(:item, "events", "data", client)
|
38
|
+
|
39
|
+
assert item.eql?(build(:item, "events", "data", client))
|
40
|
+
|
41
|
+
assert ! item.eql?(build(:item, "events", "data", Object.new))
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class FakeUDPSocket
|
2
|
+
attr_reader :buffer
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@buffer = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def send(message, *rest)
|
9
|
+
@buffer.push [message]
|
10
|
+
end
|
11
|
+
|
12
|
+
def recv
|
13
|
+
@buffer.shift
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear
|
17
|
+
@buffer = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
def inspect
|
25
|
+
"<FakeUDPSocket: #{@buffer.inspect}>"
|
26
|
+
end
|
27
|
+
end
|
data/test/twirl_test.rb
ADDED
data/twirl.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twirl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "twirl"
|
8
|
+
spec.version = Twirl::VERSION
|
9
|
+
spec.authors = ["John Nunemaker"]
|
10
|
+
spec.email = ["nunemaker@gmail.com"]
|
11
|
+
spec.description = %q{Wrapper for kjess that works with multiple kestrel instances intelligently.}
|
12
|
+
spec.summary = %q{Wrapper for kjess that works with multiple kestrel instances intelligently.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "kjess", "~> 1.2.0"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twirl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Nunemaker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: kjess
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Wrapper for kjess that works with multiple kestrel instances intelligently.
|
47
|
+
email:
|
48
|
+
- nunemaker@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- examples/server.rb
|
59
|
+
- lib/twirl.rb
|
60
|
+
- lib/twirl/cluster.rb
|
61
|
+
- lib/twirl/instrumentation/log_subscriber.rb
|
62
|
+
- lib/twirl/instrumentation/statsd.rb
|
63
|
+
- lib/twirl/instrumentation/statsd_subscriber.rb
|
64
|
+
- lib/twirl/instrumentation/subscriber.rb
|
65
|
+
- lib/twirl/instrumenters/memory.rb
|
66
|
+
- lib/twirl/instrumenters/noop.rb
|
67
|
+
- lib/twirl/item.rb
|
68
|
+
- lib/twirl/server.rb
|
69
|
+
- lib/twirl/version.rb
|
70
|
+
- script/bootstrap
|
71
|
+
- script/kestrel
|
72
|
+
- script/release
|
73
|
+
- script/test
|
74
|
+
- script/watch
|
75
|
+
- test/cluster_test.rb
|
76
|
+
- test/helper.rb
|
77
|
+
- test/instrumentation/log_subscriber_test.rb
|
78
|
+
- test/instrumentation/statsd_test.rb
|
79
|
+
- test/instrumenters/memory_test.rb
|
80
|
+
- test/instrumenters/noop_test.rb
|
81
|
+
- test/integration/cluster_test.rb
|
82
|
+
- test/item_test.rb
|
83
|
+
- test/support/fake_udp_socket.rb
|
84
|
+
- test/twirl_test.rb
|
85
|
+
- twirl.gemspec
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.8.23
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Wrapper for kjess that works with multiple kestrel instances intelligently.
|
111
|
+
test_files:
|
112
|
+
- test/cluster_test.rb
|
113
|
+
- test/helper.rb
|
114
|
+
- test/instrumentation/log_subscriber_test.rb
|
115
|
+
- test/instrumentation/statsd_test.rb
|
116
|
+
- test/instrumenters/memory_test.rb
|
117
|
+
- test/instrumenters/noop_test.rb
|
118
|
+
- test/integration/cluster_test.rb
|
119
|
+
- test/item_test.rb
|
120
|
+
- test/support/fake_udp_socket.rb
|
121
|
+
- test/twirl_test.rb
|