Skip to content

Commit

Permalink
Merge pull request #5 from serradura/u-case
Browse files Browse the repository at this point in the history
Micro::Case
  • Loading branch information
serradura committed Sep 15, 2019
2 parents 082d674 + c168422 commit fdac1ef
Show file tree
Hide file tree
Showing 62 changed files with 1,001 additions and 996 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -19,5 +19,5 @@ group :test do
gem 'simplecov', require: false
end

# Specify your gem's dependencies in micro-service.gemspec
# Specify your gem's dependencies in u-case.gemspec
gemspec
252 changes: 128 additions & 124 deletions README.md

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions benchmarks/interactor/pipeline_failure.rb
Expand Up @@ -5,7 +5,7 @@

gem 'benchmark-ips', '~> 2.7', '>= 2.7.2'
gem 'interactor', '~> 3.1', '>= 3.1.1'
gem 'u-service', '~> 1.0.0'
gem 'u-case', '~> 1.0.0.rc1'
end

require 'benchmark/ips'
Expand Down Expand Up @@ -43,7 +43,7 @@ class Add2ToAllNumbers
end

module MSB
class ConvertToNumbers < Micro::Service::Base
class ConvertToNumbers < Micro::Case::Base
attribute :numbers

def call!
Expand All @@ -55,7 +55,7 @@ def call!
end
end

class Add2 < Micro::Service::Base
class Add2 < Micro::Case::Base
attribute :numbers

def call!
Expand All @@ -67,7 +67,7 @@ def call!
end

module MSS
class ConvertToNumbers < Micro::Service::Strict
class ConvertToNumbers < Micro::Case::Strict
attribute :numbers

def call!
Expand All @@ -79,7 +79,7 @@ def call!
end
end

class Add2 < Micro::Service::Strict
class Add2 < Micro::Case::Strict
attribute :numbers

def call!
Expand All @@ -102,11 +102,11 @@ def call!
IT::Add2ToAllNumbers.call(NUMBERS)
end

x.report('Pipeline of Micro::Service::Base') do
x.report('A flow with Micro::Case::Base') do
MSB::Add2ToAllNumbers.call(NUMBERS)
end

x.report('Pipeline of Micro::Service::Strict') do
x.report('A flow with Micro::Case::Strict') do
MSS::Add2ToAllNumbers.call(NUMBERS)
end

Expand All @@ -116,19 +116,19 @@ def call!
# Warming up --------------------------------------
# Interactor::Organizer
# 2.319k i/100ms
# Pipeline of Micro::Service::Base
# A flow with Micro::Case::Base
# 14.237k i/100ms
# Pipeline of Micro::Service::Strict
# A flow with Micro::Case::Strict
# 12.301k i/100ms
# Calculating -------------------------------------
# Interactor::Organizer
# 23.511k (± 3.0%) i/s - 118.269k in 5.035043s
# Pipeline of Micro::Service::Base
# A flow with Micro::Case::Base
# 152.649k (± 1.7%) i/s - 768.798k in 5.037869s
# Pipeline of Micro::Service::Strict
# A flow with Micro::Case::Strict
# 129.477k (± 2.7%) i/s - 651.953k in 5.039222s

# Comparison:
# Pipeline of Micro::Service::Base: 152648.6 i/s
# Pipeline of Micro::Service::Strict: 129477.0 i/s - 1.18x slower
# Interactor::Organizer: 23511.2 i/s - 6.49x slower
# A flow with Micro::Case::Base: 152648.6 i/s
# A flow with Micro::Case::Strict: 129477.0 i/s - 1.18x slower
# Interactor::Organizer: 23511.2 i/s - 6.49x slower
28 changes: 14 additions & 14 deletions benchmarks/interactor/pipeline_success.rb
Expand Up @@ -5,7 +5,7 @@

gem 'benchmark-ips', '~> 2.7', '>= 2.7.2'
gem 'interactor', '~> 3.1', '>= 3.1.1'
gem 'u-service', '~> 1.0.0'
gem 'u-case', '~> 1.0.0.rc1'
end

require 'benchmark/ips'
Expand Down Expand Up @@ -43,7 +43,7 @@ class Add2ToAllNumbers
end

module MSB
class ConvertToNumbers < Micro::Service::Base
class ConvertToNumbers < Micro::Case::Base
attribute :numbers

def call!
Expand All @@ -55,7 +55,7 @@ def call!
end
end

class Add2 < Micro::Service::Base
class Add2 < Micro::Case::Base
attribute :numbers

def call!
Expand All @@ -67,7 +67,7 @@ def call!
end

module MSS
class ConvertToNumbers < Micro::Service::Strict
class ConvertToNumbers < Micro::Case::Strict
attribute :numbers

