em-proxy 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/em-proxy.gemspec +76 -0
- data/examples/appserver.rb +3 -3
- data/examples/simple.rb +25 -0
- data/lib/em-proxy/proxy.rb +21 -21
- metadata +10 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/em-proxy.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{em-proxy}
|
8
|
+
s.version = "0.1.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ilya Grigorik"]
|
12
|
+
s.date = %q{2010-10-03}
|
13
|
+
s.description = %q{EventMachine Proxy DSL}
|
14
|
+
s.email = %q{ilya@igvita.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"em-proxy.gemspec",
|
23
|
+
"examples/appserver.rb",
|
24
|
+
"examples/beanstalkd_interceptor.rb",
|
25
|
+
"examples/duplex.rb",
|
26
|
+
"examples/line_interceptor.rb",
|
27
|
+
"examples/port_forward.rb",
|
28
|
+
"examples/relay_port_forward.rb",
|
29
|
+
"examples/schemaless-mysql/mysql_interceptor.rb",
|
30
|
+
"examples/selective_forward.rb",
|
31
|
+
"examples/simple.rb",
|
32
|
+
"examples/smtp_spam_filter.rb",
|
33
|
+
"examples/smtp_whitelist.rb",
|
34
|
+
"lib/em-proxy.rb",
|
35
|
+
"lib/em-proxy/backend.rb",
|
36
|
+
"lib/em-proxy/connection.rb",
|
37
|
+
"lib/em-proxy/proxy.rb",
|
38
|
+
"spec/helper.rb",
|
39
|
+
"spec/proxy_spec.rb"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/igrigorik/em-proxy}
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubyforge_project = %q{em-proxy}
|
45
|
+
s.rubygems_version = %q{1.3.7}
|
46
|
+
s.summary = %q{EventMachine Proxy DSL}
|
47
|
+
s.test_files = [
|
48
|
+
"spec/helper.rb",
|
49
|
+
"spec/proxy_spec.rb",
|
50
|
+
"examples/appserver.rb",
|
51
|
+
"examples/beanstalkd_interceptor.rb",
|
52
|
+
"examples/duplex.rb",
|
53
|
+
"examples/line_interceptor.rb",
|
54
|
+
"examples/port_forward.rb",
|
55
|
+
"examples/relay_port_forward.rb",
|
56
|
+
"examples/schemaless-mysql/mysql_interceptor.rb",
|
57
|
+
"examples/selective_forward.rb",
|
58
|
+
"examples/simple.rb",
|
59
|
+
"examples/smtp_spam_filter.rb",
|
60
|
+
"examples/smtp_whitelist.rb"
|
61
|
+
]
|
62
|
+
|
63
|
+
if s.respond_to? :specification_version then
|
64
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
+
s.specification_version = 3
|
66
|
+
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.9"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<eventmachine>, [">= 0.12.9"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<eventmachine>, [">= 0.12.9"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
data/examples/appserver.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "rack"
|
3
3
|
|
4
|
-
app =
|
4
|
+
app = Proc.new do
|
5
5
|
p [:serving, ARGV[0]]
|
6
6
|
|
7
|
-
|
7
|
+
sleep(ARGV[1].to_i)
|
8
8
|
[200, {"Content-Type" => "text/plain"}, ["hello world: #{ARGV[1]}"]]
|
9
|
-
|
9
|
+
end
|
10
10
|
|
11
11
|
Rack::Handler::Mongrel.run(app, {:Host => "0.0.0.0", :Port => ARGV[0]})
|
data/examples/simple.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'lib/em-proxy'
|
2
|
+
|
3
|
+
Proxy.start(:host => "0.0.0.0", :port => 8080, :debug => true) do |conn|
|
4
|
+
conn.server :srv, :host => "127.0.0.1", :port => 8081
|
5
|
+
|
6
|
+
# modify / process request stream
|
7
|
+
conn.on_data do |data|
|
8
|
+
p [:on_data, data]
|
9
|
+
data
|
10
|
+
end
|
11
|
+
|
12
|
+
# modify / process response stream
|
13
|
+
conn.on_response do |backend, resp|
|
14
|
+
p [:on_response, backend, resp]
|
15
|
+
resp
|
16
|
+
end
|
17
|
+
|
18
|
+
# termination logic
|
19
|
+
conn.on_finish do |backend, name|
|
20
|
+
p [:on_finish, name]
|
21
|
+
|
22
|
+
# terminate connection (in duplex mode, you can terminate when prod is done)
|
23
|
+
unbind if backend == :srv
|
24
|
+
end
|
25
|
+
end
|
data/lib/em-proxy/proxy.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
class Proxy
|
2
|
-
|
3
|
-
def self.start(options, &blk)
|
4
|
-
EM.epoll
|
5
|
-
EM.run do
|
6
|
-
|
7
|
-
trap("TERM") { stop }
|
8
|
-
trap("INT") { stop }
|
9
|
-
|
10
|
-
EventMachine::start_server(options[:host], options[:port],
|
11
|
-
EventMachine::ProxyServer::Connection, options) do |c|
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.stop
|
18
|
-
puts "Terminating ProxyServer"
|
19
|
-
EventMachine.stop
|
20
|
-
end
|
21
|
-
end
|
1
|
+
class Proxy
|
2
|
+
|
3
|
+
def self.start(options, &blk)
|
4
|
+
EM.epoll
|
5
|
+
EM.run do
|
6
|
+
|
7
|
+
trap("TERM") { stop }
|
8
|
+
trap("INT") { stop }
|
9
|
+
|
10
|
+
EventMachine::start_server(options[:host], options[:port],
|
11
|
+
EventMachine::ProxyServer::Connection, options) do |c|
|
12
|
+
c.instance_eval(&blk)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.stop
|
18
|
+
puts "Terminating ProxyServer"
|
19
|
+
EventMachine.stop
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ilya Grigorik
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-03 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: eventmachine
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -43,6 +44,7 @@ files:
|
|
43
44
|
- README.rdoc
|
44
45
|
- Rakefile
|
45
46
|
- VERSION
|
47
|
+
- em-proxy.gemspec
|
46
48
|
- examples/appserver.rb
|
47
49
|
- examples/beanstalkd_interceptor.rb
|
48
50
|
- examples/duplex.rb
|
@@ -51,6 +53,7 @@ files:
|
|
51
53
|
- examples/relay_port_forward.rb
|
52
54
|
- examples/schemaless-mysql/mysql_interceptor.rb
|
53
55
|
- examples/selective_forward.rb
|
56
|
+
- examples/simple.rb
|
54
57
|
- examples/smtp_spam_filter.rb
|
55
58
|
- examples/smtp_whitelist.rb
|
56
59
|
- lib/em-proxy.rb
|
@@ -69,6 +72,7 @@ rdoc_options:
|
|
69
72
|
require_paths:
|
70
73
|
- lib
|
71
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
72
76
|
requirements:
|
73
77
|
- - ">="
|
74
78
|
- !ruby/object:Gem::Version
|
@@ -76,6 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
80
|
- 0
|
77
81
|
version: "0"
|
78
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
79
84
|
requirements:
|
80
85
|
- - ">="
|
81
86
|
- !ruby/object:Gem::Version
|
@@ -85,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
90
|
requirements: []
|
86
91
|
|
87
92
|
rubyforge_project: em-proxy
|
88
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.7
|
89
94
|
signing_key:
|
90
95
|
specification_version: 3
|
91
96
|
summary: EventMachine Proxy DSL
|
@@ -100,5 +105,6 @@ test_files:
|
|
100
105
|
- examples/relay_port_forward.rb
|
101
106
|
- examples/schemaless-mysql/mysql_interceptor.rb
|
102
107
|
- examples/selective_forward.rb
|
108
|
+
- examples/simple.rb
|
103
109
|
- examples/smtp_spam_filter.rb
|
104
110
|
- examples/smtp_whitelist.rb
|