File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 33
44namespace rabbit \pool ;
55
6- use common \Ldap \Ldap ;
76use rabbit \App ;
87use rabbit \exception \NotSupportedException ;
98
@@ -25,6 +24,26 @@ public function __construct(BasePool $pool)
2524 $ this ->pool = $ pool ;
2625 }
2726
27+ /**
28+ * @param callable $function
29+ * @throws \rabbit\core\Exception
30+ */
31+ public function __invoke (callable $ function )
32+ {
33+ $ client = $ this ->pool ->get ();
34+ if ($ client instanceof IUnity) {
35+ $ client = $ client ->build ();
36+ }
37+ try {
38+ return call_user_func ($ function , $ client );
39+ } catch (Throwable $ exception ) {
40+ App::error ($ exception ->getMessage ());
41+ throw $ exception ;
42+ } finally {
43+ $ this ->pool ->release ($ client );
44+ }
45+ }
46+
2847 /**
2948 * @param $name
3049 * @param $arguments
You can’t perform that action at this time.
0 commit comments