beetle 0.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.rdoc +18 -8
  2. data/beetle.gemspec +37 -121
  3. data/bin/beetle +9 -0
  4. data/examples/README.rdoc +0 -2
  5. data/examples/rpc.rb +3 -2
  6. data/ext/mkrf_conf.rb +19 -0
  7. data/lib/beetle.rb +2 -2
  8. data/lib/beetle/base.rb +1 -8
  9. data/lib/beetle/client.rb +16 -14
  10. data/lib/beetle/commands.rb +30 -0
  11. data/lib/beetle/commands/configuration_client.rb +73 -0
  12. data/lib/beetle/commands/configuration_server.rb +85 -0
  13. data/lib/beetle/configuration.rb +70 -7
  14. data/lib/beetle/deduplication_store.rb +50 -38
  15. data/lib/beetle/handler.rb +2 -5
  16. data/lib/beetle/logging.rb +7 -0
  17. data/lib/beetle/message.rb +11 -13
  18. data/lib/beetle/publisher.rb +12 -4
  19. data/lib/beetle/r_c.rb +2 -1
  20. data/lib/beetle/redis_configuration_client.rb +136 -0
  21. data/lib/beetle/redis_configuration_server.rb +301 -0
  22. data/lib/beetle/redis_ext.rb +79 -0
  23. data/lib/beetle/redis_master_file.rb +35 -0
  24. data/lib/beetle/redis_server_info.rb +65 -0
  25. data/lib/beetle/subscriber.rb +4 -1
  26. data/test/beetle/configuration_test.rb +14 -2
  27. data/test/beetle/deduplication_store_test.rb +61 -43
  28. data/test/beetle/message_test.rb +28 -4
  29. data/test/beetle/publisher_test.rb +17 -3
  30. data/test/beetle/redis_configuration_client_test.rb +97 -0
  31. data/test/beetle/redis_configuration_server_test.rb +278 -0
  32. data/test/beetle/redis_ext_test.rb +71 -0
  33. data/test/beetle/redis_master_file_test.rb +39 -0
  34. data/test/test_helper.rb +13 -1
  35. metadata +162 -69
  36. data/.gitignore +0 -5
  37. data/MIT-LICENSE +0 -20
  38. data/Rakefile +0 -114
  39. data/TODO +0 -7
  40. data/etc/redis-master.conf +0 -189
  41. data/etc/redis-slave.conf +0 -189
  42. data/examples/redis_failover.rb +0 -65
  43. data/script/start_rabbit +0 -29
  44. data/snafu.rb +0 -55
  45. data/test/beetle.yml +0 -81
  46. data/test/beetle/bla.rb +0 -0
  47. data/tmp/master/.gitignore +0 -2
  48. data/tmp/slave/.gitignore +0 -3
