Permalink
Browse files

hooking up the error handler

  • Loading branch information...
1 parent 853db11 commit c363e8bdb8724a6acf2422eff7bb32509dbcc5af @tenderlove committed Sep 23, 2008
Showing with 34 additions and 15 deletions.
  1. +2 −2 README.txt
  2. +2 −6 example/local.rb
  3. +0 −1 example/remote.rb
  4. +9 −3 ext/quail/native.c
  5. +10 −0 lib/quail.rb
  6. +10 −2 lib/quail/handle.rb
  7. +1 −1 test/quail/test_handle.rb
View
@@ -1,10 +1,10 @@
= quail
-* FIX (url)
+* http://github.com/tenderlove/quail/tree/master
== DESCRIPTION:
-FIX (describe your package)
+Really fucking fast messaging in ruby.
== FEATURES/PROBLEMS:
View
@@ -1,16 +1,12 @@
require 'quail'
-msg = "hello world"
Quail::Handle.start('localhost') do |handle|
exchange = Quail::Exchange.new(handle, 'EL', Quail::LOCAL)
- handle.bind("EL", "QG")
+ handle.bind("EL" => "QG")
t = Time.now.to_f
- 1_000_000.times {
- exchange.send(msg)
- }
+ 1_000.times { exchange.send('Hello world') }
puts Time.now.to_f - t
- sleep 2
end
View
@@ -1,7 +1,6 @@
require 'quail'
Quail::Handle.start('localhost') do |handle|
- exchange = Quail::Exchange.new(handle, 'EG', Quail::GLOBAL)
queue = Quail::Queue.new(handle, 'QG', Quail::GLOBAL)
while true
View
@@ -1,16 +1,22 @@
#include <native.h>
-static bool awesome (const char *foo)
+VALUE mQuail;
+
+static bool error_handler (const char *name)
{
+ VALUE block = rb_funcall(mQuail, rb_intern("error_handler"), 0);
+ VALUE ret = rb_funcall(block, rb_intern("call"), 1, rb_str_new2(name));
+
+ if(ret == Qtrue) return true;
return false;
}
void Init_native()
{
- VALUE mQuail = rb_define_module("Quail");
+ mQuail = rb_define_module("Quail");
rb_const_set(mQuail, rb_intern("LOCAL"), INT2NUM(CZMQ_SCOPE_LOCAL));
rb_const_set(mQuail, rb_intern("GLOBAL"), INT2NUM(CZMQ_SCOPE_GLOBAL));
- czmq_set_error_handler(awesome);
+ czmq_set_error_handler(error_handler);
Init_Quail_Handle(mQuail);
Init_Quail_Exchange(mQuail);
View
@@ -2,3 +2,13 @@
require 'quail/exchange'
require 'quail/queue'
require 'quail/handle'
+
+module Quail
+ class << self
+ attr_accessor :error_handler
+ end
+end
+
+Quail.error_handler = lambda { |name|
+ false
+}
View
@@ -29,9 +29,17 @@ def finish
@started = false
end
- def bind exchange, queue
+ ####
+ # Bind these +connections+
+ # handle.bind(
+ # 'EXCHANGE_LOCAL' => 'QUEUE_GLOBAL',
+ # 'EXCHANGE_LOCAL' => 'QUEUE_GLOBAL',
+ # )
+ def bind connections
raise "not started" unless @started
- native_bind(exchange, queue)
+ connections.each do |k,v|
+ native_bind(k, v)
+ end
end
end
end
@@ -12,7 +12,7 @@ def test_bind
Quail::Handle.start('localhost') do |handle|
exchange = Quail::Exchange.new(handle)
queue = Quail::Queue.new(handle)
- handle.bind(exchange.name, queue.name)
+ handle.bind(exchange.name => queue.name)
end
end
end

0 comments on commit c363e8b

Please sign in to comment.