PoolInterface.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * This file is part of workerman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<walkor@workerman.net>
  10. * @copyright walkor<walkor@workerman.net>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. declare(strict_types=1);
  15. namespace Workerman\Coroutine;
  16. /**
  17. * Interface PoolInterface
  18. */
  19. interface PoolInterface
  20. {
  21. /**
  22. * Get a connection from the pool.
  23. *
  24. * @return mixed
  25. */
  26. public function get(): mixed;
  27. /**
  28. * Put a connection back to the pool.
  29. *
  30. * @param object $connection
  31. * @return void
  32. */
  33. public function put(object $connection): void;
  34. /**
  35. * Create a connection.
  36. *
  37. * @return object
  38. */
  39. public function createConnection(): object;
  40. /**
  41. * Close the connection and remove the connection from the connection pool.
  42. *
  43. * @param object $connection
  44. * @return void
  45. */
  46. public function closeConnection(object $connection): void;
  47. /**
  48. * Get the number of connections in the connection pool.
  49. *
  50. * @return int
  51. */
  52. public function getConnectionCount(): int;
  53. /**
  54. * Close connections in the connection pool.
  55. *
  56. * @return void
  57. */
  58. public function closeConnections(): void;
  59. }