def call!
Expand All @@ -79,7 +79,7 @@ def call!
end
end

class Add2 < Micro::Service::Strict
class Add2 < Micro::Case::Strict
attribute :numbers

def call!
Expand All @@ -102,11 +102,11 @@ def call!
IT::Add2ToAllNumbers.call(NUMBERS)
end

x.report('Pipeline of Micro::Service::Base') do
x.report('A flow with Micro::Case::Base') do
MSB::Add2ToAllNumbers.call(NUMBERS)
end

x.report('Pipeline of Micro::Service::Strict') do
x.report('A flow with Micro::Case::Strict') do
MSS::Add2ToAllNumbers.call(NUMBERS)
end

Expand All @@ -116,19 +116,19 @@ def call!
# Warming up --------------------------------------
# Interactor::Organizer
# 4.928k i/100ms
# Pipeline of Micro::Service::Base
# A flow with Micro::Case::Base
# 7.711k i/100ms
# Pipeline of Micro::Service::Strict
# A flow with Micro::Case::Strict
# 6.545k i/100ms
# Calculating -------------------------------------
# Interactor::Organizer
# 50.502k (± 2.1%) i/s - 256.256k in 5.076410s
# Pipeline of Micro::Service::Base
# A flow with Micro::Case::Base
# 79.571k (± 2.0%) i/s - 400.972k in 5.041211s
# Pipeline of Micro::Service::Strict
# A flow with Micro::Case::Strict
# 65.981k (± 3.4%) i/s - 333.795k in 5.065318s

# Comparison:
# Pipeline of Micro::Service::Base: 79570.8 i/s
# Pipeline of Micro::Service::Strict: 65980.6 i/s - 1.21x slower
# Interactor::Organizer: 50501.7 i/s - 1.58x slower
# A flow with Micro::Case::Base: 79570.8 i/s
# A flow with Micro::Case::Strict: 65980.6 i/s - 1.21x slower
# Interactor::Organizer: 50501.7 i/s - 1.58x slower
24 changes: 12 additions & 12 deletions benchmarks/interactor/service_failure.rb
Expand Up @@ -5,7 +5,7 @@

gem 'benchmark-ips', '~> 2.7', '>= 2.7.2'
gem 'interactor', '~> 3.1', '>= 3.1.1'
gem 'u-service', '~> 1.0.0'
gem 'u-case', '~> 1.0.0.rc1'
end

require 'benchmark/ips'
Expand All @@ -25,7 +25,7 @@ def call
end
end

class MSB_Multiply < Micro::Service::Base
class MSB_Multiply < Micro::Case::Base
attributes :a, :b

def call!
Expand All @@ -37,7 +37,7 @@ def call!
end
end

class MSS_Multiply < Micro::Service::Strict
class MSS_Multiply < Micro::Case::Strict
attributes :a, :b

def call!
Expand All @@ -63,12 +63,12 @@ def call!
IT_Multiply.call(STRING_KEYS)
end

x.report('Micro::Service::Base') do
x.report('Micro::Case::Base') do
MSB_Multiply.call(SYMBOL_KEYS)
MSB_Multiply.call(STRING_KEYS)
end

x.report('Micro::Service::Strict') do
x.report('Micro::Case::Strict') do
MSS_Multiply.call(SYMBOL_KEYS)
MSS_Multiply.call(STRING_KEYS)
end
Expand All @@ -78,16 +78,16 @@ def call!

# Warming up --------------------------------------
# Interactor 1.521k i/100ms
# Micro::Service::Base 11.209k i/100ms
# Micro::Service::Strict
# Micro::Case::Base 11.209k i/100ms
# Micro::Case::Strict
# 8.794k i/100ms
# Calculating -------------------------------------
# Interactor 14.564k (± 7.8%) i/s - 73.008k in 5.048979s
# Micro::Service::Base 116.319k (± 1.7%) i/s - 582.868k in 5.012372s
# Micro::Service::Strict
# Micro::Case::Base 116.319k (± 1.7%) i/s - 582.868k in 5.012372s
# Micro::Case::Strict
# 89.790k (± 3.4%) i/s - 448.494k in 5.001098s

# Comparison:
# Micro::Service::Base: 116318.8 i/s
# Micro::Service::Strict: 89790.0 i/s - 1.30x slower
# Interactor: 14564.3 i/s - 7.99x slower
# Micro::Case::Base: 116318.8 i/s
# Micro::Case::Strict: 89790.0 i/s - 1.30x slower
# Interactor: 14564.3 i/s - 7.99x slower
24 changes: 12 additions & 12 deletions benchmarks/interactor/service_success.rb
Expand Up @@ -5,7 +5,7 @@

