Permalink
Browse files

removed prefix

  • Loading branch information...
1 parent b012aa6 commit ac8c61c9e8811e6e4f5c7ca800740c05bdb493e4 Antonio Garrote committed Jun 29, 2009
View
No changes.
View
No changes.
View
No changes.
View
0 examples/Net/Gearman/Job.php 100644 → 100755
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 examples/Net/Gearman/Set.php 100644 → 100755
No changes.
View
No changes.
View
No changes.
View
0 examples/client.php 100644 → 100755
No changes.
View
0 examples/client.rb 100644 → 100755
No changes.
View
0 examples/server.rb 100644 → 100755
No changes.
View
0 examples/worker.php 100644 → 100755
No changes.
View
1 examples/worker.rb 100644 → 100755
@@ -1,6 +1,7 @@
require 'rubygems'
#require 'gearman'
require '../lib/gearman'
+
Gearman::Util.debug = true
servers = ['localhost:4730', 'localhost:4731']
View
@@ -2,47 +2,76 @@
Gem::Specification.new do |s|
s.name = %q{gearman-ruby}
- s.version = "0.1.0"
+ s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Daniel Erat", "Ladislav Martincik"]
- s.date = %q{2009-06-22}
+ s.date = %q{2009-06-25}
s.description = %q{Library for the Gearman distributed job system}
s.email = %q{ladislav.martincik@xing.com}
s.extra_rdoc_files = [
"LICENSE",
"README"
]
s.files = [
- "examples/scale_image.rb",
+ ".gitignore",
+ "LICENSE",
+ "README",
+ "Rakefile",
+ "VERSION.yml",
+ "examples/Net/Gearman/Client.php",
+ "examples/Net/Gearman/Connection.php",
+ "examples/Net/Gearman/Exception.php",
+ "examples/Net/Gearman/Job.php",
+ "examples/Net/Gearman/Job/Common.php",
+ "examples/Net/Gearman/Job/Exception.php",
+ "examples/Net/Gearman/Job/Sleep.php",
+ "examples/Net/Gearman/Manager.php",
+ "examples/Net/Gearman/Set.php",
+ "examples/Net/Gearman/Task.php",
+ "examples/Net/Gearman/Worker.php",
+ "examples/client.php",
+ "examples/client.rb",
+ "examples/scale_image.rb",
"examples/scale_image_worker.rb",
- "gearman.gemspec",
+ "examples/server.rb",
+ "examples/worker.php",
+ "examples/worker.rb",
+ "gearman-ruby.gemspec",
"lib/gearman.rb",
"lib/gearman/client.rb",
"lib/gearman/server.rb",
"lib/gearman/task.rb",
"lib/gearman/taskset.rb",
"lib/gearman/testlib.rb",
"lib/gearman/util.rb",
- "lib/gearman/worker.rb"
+ "lib/gearman/worker.rb",
+ "test/client_test.rb",
+ "test/mock_client_test.rb",
+ "test/mock_worker_test.rb",
+ "test/worker_test.rb"
]
- s.homepage = %q{http://github.com/lacomartincik/gearman-ruby}
+ s.has_rdoc = true
+ s.homepage = %q{http://github.com/xing/gearman-ruby}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.4}
+ s.rubygems_version = %q{1.3.1}
s.summary = %q{Library for the Gearman distributed job system}
s.test_files = [
"test/client_test.rb",
"test/mock_client_test.rb",
"test/mock_worker_test.rb",
"test/worker_test.rb",
+ "examples/client.rb",
"examples/scale_image.rb",
- "examples/scale_image_worker.rb"
+ "examples/scale_image_worker.rb",
+ "examples/server.rb",
+ "examples/worker.rb"
]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
+ s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
else
View
@@ -57,13 +57,7 @@
# puts c.do_task('add', '2 + 2')
#
module Gearman
-=begin
-require 'gearman/client'
-require 'gearman/task'
-require 'gearman/taskset'
-require 'gearman/util'
-require 'gearman/worker'
-=end
+
require File.dirname(__FILE__) + '/gearman/client'
require File.dirname(__FILE__) + '/gearman/task'
require File.dirname(__FILE__) + '/gearman/taskset'
@@ -13,20 +13,18 @@ class Client
# Create a new client.
#
# @param job_servers "host:port"; either a single server or an array
- # @param prefix function name prefix (namespace)
- def initialize(job_servers=nil, prefix=nil)
+ def initialize(job_servers=nil)
@job_servers = [] # "host:port"
self.job_servers = job_servers if job_servers
- @prefix = prefix
@sockets = {} # "host:port" -> [sock1, sock2, ...]
@socket_to_hostport = {} # sock -> "host:port"
@test_hostport = nil # make get_job_server return a given host for testing
@task_create_timeout_sec = 10
@server_counter = -1
@bad_servers = []
end
- attr_reader :job_servers, :bad_servers
- attr_accessor :prefix, :test_hostport, :task_create_timeout_sec
+ attr_reader :job_servers, :bad_servers
+ attr_accessor :test_hostport, :task_create_timeout_sec
##
# Set the job servers to be used by this client.
@@ -135,6 +133,7 @@ def do_task(*args)
failed ? nil : result
end
+
end
end
View
@@ -118,10 +118,9 @@ def get_uniq_hash
#
# @param background ??
# @return String representation of packet
- def get_submit_packet(prefix=nil, background=false)
+ def get_submit_packet(background=false)
mode = 'submit_job' +
(background ? '_bg' : @high_priority ? '_high' : '')
- func = (prefix ? prefix + "\t" : '') + @func
Util::pack_request(mode, [func, get_uniq_hash, arg].join("\0"))
end
end
@@ -40,7 +40,7 @@ def add_task(*args)
# otherwise
def add_task_internal(task, reset_state=true)
task.reset_state if reset_state
- req = task.get_submit_packet(@client.prefix)
+ req = task.get_submit_packet()
@task_waiting_for_handle = task
# FIXME: We need to loop here in case we get a bad job server, or the
@@ -85,14 +85,12 @@ def report_status(numerator, denominator)
# Create a new worker.
#
# @param job_servers "host:port"; either a single server or an array
- # @param prefix function name prefix (namespace)
# @param opts hash of additional options
- def initialize(job_servers=nil, prefix=nil, opts={})
+ def initialize(job_servers=nil, opts={})
chars = ('a'..'z').to_a
@client_id = Array.new(30) { chars[rand(chars.size)] }.join
@sockets = {} # "host:port" -> Socket
@abilities = {} # "funcname" -> Ability
- @prefix = prefix
@bad_servers = [] # "host:port"
@servers_mutex = Mutex.new
%w{client_id reconnect_sec
@@ -223,7 +221,6 @@ def announce_ability(sock, func, timeout=nil)
# @param timeout the server will give up on us if we don't finish
# a task in this many seconds
def add_ability(func, timeout=nil, &f)
- func = (@prefix ? "#{@prefix}\t" : '') + func
@abilities[func] = Ability.new(f, timeout)
@sockets.values.each {|s| announce_ability(s, func, timeout) }
end

0 comments on commit ac8c61c

Please sign in to comment.