config.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. $dbResourceConfig = [
  3. 'host' => 'tfb-database',
  4. 'username' => 'benchmarkdbuser',
  5. 'password' => 'benchmarkdbpass',
  6. 'database' => 'hello_world',
  7. ];
  8. return [
  9. // 项目根命名空间
  10. 'namespace' => 'ImiApp',
  11. // 配置文件
  12. 'configs' => [
  13. 'beans' => __DIR__ . '/beans.php',
  14. ],
  15. // 扫描目录
  16. 'beanScan' => [],
  17. // 组件命名空间
  18. 'components' => [],
  19. // 主服务器配置
  20. 'mainServer' => [
  21. 'namespace' => 'ImiApp\ApiServer',
  22. 'type' => Imi\Server\Type::HTTP,
  23. 'host' => '0.0.0.0',
  24. 'port' => 8080,
  25. 'mode' => SWOOLE_BASE,
  26. 'configs' => [
  27. 'worker_num' => swoole_cpu_num(),
  28. 'open_tcp_nodelay' => true,
  29. 'tcp_fastopen' => true,
  30. ],
  31. ],
  32. 'db' => [
  33. 'defaultPool' => 'db', // 默认连接池
  34. ],
  35. 'pools' => [
  36. // 连接池名称
  37. 'db' => [
  38. 'sync' => [
  39. 'pool' => [
  40. 'class' => \Imi\Db\Pool\SyncDbPool::class,
  41. 'config' => [
  42. // 池子中最多资源数
  43. 'maxResources' => 512,
  44. // 池子中最少资源数
  45. 'minResources' => 0,
  46. 'gcInterval' => null,
  47. 'checkStateWhenGetResource' => false,
  48. ],
  49. ],
  50. // resource也可以定义多个连接
  51. 'resource' => $dbResourceConfig,
  52. ],
  53. // 异步池子,worker进程使用
  54. 'async' => [
  55. 'pool' => [
  56. 'class' => \Imi\Db\Pool\CoroutineDbPool::class,
  57. 'config' => [
  58. // 池子中最多资源数
  59. 'maxResources' => 512,
  60. // 池子中最少资源数
  61. 'minResources' => 16,
  62. 'gcInterval' => null,
  63. 'checkStateWhenGetResource' => false,
  64. ],
  65. ],
  66. // resource也可以定义多个连接
  67. 'resource' => $dbResourceConfig,
  68. ],
  69. ],
  70. ],
  71. ];