Skip to content

Commit

Permalink
add setData() and getData() method to Task class
Browse files Browse the repository at this point in the history
  • Loading branch information
toplan committed Nov 18, 2015
1 parent 9c47a45 commit e1ac7ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lightweight and powerful task load balancing for php
# Install

```php
composer require 'toplan/task-balancer:~0.1.0'
composer require 'toplan/task-balancer:~0.1.1'
```

# Usage
Expand Down Expand Up @@ -135,6 +135,10 @@ get data from driver instance.

get data from task instance.

###12. $task->setData()

set data to task instance, and override old data!

## Task Lifecycle

| Hook name | handler arguments | handler return value |
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "toplan/task-balancer",
"description": "lightweight and powerful task load balancing for php (like the nginx load balancing)",
"license": "MIT",
"version": "0.1.0",
"version": "0.1.1",
"keywords": ["task", "balance", "load balancing", "balancer"],
"authors": [
{
Expand Down
22 changes: 22 additions & 0 deletions src/TaskBalancer/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,28 @@ protected function callHookHandler($hookName, $data = null)
return true;
}

/**
* set task data
* @param $data
*
* @return $this
*/
public function setData($data)
{
$this->data = $data;
return $this;
}

/**
* get task data
* equal: $task->data
* @return null
*/
public function getData()
{
return $this->data;
}

/**
* properties overload
* @param $name
Expand Down

0 comments on commit e1ac7ba

Please sign in to comment.