gem 'benchmark-ips', '~> 2.7', '>= 2.7.2'
gem 'interactor', '~> 3.1', '>= 3.1.1'
gem 'u-service', '~> 1.0.0'
gem 'u-case', '~> 1.0.0.rc1'
end

require 'benchmark/ips'
Expand All @@ -25,7 +25,7 @@ def call
end
end

class MSB_Multiply < Micro::Service::Base
class MSB_Multiply < Micro::Case::Base
attributes :a, :b

def call!
Expand All @@ -37,7 +37,7 @@ def call!
end
end

class MSS_Multiply < Micro::Service::Strict
class MSS_Multiply < Micro::Case::Strict
attributes :a, :b

def call!
Expand All @@ -63,12 +63,12 @@ def call!
IT_Multiply.call(STRING_KEYS)
end

x.report('Micro::Service::Base') do
x.report('Micro::Case::Base') do
MSB_Multiply.call(SYMBOL_KEYS)
MSB_Multiply.call(STRING_KEYS)
end

x.report('Micro::Service::Strict') do
x.report('Micro::Case::Strict') do
MSS_Multiply.call(SYMBOL_KEYS)
MSS_Multiply.call(STRING_KEYS)
end
Expand All @@ -78,16 +78,16 @@ def call!

# Warming up --------------------------------------
# Interactor 2.943k i/100ms
# Micro::Service::Base 12.267k i/100ms
# Micro::Service::Strict
# Micro::Case::Base 12.267k i/100ms
# Micro::Case::Strict
# 9.368k i/100ms
# Calculating -------------------------------------
# Interactor 29.998k (± 2.5%) i/s - 150.093k in 5.006612s
# Micro::Service::Base 125.269k (± 3.4%) i/s - 625.617k in 5.000142s
# Micro::Service::Strict
# Micro::Case::Base 125.269k (± 3.4%) i/s - 625.617k in 5.000142s
# Micro::Case::Strict
# 96.087k (± 2.5%) i/s - 487.136k in 5.073155s

# Comparison:
# Micro::Service::Base: 125269.5 i/s
# Micro::Service::Strict: 96087.3 i/s - 1.30x slower
# Interactor: 29997.7 i/s - 4.18x slower
# Micro::Case::Base: 125269.5 i/s
# Micro::Case::Strict: 96087.3 i/s - 1.30x slower
# Interactor: 29997.7 i/s - 4.18x slower
2 changes: 1 addition & 1 deletion bin/console
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "micro/service"
require "micro/case"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
12 changes: 6 additions & 6 deletions comparisons/u-service.rb
@@ -1,4 +1,4 @@
class CreateResponse < Micro::Service::Strict
class CreateResponse < Micro::Case::Strict
attributes :responder, :answers, :survey

def call!
Expand All @@ -14,7 +14,7 @@ def call!
end
end

class AddRewardPoints < Micro::Service::Strict
class AddRewardPoints < Micro::Case::Strict
attributes :responder, :survey

def call!
Expand All @@ -27,7 +27,7 @@ def call!
end
end

class SendNotifications < Micro::Service::Strict
class SendNotifications < Micro::Case::Strict
attributes :responder, :survey

def call!
Expand All @@ -46,7 +46,7 @@ def call!

# or

ReplyToSurvey = Micro::Service::Pipeline[
ReplyToSurvey = Micro::Case::Flow[
CreateResponse,
AddRewardPoints,
SendNotifications
Expand All @@ -55,7 +55,7 @@ def call!
# or

class ReplyToSurvey
include Micro::Service::Pipeline
include Micro::Case::Flow

pipeline CreateResponse, AddRewardPoints, SendNotifications
flow CreateResponse, AddRewardPoints, SendNotifications
end
6 changes: 3 additions & 3 deletions examples/calculator/README.md
@@ -1,11 +1,11 @@
# μ-service - Calculator example
# μ-case - Calculator example

This example uses [rake](http://rubygems.org/gems/rake) to expose a CLI calculator.

## Installation instructions
```sh
gem install rake
gem install u-service -v 1.0.0
gem install u-case -v 1.0.0.rc1
```

*Note:*
Expand All @@ -14,7 +14,7 @@ If zsh is your shell, use: [`unsetopt nomatch`](https://thoughtbot.com/blog/how-

### Usage

![gif](https://github.com/serradura/u-service/blob/master/examples/calculator/assets/usage.gif?raw=true)
![gif](https://github.com/serradura/u-case/blob/master/examples/calculator/assets/usage.gif?raw=true)

#### Listing the available rake tasks
```sh
Expand Down

0 comments on commit fdac1ef

Please sign in to comment.