posterous-lacquer 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,11 +1,11 @@
1
1
  = lacquer
2
2
 
3
- Rails drop in for Varnish support.
3
+ Rails drop in for Varnish support. This version is adapted from Russ Smith's gem and is in production use on posterous.com.
4
4
 
5
5
  == Install
6
6
  Basic installation
7
7
 
8
- rails generate lacquer install
8
+ sudo gem install posterous-lacquer
9
9
 
10
10
  config/initializers/lacquer.rb
11
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -7,7 +7,7 @@ module Lacquer
7
7
 
8
8
  stats = stats.collect do |stat|
9
9
  stat = stat.strip.match(/(\d+)\s+(.+)$/)
10
- { :key => stat[2], :value => stat[1] }
10
+ { :key => stat[2], :value => stat[1] } if stat
11
11
  end
12
12
  end
13
13
  end
@@ -18,23 +18,22 @@ module Lacquer
18
18
  end
19
19
  end
20
20
 
21
- private
21
+ # private
22
22
 
23
- # Sends commands over telnet to varnish servers listed in the config.
23
+ # Sends commands over telnet to varnish servers listed in the config.
24
24
  def send_command(command)
25
25
  Lacquer.configuration.varnish_servers.collect do |server|
26
+ # RAILS_DEFAULT_LOGGER.debug("POSTEROUS_LACQUER_DEBUG: running(#{command.inspect}) on #{server.inspect}")
26
27
  retries = 0
28
+ response = nil
27
29
  begin
28
30
  retries += 1
29
- response = []
30
31
  connection = Net::Telnet.new(
31
32
  'Host' => server[:host],
32
33
  'Port' => server[:port],
33
34
  'Timeout' => server[:timeout] || 5)
34
- connection.cmd(command) do |c|
35
- response.push c.strip
36
- c.strip
37
- end
35
+ connection.cmd(command + "\nquit\n") {|r| response = r.strip}
36
+ connection.close
38
37
  rescue Exception => e
39
38
  if retries < Lacquer.configuration.retries
40
39
  retry
@@ -44,15 +43,15 @@ module Lacquer
44
43
  :error_class => "Varnish Error, retried #{Lacquer.configuration.retries} times",
45
44
  :error_message => "Error while trying to connect to #{server[:host]}:#{server[:port]}: #{e}",
46
45
  :parameters => server,
47
- :response => response.join("\n")})
46
+ :response => response})
48
47
  else
49
48
  raise VarnishError.new("Error while trying to connect to #{server[:host]}:#{server[:port]} #{e}")
50
49
  end
51
- end
52
- ensure
53
- connection.close rescue nil
50
+ end
54
51
  end
52
+ response
55
53
  end
56
54
  end
55
+
57
56
  end
58
57
  end
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{lacquer}
8
- s.version = "0.2.1"
7
+ s.name = %q{posterous-lacquer}
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Russ Smith"]
12
- s.date = %q{2010-06-14}
11
+ s.authors = ["Garry Tan", "Russ Smith"]
12
+ s.date = %q{2010-09-03}
13
13
  s.description = %q{Rails drop in for Varnish support.}
14
- s.email = %q{russ@bashme.org}
14
+ s.email = %q{garry@posterous.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  "Rakefile",
25
25
  "VERSION",
26
26
  "init.rb",
27
- "lacquer.gemspec",
28
27
  "lib/generators/USAGE",
29
28
  "lib/generators/lacquer_generator.rb",
30
29
  "lib/generators/templates/initializer.rb",
@@ -35,31 +34,35 @@ Gem::Specification.new do |s|
35
34
  "lib/lacquer/delayed_job_job.rb",
36
35
  "lib/lacquer/resque_job.rb",
37
36
  "lib/lacquer/varnish.rb",
37
+ "posterous-lacquer.gemspec",
38
38
  "rails/init.rb",
39
- "test.rb",
40
- "test/helper.rb",
41
- "test/test_cache_utils.rb",
42
- "test/test_varnish_interface.rb"
39
+ "spec/lacquer/cache_utils_spec.rb",
40
+ "spec/lacquer/varnish_spec.rb",
41
+ "spec/spec.opts",
42
+ "spec/spec_helper.rb"
43
43
  ]
