fmq 0.3.4 → 0.3.5

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.
@@ -1,3 +1,8 @@
1
+ == 0.3.5 2009-07-25
2
+
3
+ * 1 minor change:
4
+ * ruby 1.9 and rack 1.0.0 compatibility (thanks to John W Higgins <wishdev@gmail.com>)
5
+
1
6
  == 0.3.4 2008-09-06
2
7
 
3
8
  * 2 minor change:
@@ -15,7 +20,7 @@
15
20
 
16
21
  * 3 minor changes:
17
22
  * changed the way of the queue manager setup
18
- * updated rdoc, readme and website documentaition
23
+ * updated rdoc, readme and website documentation
19
24
  * added a new queue that persists the messages in the file system
20
25
  * 3 tiny changes:
21
26
  * fixed the fmq logger creation
@@ -26,9 +31,9 @@
26
31
 
27
32
  * 2 minor changes:
28
33
  * refactored the queue manager and remove legacy code (moved constraints stuff to the base queue)
29
- * refactored the setup_queue method in the configuration file (sorry you have to change your configs)
34
+ * refactored the setup_queue method in the configuration file (sorry you have to change your config)
30
35
  * 3 tiny changes:
31
- * default-server can now be used from within the development repository (no rund trip nessesary)
36
+ * default-server can now be used from within the development repository (no rund trip necessary)
32
37
  * added and replaced some tests for the new interface of the queue manager and the base queue
33
38
  * one can now yield and return messages
34
39
 
@@ -38,11 +43,11 @@
38
43
  * replaced the mongrel handler by rack so that it can be used by many servers and in different configurations
39
44
  * removed the old yml style config and replaced it by a new rubyish config style (see config.ru)
40
45
  * 5 tiny changes:
41
- * seperated the admin interface handler
46
+ * separated the admin interface handler
42
47
  * removed the configuration stuff that belonged to the old yml file from queue_manager and boot classes
43
48
  * removed that the command fmq can be used to start the server (rackup can be used by now)
44
- * admin interface is now seperated to several files (javascript, css, ...)
45
- * admin interface is validated by W3C validatior for xhtml strict and css 2.1 compliance
49
+ * admin interface is now separated to several files (javascript, css, ...)
50
+ * admin interface is validated by W3C validator for xhtml strict and css 2.1 compliance
46
51
 
47
52
  == 0.2.0 2008-06-28
48
53
 
@@ -1,3 +1 @@
1
- ================================================================================
2
- For more information on Free Message Queue (FMQ), see http://fmq.rubyforge.org
3
- ================================================================================
1
+ For more information on Free Message Queue (FMQ), see http://fmq.rubyforge.org
data/README.txt CHANGED
@@ -44,7 +44,7 @@ The server will start and host a admin interface on http://localhost:5884/admin/
44
44
 
45
45
  == REQUIREMENTS:
46
46
 
47
- * rack >= 0.4.0 (web server provider)
47
+ * rack >= 1.0.0 (web server provider)
48
48
 
49
49
  == INSTALL:
50
50
 
@@ -8,7 +8,7 @@ RUBYFORGE_PROJECT = 'fmq' # The unix name for your project
8
8
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
9
  DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
10
  EXTRA_DEPENDENCIES = [
11
- ['rack', '>= 0.4.0']
11
+ ['rack', '>= 1.0.0']
12
12
  ] # An array of rubygem dependencies [name, version]
13
13
 
14
14
  @config_file = "~/.rubyforge/user-config.yml"
@@ -63,8 +63,8 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
63
63
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
64
  p.extra_deps = EXTRA_DEPENDENCIES
65
65
 
66
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
- end
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
68
 
69
69
  CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
70
  PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
@@ -1,5 +1,5 @@
1
1
  begin
2
- require File.dirname(__FILE__) + '/../lib/fmq'
2
+ require ::File.dirname(__FILE__) + '/../lib/fmq'
3
3
  rescue LoadError
4
4
  require "fmq"
5
5
  end
@@ -2,17 +2,17 @@
2
2
  # Copyright (c) 2008 Vincent Landgraf
3
3
  #
4
4
  # This file is part of the Free Message Queue.
5
- #
5
+ #
6
6
  # Free Message Queue is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU General Public License as published by
8
8
  # the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
- #
10
+ #
11
11
  # Free Message Queue is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU General Public License for more details.
15
- #
15
+ #
16
16
  # You should have received a copy of the GNU General Public License
