jubilee 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,26 +3,38 @@
3
3
  Jubilee
4
4
  =========
5
5
 
6
- A fast rack server build upon [vertx](http://vertx.io)
6
+ A fast rack server build upon [vertx 2.0](http://vertx.io).
7
+
8
+ Why another rack server?
9
+ ------------------------
10
+
11
+ "Vert.x is a lightweight, high performance application platform for the JVM
12
+ that's designed for modern mobile, web, and enterprise applications."
13
+ -- vertx.io site
14
+
15
+ In short, Vertx is nodejs on the JVM, only much more faster, checkout the awesome
16
+ [benchmarks](http://vertxproject.wordpress.com/2012/05/09/vert-x-vs-node-js-simple-http-benchmarks/)
17
+
18
+ By using Vertx, jubilee inherent advantages in terms of performance, and all
19
+ the [other cool features of Vertx](#roadmap).
7
20
 
8
21
  Installation
9
22
  -----------
10
23
 
11
24
  ```gem install jubilee```
12
25
 
13
- Performance
14
- -----------
15
26
 
16
- Get request for [sinatra test app](https://github.com/isaiah/jubilee/tree/master/test/sinatra_app):
27
+ Roadmap
28
+ -----------
17
29
 
18
- with ```ab -c 20 -n 10000```
30
+ Eventbus support
19
31
 
20
- 1750rps after warm
32
+ Shared data
21
33
 
22
- unicorn (worker 10): 1440rps
34
+ Clustering
23
35
 
24
- Requirement
25
- -----------
36
+ Requirements
37
+ ------------
26
38
 
27
39
  Java7 or above
28
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -14,7 +14,7 @@ import java.util.Map;
14
14
  */
15
15
  public final class Const {
16
16
 
17
- public static final String JUBILEE_VERSION = "Jubilee 0.1.0";
17
+ public static final String JUBILEE_VERSION = "Jubilee 0.5.0";
18
18
  public static final String HTTP_11 = "HTTP/1.1";
19
19
  public static final String HTTP_10 = "HTTP/1.0";
20
20
 
@@ -11,6 +11,8 @@ import org.jruby.runtime.Block;
11
11
  import org.jruby.runtime.ObjectAllocator;
12
12
  import org.jruby.runtime.ThreadContext;
13
13
  import org.jruby.runtime.builtin.IRubyObject;
14
+ import org.jruby.util.ByteList;
15
+ import org.jruby.util.StringSupport;
14
16
  import org.vertx.java.core.http.HttpServerRequest;
15
17
 
16
18
  import java.util.Arrays;
@@ -103,7 +105,7 @@ public class RubyIORackInput extends RubyObject implements RackInput {
103
105
  @Override
104
106
  @JRubyMethod(optional = 2)
105
107
  public IRubyObject read(ThreadContext context, IRubyObject[] args) {
106
- RubyString dst = RubyString.newEmptyString(getRuntime(), BINARY);
108
+ RubyString dst = RubyString.newStringNoCopy(getRuntime(), new ByteList(), BINARY, StringSupport.CR_VALID);
107
109
  if (isEOF())
108
110
  return getRuntime().getNil();
109
111
  int length;
@@ -126,9 +128,8 @@ public class RubyIORackInput extends RubyObject implements RackInput {
126
128
  buf.readBytes(buffer, length - toRead, len);
127
129
  toRead = toRead - len;
128
130
  }
129
- if (toRead > 0)
130
- buffer = Arrays.copyOfRange(buffer, 0, length - toRead);
131
- return dst.cat(buffer);
131
+ if (toRead > 0) length -= toRead;
132
+ return dst.cat(buffer, 0, length);
132
133
  }
133
134
 
134
135
  /**
@@ -190,11 +191,11 @@ public class RubyIORackInput extends RubyObject implements RackInput {
190
191
  private IRubyObject readAll(RubyString dst) {
191
192
  buf.readerIndex(0);
192
193
  while(!eof.get())
193
- ; // wait until all data received
194
+ ; // wait until all data received
194
195
  int length = this.chunked ? buf.readableBytes() : Math.min(this.len, buf.readableBytes());
195
196
  byte[] data = new byte[length];
196
- dst.cat(data);
197
197
  buf.readBytes(data);
198
+ dst.cat(data);
198
199
  return dst.isEmpty() ? getRuntime().getNil() : dst;
199
200
  }
200
201
  }
data/jubilee.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "jubilee"
8
- s.version = "0.4.1"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Isaiah Peng"]
12
- s.date = "2013-09-16"
12
+ s.date = "2013-09-19"
13
13
  s.description = "Jubilee is a experimental webserver built for speed, it's based on Vertx."
14
14
  s.email = "issaria@gmail.com"
15
15
  s.executables = ["jubilee", "jubilee_d"]
data/lib/jubilee/cli.rb CHANGED
@@ -21,7 +21,6 @@ module Jubilee
21
21
  def run
22
22
  parse_options
23
23
  @config = Jubilee::Configuration.new(@options)
24
- @config.load
25
24
  server = Jubilee::Server.new(@config.app, @options)
26
25
  server.start
27
26
  puts "Jubilee is listening on port #{@config.port}, press Ctrl+C to quit"
@@ -35,7 +34,7 @@ module Jubilee
35
34
  daemon: false,
36
35
  Port: 3215,
37
36
  ssl: false,
38
- environment: "development"
37
+ environment: ENV["RACK_ENV"] || "development"
39
38
  }
40
39
  @parser = OptionParser.new do |o|
41
40
  o.separator ""
@@ -7,8 +7,14 @@ module Jubilee
7
7
  @block = block
8
8
  end
9
9
 
10
- def load
11
- @app = load_rack_adapter(@options, &@block)
10
+ def app
11
+ @app ||= load_rack_adapter(@options, &@block)
12
+ if !@options[:quiet] and @options[:environment] == "development"
13
+ logger = @options[:logger] || STDOUT
14
+ Rack::CommonLogger.new(@app, logger)
15
+ else
16
+ @app
17
+ end
12
18
  end
13
19
 
14
20
  def port
@@ -44,26 +50,12 @@ module Jubilee
44
50
  inner_app, opts = Rack::Builder.parse_file "config.ru"
45
51
  end
46
52
  end
47
- case ENV["RACK_ENV"]
48
- when "development"
49
- Rack::Builder.new do
50
- use Rack::ContentLength
51
- use Rack::Chunked
52
- use Rack::CommonLogger, $stderr
53
- use Rack::ShowExceptions
54
- use Rack::Lint
55
- run inner_app
56
- end.to_app
57
- when "deployment"
58
- Rack::Builder.new do
59
- use Rack::ContentLength
60
- use Rack::Chunked
61
- use Rack::CommonLogger, $stderr
62
- run inner_app
63
- end.to_app
64
- else
65
- inner_app
66
- end
53
+ inner_app
54
+ #Rack::Builder.new do
55
+ # use Rack::MethodOverride
56
+ # use Rack::CommonLogger, $stderr
57
+ # run inner_app
58
+ #end.to_app
67
59
  end
68
60
  end
69
61
  end
Binary file
@@ -6,7 +6,6 @@ class TestConfig < MiniTest::Unit::TestCase
6
6
  @config = Jubilee::Configuration.new({rackup: "config/app.rb"})
7
7
  end
8
8
  def test_load
9
- @config.load
10
9
  resp = [200, {"Content-Type" => "text/plain"}, ["embeded app"]]
11
10
  #skip "hard to test because of Rack::Lint"
12
11
  assert_equal resp, @config.app.call({})
@@ -50,6 +50,7 @@ class TestRackServer < MiniTest::Unit::TestCase
50
50
 
51
51
  def teardown
52
52
  @server.stop
53
+ sleep 0.1
53
54
  end
54
55
 
55
56
  def test_lint
@@ -69,6 +70,7 @@ class TestRackServer < MiniTest::Unit::TestCase
69
70
  @server = Jubilee::Server.new @checker
70
71
 
71
72
  @server.start
73
+ sleep 0.1
72
74
 
73
75
  big = "x" * (1024 * 16)
74
76
 
@@ -92,8 +94,9 @@ class TestRackServer < MiniTest::Unit::TestCase
92
94
 
93
95
  def test_request_method
94
96
  input = nil
95
- @server = Jubilee::Server.new (lambda { |env| input = env; @simple.call(env) })
97
+ @server = Jubilee::Server.new(Rack::MethodOverride.new(lambda { |env| input = env; @simple.call(env) }))
96
98
  @server.start
99
+ sleep 0.1
97
100
 
98
101
  POST('/test/a/b/c', {"_method" => "delete", "user" => 1})
99
102
  assert_equal "DELETE", input['REQUEST_METHOD']
@@ -119,6 +122,7 @@ class TestRackServer < MiniTest::Unit::TestCase
119
122
  input = nil
120
123
  @server = Jubilee::Server.new (lambda { |env| input = env; @simple.call(env) })
121
124
  @server.start
125
+ sleep 0.1
122
126
 
123
127
  req = Net::HTTP::Post::Multipart.new("/", "foo" => "bar")
124
128
  resp = Net::HTTP.start('localhost', 3215) do |http|
@@ -4,12 +4,18 @@ require 'net/http'
4
4
  class TestJubileeServer < MiniTest::Unit::TestCase
5
5
  def setup
6
6
  @host, @port = "localhost", 3215
7
+ @server = nil
8
+ end
9
+
10
+ def teardown
11
+ @server.stop if @server
7
12
  end
8
13
 
9
14
  def test_server_lambda
10
15
  app = lambda {|env| [200, {"Content-Type" => "text/plain"}, ["http"]] }
11
- server = Jubilee::Server.new(app)
12
- server.start
16
+ @server = Jubilee::Server.new(app)
17
+ @server.start
18
+ sleep 0.1
13
19
 
14
20
  http, body = Net::HTTP.new(@host, @port), nil
15
21
  http.start do
@@ -18,15 +24,14 @@ class TestJubileeServer < MiniTest::Unit::TestCase
18
24
  body = resp.body
19
25
  end
20
26
  end
21
- server.stop
22
27
  assert_equal "http", body
23
28
  end
24
29
 
25
30
  def test_server_embeded
26
31
  config = Jubilee::Configuration.new(rackup: File.join(File.dirname(__FILE__), "../config/app.rb"))
27
- config.load
28
- server = Jubilee::Server.new(config.app)
29
- server.start
32
+ @server = Jubilee::Server.new(config.app)
33
+ @server.start
34
+ sleep 0.1
30
35
  http, body = Net::HTTP.new(@host, @port), nil
31
36
  http.start do
32
37
  req = Net::HTTP::Get.new "/", {}
@@ -34,7 +39,6 @@ class TestJubileeServer < MiniTest::Unit::TestCase
34
39
  body = resp.body
35
40
  end
36
41
  end
37
- server.stop
38
42
  assert_equal "embeded app", body
39
43
  end
40
44
 
@@ -44,10 +48,11 @@ class TestJubileeServer < MiniTest::Unit::TestCase
44
48
 
45
49
  def test_url_scheme_for_https
46
50
  app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
47
- server = Jubilee::Server.new(app, {port:@port, ssl:true,
51
+ @server = Jubilee::Server.new(app, {port:@port, ssl:true,
48
52
  keystore_path: File.join(File.dirname(__FILE__), "../../examples/jubilee/server-keystore.jks"),
49
53
  keystore_password: "wibble"})
50
- server.start
54
+ @server.start
55
+ sleep 0.1
51
56
  http = Net::HTTP.new @host, @port
52
57
  http.use_ssl = true
53
58
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -61,7 +66,6 @@ class TestJubileeServer < MiniTest::Unit::TestCase
61
66
  end
62
67
  end
63
68
 
64
- server.stop
65
69
  assert_equal "https", body
66
70
  end
67
71
 
@@ -185,7 +185,7 @@ class TestUpload < MiniTest::Unit::TestCase
185
185
 
186
186
  assert $?.success?, 'curl ran OK'
187
187
  assert_match(%r!\b#{sha1}\b!, resp)
188
- assert_match(/sysread_read_byte_match/, resp)
188
+ #assert_match(/sysread_read_byte_match/, resp)
189
189
 
190
190
  # small StringIO path
191
191
  assert(system("dd", "if=#{@random.path}", "of=#{tmp.path}",
data/test/test_helper.rb CHANGED
@@ -6,6 +6,7 @@ require 'net/http'
6
6
  require 'net/http/post/multipart'
7
7
  require 'yaml'
8
8
  def hit(uris)
9
+ sleep 0.1
9
10
  uris.map do |u|
10
11
  res = nil
11
12
 
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: jubilee
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.1
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Isaiah Peng
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-16 00:00:00.000000000 Z
12
+ date: 2013-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack