Sha256: 6cea1af10ef2c4d375788c9911dd21dfc9529834ee94d4a8661d5df2301bd214

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:test)

task :default => :test

require 'async/http/protocol'

PROTOCOL = Async::HTTP::Protocol::HTTP2

task :debug do
	require 'async/logger'
	
	Async.logger.level = Logger::DEBUG
end

task :server do
	require 'async/reactor'
	require 'async/http/server'
	
	server = Async::HTTP::Server.new(Async::IO::Endpoint.tcp('0.0.0.0', 9294, reuse_port: true), PROTOCOL)
	
	Async::Reactor.run do
		server.run
	end
end

task :client do
	require 'async/reactor'
	require 'async/http/client'
	
	client = Async::HTTP::Client.new(Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true), PROTOCOL)
	
	Async::Reactor.run do
		response = client.get("/")
		
		puts response.inspect
		
		client.close
	end
end

task :wrk do
	require 'async/reactor'
	require 'async/http/server'
	
	app = lambda do |env|
		[200, {}, ["Hello World"]]
	end
	
	server = Async::HTTP::Server.new(Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true), app)
	
	process_count = Etc.nprocessors
	
	pids = process_count.times.collect do
		fork do
			Async::Reactor.run do
				server.run
			end
		end
	end

	url = "http://127.0.0.1:9294/"
	
	connections = process_count
	system("wrk", "-c", connections.to_s, "-d", "2", "-t", connections.to_s, url)

	pids.each do |pid|
		Process.kill(:KILL, pid)
		Process.wait pid
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
async-http-0.24.0 Rakefile
async-http-0.23.3 Rakefile
async-http-0.23.2 Rakefile
async-http-0.23.1 Rakefile
async-http-0.23.0 Rakefile
async-http-0.22.0 Rakefile
async-http-0.21.0 Rakefile
async-http-0.20.1 Rakefile
async-http-0.20.0 Rakefile
async-http-0.19.0 Rakefile
async-http-0.18.0 Rakefile
async-http-0.17.1 Rakefile