fukafuka 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10f8691a292d51eab63f400b902da075a21da366
4
+ data.tar.gz: 0aa84fb0c51d3dd9bb38537a98027ad2ad38d3be
5
+ SHA512:
6
+ metadata.gz: 840161cb18f02e7d331e89a6ede0421eb7b6d6aee6265cc4ecf5117847e3d7553addcb74e2cc897ce1c0709bcc971616fea05d8d3da9ffc3224219401d6e7cac
7
+ data.tar.gz: 5555ccac9f734b27c4627157ab2c0880187533c89d5f007923c69b440bfd22231f4d7080fde6c50f318505e4d90ce3add0d95b9d32cac1a33a97ab3efddf706e
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ 2.4.1
@@ -0,0 +1,20 @@
1
+ sudo: required
2
+ services:
3
+ - docker
4
+ script:
5
+ - git rev-parse HEAD > REVISION
6
+ - docker build -t mozamimy/fukafuka .
7
+ env:
8
+ REPOSITORY: mozamimy/fukafuka
9
+ after_success:
10
+ - if [ "$TRAVIS_TAG" != "" ]; then
11
+ docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" &&
12
+ docker tag $REPOSITORY $REPOSITORY:`cat VERSION` &&
13
+ docker push $REPOSITORY:`cat VERSION` &&
14
+ docker tag $REPOSITORY $REPOSITORY:latest &&
15
+ docker push $REPOSITORY:latest ;
16
+ fi
17
+ notifications:
18
+ on_success: always
19
+ on_failure: always
20
+ on_start: false
@@ -0,0 +1,12 @@
1
+ FROM ruby:2.4
2
+ LABEL maintainer "mozamimy (Moza USANE) <alice@mozami.me>"
3
+
4
+ RUN apt-get update && apt-get upgrade -y
5
+
6
+ RUN mkdir /log
7
+
8
+ WORKDIR /app
9
+ COPY . /app
10
+ RUN bundle install -j4 --deployment --without 'development test'
11
+
12
+ CMD ["bundle", "exec", "unicorn", "-c", "/app/config/unicorn.rb"]
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fukafuka.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 mozamimy (Moza USANE)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Fukafuka
2
+
3
+ A tiny web application for load testing.
4
+ (Fuka (負荷) means 'load' in Japanese :rabbit:)
5
+
6
+ ## Usage
7
+
8
+ ### Production with Docker
9
+
10
+ ```
11
+ $ docker-compose build
12
+ $ docker-compose up
13
+ ```
14
+
15
+ Pre built images is here https://hub.docker.com/r/mozamimy/fukafuka/
16
+
17
+ ### Development
18
+
19
+ ```
20
+ $ bundle install
21
+ $ bundle exec rackup
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### GET /prime
27
+
28
+ ```
29
+ $ curl http://localhost:9292/prime?num=50
30
+ {"status":"ok","result":[[2,1],[5,2]]}
31
+ ```
32
+
33
+ ### GET /hexdigest
34
+
35
+ ```
36
+ $ curl "http://localhost:9292/hexdigest?str=rabbit&iteration=1000000"
37
+ {"status":"ok","result":"d37d96b42ad43384915e4513505c30c0b1c4e7c765b5577eda25b5dbd7f26d89"}
38
+ ```
39
+
40
+ ### GET /hello/revision
41
+
42
+ You should put `REVISION` file on application root directory.
43
+
44
+ ```
45
+ $ curl http://localhost:9292/hello/revision
46
+ 245753efa210be10d3f38809ad8cd46f231e388a
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Mozamimy/fukafuka.
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
57
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fukafuka"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require 'fukafuka'
2
+ require 'revision_plate'
3
+
4
+ map '/hello/revision' do
5
+ run RevisionPlate::App.new(File.join(__dir__, 'REVISION'))
6
+ end
7
+
8
+ run Fukafuka.app
@@ -0,0 +1,23 @@
1
+ working_directory '/app'
2
+
3
+ timeout (ENV['UNICORN_TIMEOUT'] || 30).to_i
4
+
5
+ if ENV['LISTEN_UNIX']
6
+ listen ENV['LISTEN_UNIX'], backlog: 2048
7
+ else
8
+ listen (ENV['PORT'] || 8080).to_i
9
+ end
10
+
11
+ preload_app true
12
+
13
+ worker_processes (ENV['WORKER_NUM'] || 8).to_i
14
+
15
+ pid_path = '/tmp/unicorn.pid'
16
+ pid pid_path
17
+ if ENV['UNICORN_LOG_TO_STDOUT'] == '1'
18
+ stdout_path '/dev/stdout'
19
+ stderr_path '/dev/stderr'
20
+ else
21
+ stderr_path '/log/unicorn-err.log'
22
+ stdout_path '/log/unicorn-out.log'
23
+ end
@@ -0,0 +1,11 @@
1
+ version: '3'
2
+ services:
3
+ app:
4
+ build:
5
+ context: .
6
+ environment:
7
+ TZ: Asia/Tokyo
8
+ RACK_ENV: production
9
+ UNICORN_LOG_TO_STDOUT: '1'
10
+ ports:
11
+ - '8080:8080'
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fukafuka/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fukafuka"
8
+ spec.version = Fukafuka::VERSION
9
+ spec.authors = ["mozamimy (Moza USANE)"]
10
+ spec.email = ["alice@mozami.me"]
11
+
12
+ spec.summary = %q{A simple web application for load testing.}
13
+ spec.description = %q{A simple web application for load testing.}
14
+ spec.homepage = "https://github.com/mozamimy/fukafuka"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "sinatra"
25
+ spec.add_dependency "sinatra-contrib"
26
+ spec.add_dependency "revision_plate"
27
+ spec.add_dependency "unicorn"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.14"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ end
@@ -0,0 +1,2 @@
1
+ require 'fukafuka/version'
2
+ require 'fukafuka/app'
@@ -0,0 +1,46 @@
1
+ require 'sinatra/base'
2
+ require 'sinatra/reloader'
3
+ require 'prime'
4
+
5
+ module Fukafuka
6
+ def self.app
7
+ App.rack
8
+ end
9
+
10
+ class App < Sinatra::Base
11
+ configure :development do
12
+ register Sinatra::Reloader
13
+ end
14
+
15
+ set :environment, ENV['RACK_ENV'] == 'deployment' ? :production : ENV['RACK_ENV'].to_sym
16
+
17
+ def self.rack
18
+ app = lambda { |env|
19
+ App.call(env)
20
+ }
21
+ end
22
+
23
+ get '/prime' do
24
+ num = Integer(params[:num])
25
+ {
26
+ 'status' => 'ok',
27
+ 'result' => Prime.prime_division(num),
28
+ }.to_json
29
+ end
30
+
31
+ get '/hexdigest' do
32
+ str = params.fetch(:str)
33
+ iteration = Integer(params.fetch(:iteration))
34
+
35
+ hexdigest = nil
36
+ iteration.times do
37
+ hexdigest = OpenSSL::Digest::SHA256.hexdigest(str)
38
+ end
39
+
40
+ {
41
+ 'status' => 'ok',
42
+ 'result' => hexdigest,
43
+ }.to_json
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module Fukafuka
2
+ VERSION = File.read("#{__dir__}/../../VERSION")
3
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fukafuka
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mozamimy (Moza USANE)
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: revision_plate
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: unicorn
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: A simple web application for load testing.
112
+ email:
113
+ - alice@mozami.me
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".ruby-version"
121
+ - ".travis.yml"
122
+ - Dockerfile
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - VERSION
128
+ - bin/console
129
+ - bin/setup
130
+ - config.ru
131
+ - config/unicorn.rb
132
+ - docker-compose.yml
133
+ - fukafuka.gemspec
134
+ - lib/fukafuka.rb
135
+ - lib/fukafuka/app.rb
136
+ - lib/fukafuka/version.rb
137
+ homepage: https://github.com/mozamimy/fukafuka
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.6.11
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: A simple web application for load testing.
161
+ test_files: []