Skip to content

Commit ed6053f

Browse files
committed
~
1 parent ed03345 commit ed6053f

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.zan-ide-helper.php

+9
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ public function release($connObj, int $conStatus = self::SWOOLE_CONNNECT_OK){}
139139
* destroy 释放连接池对象,调用此接口前,需要将连接对象全部释放
140140
*/
141141
public function destroy() { }
142+
143+
/**
144+
* @return array
145+
* [
146+
* "all_conn_obj" => 0,
147+
* "idle_conn_obj" => 0,
148+
* ]
149+
*/
150+
public function getStatInfo() { }
142151
}
143152

144153
/**

src/Network/Connection/ConnectionManager.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,7 @@ public function monitorTick()
129129
}
130130

131131
foreach (self::$poolExMap as $poolKey => $pool) {
132-
$info = $pool->getStatInfo();
133-
$hawk->add(Constant::BIZ_CONNECTION_POOL,
134-
[
135-
'free' => $info["idle_conn_obj"],
136-
'active' => $info["all_conn_obj"] - $info["idle_conn_obj"],
137-
], [
132+
$hawk->add(Constant::BIZ_CONNECTION_POOL, $pool->getStatInfo(), [
138133
'pool_name' => $poolKey,
139134
]
140135
);

src/Network/Connection/PoolEx.php

+11
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,15 @@ public function release($conn, $close = false)
100100
return $this->poolEx->release($conn, \swoole_connpool::SWOOLE_CONNNECT_OK);
101101
}
102102
}
103+
104+
public function getStatInfo()
105+
{
106+
$info = $this->poolEx->getStatInfo();
107+
108+
return [
109+
"all" => $info["all_conn_obj"],
110+
"active" => $info["all_conn_obj"] - $info["idle_conn_obj"],
111+
"free" => $info["idle_conn_obj"],
112+
];
113+
}
103114
}

0 commit comments

Comments
 (0)