File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,22 @@ task load balancer for php (like the nginx load balancing)
4
4
# Usage
5
5
6
6
``` php
7
- //define tas
7
+ //define a task
8
8
Balancer::task('task1', function($task){
9
- //define driver
10
- $task->driver('driver1')
11
- ->weight(3)->backUp()
12
- ->data(['this is data 1'])
13
- ->work(function($driver, $data){
9
+
10
+ //define a driver for `task1` like this
11
+ $task->driver('driver1') //create a driver instance named 'driver1'
12
+ ->weight(100) //driver weight
13
+ ->backUp() //this driver is a back up driver
14
+ ->data(['this is data 1']) //data for driver work
15
+ ->work(function($driver, $data){ //define driver`s work
14
16
$driver->failed();
15
17
$msg = 'working! by '.$driver->name.'<br >';
16
18
print_r($msg);
17
19
return [$msg, $data];
18
20
});
19
21
20
- //define driver
22
+ //or
21
23
$task->driver('driver2')
22
24
->weight(3)->backUp(false)
23
25
->data(['this is data 2'])
@@ -28,7 +30,7 @@ Balancer::task('task1', function($task){
28
30
return [$msg, $data];
29
31
});
30
32
31
- //define driver
33
+ //or
32
34
$task->driver('driver3')
33
35
->weight(0)->backUp()
34
36
->data(['this is data 3'])
@@ -43,6 +45,10 @@ Balancer::task('task1', function($task){
43
45
//run task
44
46
$result = Balancer::run('task1');
45
47
```
48
+
49
+ #
50
+
51
+
46
52
# Todo
47
53
48
54
- [x] remember every tasks` start time and end time.
You can’t perform that action at this time.
0 commit comments