Permalink
Browse files

adding the queue object

  • Loading branch information...
1 parent 7900a56 commit 6a951909ec1aeef03844f4a771fefb183d0cdacf @tenderlove committed Sep 22, 2008
Showing with 62 additions and 1 deletion.
  1. +1 −0 ext/quail/native.c
  2. +22 −0 ext/quail/quail_queue.c
  3. +8 −0 ext/quail/quail_queue.h
  4. +1 −0 lib/quail.rb
  5. +3 −1 lib/quail/exchange.rb
  6. +15 −0 lib/quail/queue.rb
  7. +12 −0 test/quail/test_queue.rb
View
@@ -8,4 +8,5 @@ void Init_native()
Init_Quail_Handle(mQuail);
Init_Quail_Exchange(mQuail);
+ Init_Quail_Queue(mQuail);
}
View
@@ -0,0 +1,22 @@
+#include <quail_queue.h>
+
+static VALUE create_queue( VALUE self,
+ VALUE rb_h,
+ VALUE name,
+ VALUE scope,
+ VALUE address)
+{
+ void * handle;
+ Data_Get_Struct(rb_h, void, handle);
+ czmq_create_queue( handle,
+ StringValuePtr(name),
+ NUM2INT(scope),
+ StringValuePtr(address)
+ );
+}
+
+void Init_Quail_Queue(VALUE mQuail)
+{
+ VALUE cQuailHandle = rb_define_class_under(mQuail, "Queue", rb_cObject);
+ rb_define_private_method(cQuailHandle, "create_queue", create_queue, 4);
+}
View
@@ -0,0 +1,8 @@
+#ifndef QUAIL_QUEUE
+#define QUAIL_QUEUE
+
+#include <native.h>
+
+void Init_Quail_Queue(VALUE mQuail);
+
+#endif
View
@@ -1,2 +1,3 @@
require 'quail/native'
require 'quail/exchange'
+require 'quail/queue'
View
@@ -1,11 +1,13 @@
module Quail
class Exchange
- attr_accessor :eid
+ attr_accessor :eid, :name
def initialize handle,
exchange_name = 'E',
scope = Quail::GLOBAL,
address = '127.0.0.1:5000'
+ @name = exchange_name
+ @handle = handle
@eid = create_exchange(handle, exchange_name, scope, address)
end
end
View
@@ -0,0 +1,15 @@
+module Quail
+ class Queue
+ attr_accessor :name
+
+ def initialize handle,
+ name = 'Q',
+ scope = Quail::GLOBAL,
+ address = '127.0.0.1:5001'
+
+ @handle = handle
+ @name = name
+ create_queue(handle, name, scope, address)
+ end
+ end
+end
View
@@ -0,0 +1,12 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "helper"))
+
+module Quail
+ class TestQueue < Quail::TestCase
+ def test_initialize
+ handle = Quail::Handle.new('localhost')
+ assert_nothing_raised {
+ queue = Quail::Queue.new(handle)
+ }
+ end
+ end
+end

0 comments on commit 6a95190

Please sign in to comment.