@@ -14,7 +14,7 @@ Lightweight and powerful task load balancing.
1414# Install
1515
1616``` php
17- composer require ' toplan/task-balancer:~0.5'
17+ composer require toplan/task-balancer:~0.5
1818```
1919
2020# Usage
@@ -33,7 +33,7 @@ Balancer::task('task1', function($task){
3333 $driver->failure();
3434 }
3535 //return some data you need
36- return 'some data here ';
36+ return 'some data you need ';
3737 });
3838
3939 //or like this:
@@ -70,7 +70,7 @@ The `$result` structure:
7070 'started_at' => timestamp,
7171 'finished_at' => timestamp
7272 ],
73- 'result' => 'some data here '
73+ 'result' => 'some data you need '
7474 ],
7575 ...
7676 ]
@@ -84,10 +84,11 @@ The `$result` structure:
8484### Balancer::task($name[ , $data] , Closure $ready);
8585
8686Create a task instance, and return it.
87+ The closure ` $ready ` immediately called with argument ` $task ` .
8788
8889``` php
8990Balancer::task('taskName', $data, function($task){
90- //task` s ready work, such as create drivers.
91+ //task' s ready work, such as create drivers.
9192});
9293```
9394
@@ -101,19 +102,23 @@ The keys of `$options`:
101102- ` data `
102103- ` driver `
103104
105+ ### $task->name($name)
106+
107+ set the name of task.
108+
104109### $task->data($data)
105110
106111Set the data of task.
107112
108113### $task->driver($config[ , $weight] [ , 'backup' ] , Closure $work)
109114
110- Create a driver for the task.
115+ Create a driver for the task. The closure ` $work ` will been called with arguments ` $driver ` and ` $data ` .
111116
112117> Expected ` $weight ` to be a integer, default ` 1 ` .
113118
114119``` php
115120$task->driver('driverName 80 backup', function($driver, $data){
116- //driver`s work
121+ //driver's job content.
117122});
118123```
119124
@@ -123,7 +128,7 @@ Set the weight value of driver.
123128
124129### $driver->backup($is)
125130
126- Whether the backup driver.
131+ Set whether backup driver.
127132
128133> Expected ` $is ` to be boolean.
129134
@@ -133,27 +138,35 @@ Set the data of driver.
133138
134139> ` $data ` will store in driver instance.
135140
136- ### $driver->work(Closure $work function($driver, $data){} );
141+ ### $driver->work(Closure $work);
137142
138- Set the work of driver, which will been called with two arguments: ` $driver ` , ` $data ` .
143+ Set the job content of driver.
139144
140145> ` $data ` equals to ` $driver->getData() `
141146
147+ ### $driver->reset($config[ , $weight] [ , 'backup' ] , Closure $work)
148+
149+ Reset driver's weight value, job content and reset whether backup.
150+
151+ ### $driver->destroy()
152+
153+ Remove the driver from task which belongs to.
154+
142155### $driver->failure()
143156
144- Set current driver run failed .
157+ Set the driver running failure .
145158
146159### $driver->success()
147160
148- Set current driver run succeed .
161+ Set the driver run successfully .
149162
150163### $driver->getDriverData()
151164
152- Get the data of driver.
165+ Get the data which store in driver instance .
153166
154167### $driver->getTaskData()
155168
156- Get the data of task.
169+ Get the data which store in task instance .
157170
158171
159172## 2. Lifecycle & Hooks
0 commit comments