17
17
  # along with Free Message Queue. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
@@ -21,22 +21,22 @@ module FreeMessageQueue
21
21
  class AdminInterface
22
22
  # rack response for bad requests
23
23
  WRONG_METHOD = [400, {"CONTENT-TYPE" => "text/plain", "ERROR" => "Wrong http Method"}, ""]
24
-
24
+
25
25
  # rack response for good requests
26
26
  OK = [200, {"CONTENT-TYPE" => "text/plain"}, ["ok"]]
27
-
27
+
28
28
  # create the admin interface for the passed QueueManager
29
29
  def initialize(queue_manager)
30
30
  @manager = queue_manager
31
31
  @log = FreeMessageQueue.logger
32
32
  end
33
-
33
+
34
34
  # handle all requests
35
35
  def call(env)
36
36
  begin
37
37
  request = Rack::Request.new(env)
38
38
  @log.debug "[AdminInterface] ENV: #{env.inspect}"
39
-
39
+
40
40
  if request.get? then
41
41
  @log.info "[AdminInterface] list queues"
42
42
  # ======= LIST QUEUES
@@ -44,7 +44,7 @@ module FreeMessageQueue
44
44
  @manager.queues.each do |queue_name|
45
45
  queues_code << queue_to_json(queue_name)
46
46
  end
47
-
47
+
48
48
  return [200, {"CONTENT-TYPE" => "application/json"}, ["[%s]" % queues_code.join(","), ]]
49
49
  elsif request.post? then
50
50
  if request["_method"] == "delete" then
@@ -55,9 +55,12 @@ module FreeMessageQueue
55
55
  elsif request["_method"] == "create"
56
56
  # ======= CREATE QUEUE
57
57
  @log.info "[AdminInterface] create queue"
58
- @manager.setup_queue request["path"] do |q|
58
+ @manager.setup_queue(request["path"], request["queue_class"]) do |q|
59
59
  q.max_messages = request["max_messages"].to_i
60
60
  q.max_size = str_bytes request["max_size"]
61
+ request.params.each { |k,v|
62
+ q.send("#{k[3..-1]}=", v) if k.match(/^qm_/)
63
+ }
61
64
  end
62
65
  return OK
63
66
  else
@@ -70,13 +73,13 @@ module FreeMessageQueue
70
73
  return [400, {"CONTENT-TYPE" => "text/plain", "ERROR" => ex.message}, [ex.message]]
71
74
  end
72
75
  end
73
-
76
+
74
77
  private
75
-
78
+
76
79
  # converts the data of one queue to json format
77
80
  def queue_to_json(queue_name)
78
81
  queue = @manager.queue(queue_name)
79
-
82
+
80
83
  "[\"%s\", %d, %d, %d, %d]" % [
81
84
  queue_name,
82
85
  queue.bytes,
@@ -85,14 +88,17 @@ module FreeMessageQueue
85
88
  queue.max_messages,
86
89
  ]
87
90
  end
88
-
91
+
89
92
  # Retuns count of bytes to a expression with kb, mb or gb
90
93
  # e.g 10kb will return 10240
91
94
  def str_bytes(str)
92
95
  case str
93
- when /([0-9]+)kb/i: $1.to_i.kb
94
- when /([0-9]+)mb/i: $1.to_i.mb
95
- when /([0-9]+)gb/i: $1.to_i.gb
96
+ when /([0-9]+)kb/i
97
+ $1.to_i.kb
98
+ when /([0-9]+)mb/i
99
+ $1.to_i.mb
100
+ when /([0-9]+)gb/i
101
+ $1.to_i.gb
96
102
  else
97
103
  BaseQueue::INFINITE
98
104
  end
@@ -78,8 +78,10 @@ module FreeMessageQueue
78
78
 
79
79
  # create a queue using a block. The block can be used to set configuration
80
80
  # options for the queue
81
- def setup_queue(path, queue_class = DEFAULT_QUEUE_CLASS, &block)
81
+ def setup_queue(path, queue_class = nil, &block)
82
82
  check_queue_name(path)
83
+ queue_class ||= DEFAULT_QUEUE_CLASS
84
+ queue_class = FreeMessageQueue::const_get(queue_class) if queue_class.class == String
83
85
  queue_object = queue_class.new(self)
84
86
  block.call(queue_object) if block_given?
85
87
  @queues[path] = queue_object
@@ -17,6 +17,9 @@
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with Free Message Queue. If not, see <http://www.gnu.org/licenses/>.
19
19
  #