44
44
  s.homepage = %q{http://github.com/russ/lacquer}
45
45
  s.rdoc_options = ["--charset=UTF-8"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
47
+ s.rubygems_version = %q{1.3.7}
48
48
  s.summary = %q{Rails drop in for Varnish support.}
49
49
  s.test_files = [
50
- "test/helper.rb",
51
- "test/test_cache_utils.rb",
52
- "test/test_varnish_interface.rb"
50
+ "spec/lacquer/cache_utils_spec.rb",
51
+ "spec/lacquer/varnish_spec.rb",
52
+ "spec/spec_helper.rb"
53
53
  ]
54
54
 
55
55
  if s.respond_to? :specification_version then
56
56
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
57
57
  s.specification_version = 3
58
58
 
59
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
59
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
+ s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
60
61
  else
62
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
61
63
  end
62
64
  else
65
+ s.add_dependency(%q<rspec>, [">= 1.3.0"])
63
66
  end
64
67
  end
65
68
 
@@ -6,6 +6,8 @@ describe "Varnish" do
6
6
  Net::Telnet.stub!(:new).and_return(@telnet_mock)
7
7
  @telnet_mock.stub!(:close)
8
8
  @telnet_mock.stub!(:cmd)
9
+ @telnet_mock.stub!(:puts)
10
+ @telnet_mock.stub!(:waitfor)
9
11
  Lacquer.configuration.retries.should == 5
10
12
  end
11
13
 
@@ -48,7 +50,74 @@ describe "Varnish" do
48
50
 
49
51
  describe "when sending a stats command" do
50
52
  it "should return an array of stats" do
51
- @telnet_mock.stub!(:cmd).and_yield("200 200\n1000 Connections")
53
+ @telnet_mock.stub!(:cmd).and_yield(%Q[
54
+ 200 2023
55
+ 6263596 Client connections accepted
56
+ 6260911 Client requests received
57
+ 919605 Cache hits for pass
58
+ 2123848 Cache misses
59
+ 6723161 Backend conn. success
60
+ 6641493 Fetch with Length
61
+ 81512 Fetch wanted close
62
+ 11 Fetch failed
63
+ 1648 N struct sess_mem
64
+ 81 N struct sess
65
+ 22781 N struct object
66
+ 23040 N struct objectcore
67
+ 36047 N struct objecthead
68
+ 56108 N struct smf
69
+ 1646 N small free smf
70
+ 263 N large free smf
71
+ 55 N struct vbe_conn
72
+ 804 N worker threads
73
+ 1583 N worker threads created
74
+ 2114 N worker threads limited
75
+ 1609 N overflowed work requests
76
+ 1 N backends
77
+ 1693663 N expired objects
78
+ 400637 N LRU nuked objects
79
+ 10 N LRU moved objects
80
+ 254 HTTP header overflows
81
+ 2506470 Objects sent with write
82
+ 6263541 Total Sessions
83
+ 6260911 Total Requests
84
+ 40 Total pipe
85
+ 4599215 Total pass
86
+ 6722994 Total fetch
87
+ 2607029095 Total header bytes
88
+ 55280196533 Total body bytes
89
+ 6263536 Session Closed
90
+ 5 Session herd
91
+ 511352337 SHM records
92
+ 33376035 SHM writes
93
+ 33177 SHM flushes due to overflow
94
+ 208858 SHM MTX contention
95
+ 246 SHM cycles through buffer
96
+ 6361382 allocator requests
97
+ 54199 outstanding allocations
98
+ 953389056 bytes allocated
99
+ 120352768 bytes free
100
+ 323 SMS allocator requests
101
+ 151528 SMS bytes allocated
102
+ 151528 SMS bytes freed
103
+ 6723053 Backend requests made
104
+ 1 N vcl total
105
+ 1 N vcl available
106
+ 49 N total active purges
107
+ 197 N new purges added
108
+ 148 N old purges deleted
109
+ 6117 N objects tested
110
+ 60375 N regexps tested against
111
+ 140 N duplicate purges removed
112
+ 944407 HCB Lookups without lock
113
+ 3 HCB Lookups with lock
114
+ 2099076 HCB Inserts
115
+ 515351 Objects ESI parsed (unlock)
116
+ 35371 Client uptime
117
+
118
+ 500 22
119
+ Closing CLI connection
120
+ ].strip)
52
121
  stats = Lacquer::Varnish.new.stats
53
122
  stats.size.should be(1)
54
123
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posterous-lacquer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Garry Tan
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-02 00:00:00 -07:00
19
+ date: 2010-09-03 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -52,7 +52,6 @@ files:
52
52
  - Rakefile
53
53
  - VERSION
54
54
  - init.rb
55
- - lacquer.gemspec
56
55
  - lib/generators/USAGE
57
56
  - lib/generators/lacquer_generator.rb
58
57
  - lib/generators/templates/initializer.rb
@@ -63,6 +62,7 @@ files:
63
62
  - lib/lacquer/delayed_job_job.rb
64
63
  - lib/lacquer/resque_job.rb
65
64
  - lib/lacquer/varnish.rb
65
+ - posterous-lacquer.gemspec
66
66
  - rails/init.rb
67
67
  - spec/lacquer/cache_utils_spec.rb
68
68
  - spec/lacquer/varnish_spec.rb