data/script/start_rabbit DELETED
@@ -1,29 +0,0 @@
1
- #!/bin/bash
2
-
3
- # export RABBITMQ_MNESIA_BASE=/var/lib/rabbitmq/mnesia2
4
- # Defaults to /var/lib/rabbitmq/mnesia. Set this to the directory where Mnesia
5
- # database files should be placed.
6
-
7
- # export RABBITMQ_LOG_BASE
8
- # Defaults to /var/log/rabbitmq. Log files generated by the server will be placed
9
- # in this directory.
10
-
11
- export RABBITMQ_NODENAME=$1
12
- # Defaults to rabbit. This can be useful if you want to run more than one node
13
- # per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine
14
- # combination. See clustering on a single machine guide at <http://www.rab-
15
- # bitmq.com/clustering.html#single-machine> for details.
16
-
17
- # RABBITMQ_NODE_IP_ADDRESS
18
- # Defaults to 0.0.0.0. This can be changed if you only want to bind to one net-
19
- # work interface.
20
-
21
- export RABBITMQ_NODE_PORT=$2
22
- # Defaults to 5672.
23
-
24
- # RABBITMQ_CLUSTER_CONFIG_FILE
25
- # Defaults to /etc/rabbitmq/rabbitmq_cluster.config. If this file is present it
26
- # is used by the server to auto-configure a RabbitMQ cluster. See the clustering
27
- # guide at <http://www.rabbitmq.com/clustering.html> for details.
28
-
29
- rabbitmq-server
data/snafu.rb DELETED
@@ -1,55 +0,0 @@
1
- # The simplest case
2
- client.register_message(:something_happened) # => key: something_happened
3
-
4
- # with options
5
- client.register_message(:
6
-
7
- ####################
8
- # Message Grouping #
9
- ####################
10
-
11
- client.register_message(:delete_something, :group => :jobs) # => key: jobs.delete_something
12
- client.register_message(:create_something, :group => :jobs) # => key: jobs.create_something
13
-
14
- # You can register a handler for a message group
15
- client.register_handler(JobsHandler, :group => :jobs) # bind queue with: jobs.*
16
-
17
- # And still register on single messages
18
- client.register_handler(DeletedJobHandler, :delete_something) # bind queue with: *.delete_something
19
-
20
- ######################
21
- # Handler Definition #
22
- ######################
23
-
24
- # With a Handler class that implements .process(message)
25
- client.register_handler(MyProcessor, :something_happened) # => queue: my_processor
26
-
27
- # With a String / Symbol and a block
28
- client.register_handler("Other Processor", :delete_something, :something_happened) lambda { |message| foobar(message) } # => queue: other_processor, bound with: *.delete_something and *.something_happened
29
-
30
- # With extra parameters
31
- client.register_handler(VeryImportant, :delete_something, :immediate => true) # queue: very_important, :immediate => true
32
-
33
- ###################################
34
- # Wiring, Subscribing, Publishing #
35
- ###################################
36
- client.wire! # => all the binding magic happens
37
-
38
- client.subscribe
39
-
40
- client.publish(:delete_something, 'payload')
41
-
42
- __END__
43
-
44
- Whats happening when wire! is called? (pseudocode)
45
- 1. all the messages are registered
46
- messages = [{:name => :delete_something, :group => :jobs, :bound => false}, {:name => :something_happened, :bound => false}]
47
- 2. all the queues for the handlers are created and bound...
48
- my_processor_queue = queue(:my_processor).bind(exchange, :key => '*.something_happened')
49
- jobs_handler_queue = queue(:jobs_handler).bind(exchange, :key => 'jobs.*')
50
- handlers_with_queues = [[jobs_handler_queue, JobsHandler], [my_processor_queue, block_or_class]]
51
- 3. every handler definition binds a queue for the handler to a list of messages and marks the message as bound.
52
- 4. If in the end a message isn't bound to a queue at least once, an exception is raised
53
-
54
- Exceptions will be thrown if:
55
- * after all m
data/test/beetle.yml DELETED
@@ -1,81 +0,0 @@
1
- # list all standard exchanges used by the main xing app, along with their options for declaration
2
- # used by producers and consumers
3
- exchanges:
4
- test:
5
- type: "topic"
6
- durable: true
7
- deadletter:
8
- type: "topic"
9
- durable: true
10
- redundant:
11
- type: "topic"
12
- durable: true
13
-
14
- # list all standard queues along with their binding declaration
15
- # this section is only used by consumers
16
- queues:
17
- test: # binding options
18
- exchange: "test" # Bandersnatch default is the name of the queue
19
- passive: false # amqp default is false
20
- durable: true # amqp default is false
21
- exclusive: false # amqp default is false
22
- auto_delete: false # amqp default is false
23
- nowait: true # amqp default is true
24
- key: "#" # listen to every message
25
- deadletter:
26
- exchange: "deadletter"
27
- durable: true
28
- key: "#"
29
- redundant:
30
- exchange: "redundant"
31
- durable: true
32
- key: "#"
33
- additional_queue:
34
- exchange: "redundant"
35
- durable: true
36
- key: "#"
37
-
38
- # list all messages we can publish
39
- messages:
40
- test:
41
- queue: "test"
42
- # Spefify the queue for listeners (default is message name)
43
- key: "test"
44
- # Specifies the routing key pattern for message subscription.
45
- ttl: <%= 1.hour %>
46
- # Specifies the time interval after which messages are silently dropped (seconds)
47
- mandatory: true
48
- # default is false
49
- # Tells the server how to react if the message
50
- # cannot be routed to a queue. If set to _true_, the server will return an unroutable message
51
- # with a Return method. If this flag is zero, the server silently drops the message.
52
- immediate: false
53
- # default is false
54
- # Tells the server how to react if the message
55
- # cannot be routed to a queue consumer immediately. If set to _true_, the server will return an
56
- # undeliverable message with a Return method. If set to _false_, the server will queue the message,
57
- # but with no guarantee that it will ever be consumed.
58
- persistent: true
59
- # default is false
60
- # Tells the server whether to persist the message
61
- # If set to _true_, the message will be persisted to disk and not lost if the server restarts.
62
- # If set to _false_, the message will not be persisted across server restart. Setting to _true_
63
- # incurs a performance penalty as there is an extra cost associated with disk access.
64
- deadletter:
65
- key: "deadletter"
66
- persistent: true
67
- redundant:
68
- key: "redundant"
69
- persistent: true
70
- redundant: true
71
-
72
- development: &development
73
- hostname: localhost:5672, localhost:5673
74
- # hostname: localhost:5672
75
- msg_id_store:
76
- host: localhost
77
- db: 4
78
-
79
- test:
80
- <<: *development
81
- hostname: localhost:5672
data/test/beetle/bla.rb DELETED
File without changes
@@ -1,2 +0,0 @@
1
- *.rdb
2
- appendonly.aof
data/tmp/slave/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- *.rdb
2
- appendonly.aof
3
-