20
+
21
+ require 'yaml'
22
+
20
23
  module FreeMessageQueue
21
24
  # This implements server that plugs the free message queue into a rack enviroment
22
25
  class Server
@@ -29,7 +32,7 @@ module FreeMessageQueue
29
32
  # Process incoming request and send them to the right sub processing method like <em>process_get</em>
30
33
  def call(env)
31
34
  request = Rack::Request.new(env)
32
- queue_path = request.env["REQUEST_PATH"]
35
+ queue_path = request.env["PATH_INFO"]
33
36
  @log.debug("[Server] Request params: #{YAML.dump(request.params)})")
34
37
 
35
38
  response = nil
@@ -20,7 +20,7 @@ module FreeMessageQueue
20
20
  module VERSION #:nodoc:
21
21
  MAJOR = 0
22
22
  MINOR = 3
23
- TINY = 4
23
+ TINY = 5
24
24
 
25
25
  STRING = [MAJOR, MINOR, TINY].join('.')
26
26
  end
File without changes
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.dirname(__FILE__) + '/helper.rb'
2
2
 
3
3
  # This is the default test to the message interface
4
4
  class TestMessage < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.dirname(__FILE__) + '/helper.rb'
2
2
  require "fileutils"
3
3
 
4
4
  # This is the default test to the message interface
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.dirname(__FILE__) + '/helper.rb'
2
2
 
3
3
  class TestFreeMessageQueue < Test::Unit::TestCase
4
4
  TEST_URL = "http://localhost:5884/fmq_test/test1"
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.dirname(__FILE__) + '/helper.rb'
2
2
 
3
3
  # This is the default test to the message interface
4
4
  class TestLinkedQueue < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.dirname(__FILE__) + '/helper.rb'
2
2
 
3
3
  # This is the tests the queue manager interface
4
4
  class TestQueueManager < Test::Unit::TestCase
@@ -6,7 +6,7 @@ class TestQueueManager < Test::Unit::TestCase
6
6
 
7
7
  def setup
8
8
  @queue_manager = FreeMessageQueue::QueueManager.new(false) do
9
- setup_queue DEFAULT_QUEUE_NAME do |q|
9
+ setup_queue TestQueueManager::DEFAULT_QUEUE_NAME do |q|
10
10
  q.max_messages = 100
11
11
  q.max_size = 100.mb
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Landgraf
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-06 00:00:00 +02:00
12
+ date: 2009-07-25 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.4.0
23
+ version: 1.0.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.7.0
33
+ version: 2.3.2
34
34
  version:
35
35
  description: The project implements a queue system with a server and some client apis. This project wants to be a fast and lightweight implementation with most of the features of MQS or ActiveMQ.
36
36
  email:
@@ -76,18 +76,17 @@ files:
76
76
  - lib/fmq/queues/file_persistent.rb
77
77
  - lib/fmq/queues/round_robin.rb
78
78
  - lib/fmq/version.rb
79
+ - test/helper.rb
79
80
  - test/test_basic.rb
80
81
  - test/test_fmq_client.rb
81
- - test/test_helper.rb
82
82
  - test/test_linked.rb
83
83
  - test/test_queue_manager.rb
84
84
  - test/test_file_persistent.rb
85
85
  has_rdoc: true
86
86
  homepage: http://fmq.rubyforge.org
87
- post_install_message: |-
88
- ================================================================================
89
- For more information on Free Message Queue (FMQ), see http://fmq.rubyforge.org
90
- ================================================================================
87
+ licenses: []
88
+
89
+ post_install_message: For more information on Free Message Queue (FMQ), see http://fmq.rubyforge.org
91
90
  rdoc_options:
92
91
  - --main
93
92
  - README.txt
@@ -108,14 +107,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
107
  requirements: []
109
108
 
110
109
  rubyforge_project: fmq
111
- rubygems_version: 1.2.0
110
+ rubygems_version: 1.3.5
112
111
  signing_key:
113
- specification_version: 2
112
+ specification_version: 3
114
113
  summary: The project implements a queue system with a server and some client apis. This project wants to be a fast and lightweight implementation with most of the features of MQS or ActiveMQ.
115
114
  test_files:
116
115
  - test/test_basic.rb
117
116
  - test/test_file_persistent.rb
118
117
  - test/test_fmq_client.rb
119
- - test/test_helper.rb
120
118
  - test/test_linked.rb
121
119
  - test/test_queue_manager.rb