-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract concurrency logic to a separated class.
Remove unnecesary additional vendorized files. Use Celluloid in Ruby 1.9.
- Loading branch information
Showing
180 changed files
with
2,023 additions
and
38,476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module EY | ||
module Serverside | ||
class Future | ||
def self.success?(futures) | ||
futures.empty? || futures.all? {|f| f.success?} | ||
end | ||
|
||
def initialize(server, *args, &block) | ||
@server = server | ||
@args = args | ||
@block = block | ||
end | ||
|
||
def success? | ||
@value == true | ||
end | ||
|
||
def error? | ||
!success? | ||
end | ||
end | ||
|
||
if defined?(Fiber) | ||
require 'engineyard-serverside/futures/celluloid' | ||
else | ||
require 'engineyard-serverside/futures/dataflow' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module EY | ||
module Serverside | ||
$LOAD_PATH.unshift File.expand_path('../../vendor/celluloid/lib', File.dirname(__FILE__)) | ||
require 'celluloid' | ||
class Future | ||
def self.call(servers, *args, &block) | ||
futures = servers.map do |server| | ||
new(server, *args, &block) | ||
end | ||
|
||
futures.each {|f| f.call} | ||
futures | ||
end | ||
|
||
def future | ||
Celluloid::Future.new(@server, *@args, &@block) | ||
end | ||
|
||
def call | ||
# Celluloid needs to call the block explicitely | ||
@value ||= future.call | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module EY | ||
module Serverside | ||
$LOAD_PATH.unshift File.expand_path('../../vendor/dataflow', File.dirname(__FILE__)) | ||
require 'dataflow' | ||
|
||
class Future | ||
extend Dataflow | ||
|
||
def self.call(servers, *args, &block) | ||
futures = [] | ||
# Dataflow needs to call `barrier` and `need_later` in the same object | ||
barrier(*servers.map do |server| | ||
future = new(server, *args, &block) | ||
futures << future | ||
|
||
need_later { future.call } | ||
end) | ||
|
||
futures | ||
end | ||
|
||
def future | ||
@block.call(@server, *@args) | ||
end | ||
|
||
def call | ||
@value ||= future | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'open4' | ||
|
||
module EY | ||
module Serverside | ||
module LoggedOutput | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.