marcinbunsch-quick_queue 0.1.0 → 0.1.1

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.
data/README.rdoc CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  quick_queue is a mix of Ruby's Queue and drb to produce an extremely simple to use queue system in pure Ruby.
4
4
 
5
+ === installation
6
+
7
+ Simple:
8
+
9
+ sudo gem install marcinbunsch-quick_queue
10
+
11
+ === usage
12
+
13
+ Simpler:
14
+
15
+ To use the server, type *qq* in the console. That's it.
16
+
17
+ To use the client, either use or extend the QuickQueue::Client class:
18
+
19
+ require 'quick_queue/client'
20
+ client = QuickQueue::Client.new
21
+ client.server_status
22
+ => "Current queue status: queue is empty"
23
+ client.push 'item'
24
+ => 1
25
+ client.fetch
26
+ => 'item'
27
+
5
28
  == Note on Patches/Pull Requests
6
29
 
7
30
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/qq CHANGED
@@ -8,6 +8,7 @@ OptionParser.new do |opts|
8
8
  opts.banner = "Usage: qs [options]"
9
9
 
10
10
  opts.on("-p PORT", "--port PORT", "Specify port (default: 5000)") { |value| @options[:port] = value; }
11
+ opts.on("-h HOST", "--host HOST", "Specify host (default: localhost)") { |value| @options[:host] = value; }
11
12
  opts.on("-f FILE", "--file FILE", "Specify file with data for queue (one item per line)") { |value| @options[:file] = value; }
12
13
  opts.on("-q", "quit deamon (if present)") { }
13
14
  opts.on("-d", "--deamon", "Run as a deamon process") { @options[:deamon] = true; }
@@ -4,8 +4,9 @@ module QuickQueue
4
4
 
5
5
  def initialize(options = {})
6
6
  port = (options[:port] || 7654)
7
+ host = (options[:host] || 'localhost')
7
8
  DRb.start_service()
8
- @server = DRbObject.new(nil, "druby://localhost:#{port}")
9
+ @server = DRbObject.new(nil, "druby://#{host}:#{port}")
9
10
  @current_item = nil
10
11
  end
11
12
 
@@ -22,17 +23,19 @@ module QuickQueue
22
23
  end
23
24
 
24
25
  def loop
25
- begin
26
- while item = fetch
26
+ while item = fetch
27
+ begin
27
28
  @current_item = item
28
29
  handle(item)
29
30
  @current_item = nil
30
- end
31
- rescue
32
- # if something went wrong, put it back in the queue
33
- if @current_item
34
- @server.push(@current_item)
35
- @current_item = nil
31
+ rescue
32
+ # if something went wrong, put it back in the queue
33
+ if @current_item
34
+ @logger.info("Failed to process #{@current_item}, putting it back in queue") if @logger
35
+ @logger.info("Reason for failure: #{$!.class}: #{$!.message} at #{$!.backtrace.first}") if @logger
36
+ @server.push(@current_item)
37
+ @current_item = nil
38
+ end
36
39
  end
37
40
  end
38
41
  end
@@ -45,8 +45,9 @@ module QuickQueue
45
45
  @size = @queue.length
46
46
  trap('INT') { exit }
47
47
  port = (options[:port] || 7654)
48
- puts "quick_queue: server working at #{port}"
49
- DRb.start_service("druby://localhost:#{port}", self)
48
+ host = (options[:host] || 'localhost')
49
+ puts "quick_queue: server working at #{host}:#{port}"
50
+ DRb.start_service("druby://#{host}:#{port}", self)
50
51
  DRb.thread.join
51
52
  end
52
53
 
data/quick_queue.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{quick_queue}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Bunsch"]
12
- s.date = %q{2009-09-16}
12
+ s.date = %q{2009-09-18}
13
13
  s.default_executable = %q{qq}
14
14
  s.email = %q{marcin@applicake.com}
15
15
  s.executables = ["qq"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcinbunsch-quick_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-16 00:00:00 -07:00
12
+ date: 2009-09-18 00:00:00 -07:00
13
13
  default_executable: qq
14
14
  dependencies: []
15
15