Skip to content

Commit b45784c

Browse files
陈家文陈家文
陈家文
authored and
陈家文
committed
mr.wen 整理代码
1 parent 19b5ba5 commit b45784c

5 files changed

+14
-11
lines changed

Src/AsyncLogHandle/AsyncLogObserver.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ interface AsyncLogObserver
1111
{
1212
/**
1313
* 绑定处理方法
14+
* @param $context
15+
* @return mixed
1416
* @Author jiaWen.chen
1517
*/
16-
public function onHandle();
18+
public function onHandle($context);
1719

1820
/**
1921
* 订阅消息内容

Src/AsyncLogHandle/AsyncLogSubject.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ public function handle()
8080

8181
// 2.1 格式化数据结构
8282
$this->_handleBefore(fgets($fp, 1024 * 1024 * 1024), $lineNum++);
83-
8483
// 2.2 判断是否已经执行完毕
8584
if (empty($this->log_deal['deal_contain'])) {
8685
$this->_dealSuccessContain();
8786
Log::notice("执行定时任务,读取日志文件来完成订阅与发布,执行完毕!!!");
8887
break;
8988
}
90-
89+
dump('执行定时任务,读取日志文件来完成订阅与发布,正在执行第'.$this->log_deal['deal_contain']['line_num'].'行...');
9190

9291
// 2.3 执行对应的message事物。
9392
$observerExists = $observerResult = null;
@@ -97,7 +96,7 @@ public function handle()
9796
$observerExists = true;
9897
}
9998
}
100-
dump($observerResult);
99+
101100
if (empty($observerExists)) {
102101
// 2.4 如果不存在这个观察者
103102
$this->_dealSuccessContain();
@@ -127,12 +126,10 @@ public function handle()
127126
]);
128127
} else if ($observerResult === true) {
129128
// 2.7 执行成功
130-
// dump($this->log_deal['success_contain']);
131129
$this->log_deal['success_contain'] = [
132130
'start_line' => $this->log_deal['success_contain']['start_line']?:$this->log_deal['deal_contain']['line_num'],
133131
'end_line' => $this->log_deal['deal_contain']['line_num']
134132
];
135-
// dump($this->log_deal['success_contain']);
136133
}
137134
}
138135
}

example/AsyncLogCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public function handle()
4242
$asyncLogSubject->addObserver(new AsyncLogObserverOfNumA());
4343
$asyncLogSubject->addObserver(new AsyncLogObserverOfNumB());
4444
$asyncLogSubject->handle();
45-
// dd($asyncLogSubject);
4645
}
4746

4847
}

example/AsyncLogObserverOfNumA.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
class AsyncLogObserverOfNumA extends AsyncLogObserverOfGenerator
88
{
9-
public function onHandle()
9+
public function onHandle($context)
1010
{
11-
return false;
11+
// TODO: Implement onHandle() method.
12+
13+
dump($context);
14+
return true;
1215
}
1316
}

example/AsyncLogObserverOfNumB.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
class AsyncLogObserverOfNumB extends AsyncLogObserverOfGenerator
88
{
9-
public function onHandle()
9+
public function onHandle($context)
1010
{
11-
return true;
11+
dump($context);
12+
13+
return true;
1214
}
1315
}

0 commit comments

Comments
 (0)