drbqs 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc DELETED
@@ -1,128 +0,0 @@
1
- = drbqs
2
-
3
- Task queuing system over network that is implemented by dRuby.
4
-
5
- == Requirements
6
-
7
- DRbQS uses Fiber, so ruby requires version 1.9.
8
-
9
- == Usage
10
-
11
- === Preparation
12
-
13
- We prepare a class to send tasks over network,
14
- which has data and a method to deal with tasks.
15
-
16
- We make sum.rb as the following.
17
-
18
- class Sum
19
- def initialize(start_num, end_num)
20
- @num = [start_num, end_num]
21
- end
22
-
23
- def exec
24
- (@num[0]..@num[1]).inject(0) { |sum, i| sum += i }
25
- end
26
- end
27
-
28
- The Sum class calculates sum of numbers from start_num to end_num.
29
- The task we want to calculate is summation of numbers.
30
-
31
- === Start server
32
-
33
- We make server.rb as the following.
34
-
35
- require_relative 'sum.rb'
36
-
37
- DRbQS.define_server(:finish_exit => true) do |server, argv, opts|
38
- 10.step(100, 10) do |i|
39
- task = DRbQS::Task.new(Sum.new(i - 10, i), :exec)
40
- server.queue.add(task)
41
- end
42
- end
43
-
44
- In terminal, we load server.rb and execute server of drbqs.
45
-
46
- drbqs-server server.rb -p 13500
47
-
48
- === Hook of server
49
-
50
- We can use two hooks of server: 'empty_queue' and 'finish'.
51
-
52
- DRbQS.define_server do |server, argv, opts|
53
- server.add_hook(:empty_queue) do |srv|
54
- srm.queue.add( ... )
55
- end
56
-
57
- server.add_hook(:finish) do |srv|
58
- srm.exit
59
- end
60
- end
61
-
62
- 'finish' hook usually exit server program, but
63
- an option :finish_exit for DRbQS.define_server or DRbQS.new
64
- is nearly same.
65
-
66
- We can use 'empty_queue' hook for adding tasks
67
- when task queue is empty.
68
-
69
- === Task generator
70
-
71
- Arguments of DRbQS::TaskGenerator.new define instance variables.
72
-
73
- task_generator = DRbQS::TaskGenerator.new(:abc => 'ABC', :def => 123, :data => [1, 2, 3])
74
-
75
- The above example defines the following instance variables.
76
-
77
- @abc = 'ABC'
78
- @def = 123
79
- @data = [1, 2, 3]
80
-
81
- Then, DRbQS::TaskGenerator#set method defines generation of tasks.
82
- The block of the method is evaluated in the context of task_generator.
83
- For the above example we can use @abc, @def, and @data.
84
-
85
- task_generator.set do
86
- @data.each do |i|
87
- create_add_task(i, :to_s)
88
- end
89
- end
90
-
91
- DRbQS::TaskGenerator#create_add_task creates a task
92
- and the task is returned by DRbQS::TaskGenerator#new_tasks.
93
- The arguments of DRbQS::TaskGenerator#create_add_task is
94
- the same as DRbQS::Task.new.
95
-
96
- To use the generator in DRbQS::Server,
97
- we set the generator by DRbQS::Server#add_task_generator.
98
-
99
- === Start node and connect server
100
-
101
- Because nodes needs class Sum,
102
- the nodes load sum.rb when they starts.
103
- Then, we type in terminal.
104
-
105
- drbqs-node druby://localhost:13500/ -l sum.rb
106
-
107
- To use two cpu cores we execute two processes by the following.
108
-
109
- drbqs-node 2 druby://localhost:13500/ -l sum.rb
110
-
111
- Then, if it succeeds, the calculation starts.
112
- If it finishes, the server and node ends.
113
-
114
- == Contributing to drbqs
115
-
116
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
117
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
118
- * Fork the project
119
- * Start a feature/bugfix branch
120
- * Commit and push until you are happy with your contribution
121
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
122
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
123
-
124
- == Copyright
125
-
126
- Copyright (c) 2011 Takayuki YAMAGUCHI. See LICENSE.txt for
127
- further details.
128
-