thirdparty.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | ThirdParty模块配置
  6. |--------------------------------------------------------------------------
  7. |
  8. | 这里定义了ThirdParty模块的各种配置选项
  9. |
  10. */
  11. // 模块基础配置
  12. 'module' => [
  13. 'name' => 'ThirdParty',
  14. 'version' => '1.0.0',
  15. 'description' => '第三方服务管理模块',
  16. 'author' => 'KKU Team',
  17. ],
  18. // 默认配置
  19. 'defaults' => [
  20. 'timeout' => 30, // 默认超时时间(秒)
  21. 'retry_times' => 3, // 默认重试次数
  22. 'retry_delay' => 1000, // 默认重试延迟(毫秒)
  23. 'auth_type' => 'API_KEY', // 默认认证类型
  24. 'service_status' => 'INACTIVE', // 默认服务状态
  25. 'environment' => 'production', // 默认环境
  26. 'health_check_interval' => 300, // 默认健康检查间隔(秒)
  27. ],
  28. // HTTP客户端配置
  29. 'http' => [
  30. 'timeout' => 30, // HTTP请求超时时间
  31. 'connect_timeout' => 10, // 连接超时时间
  32. 'verify' => true, // 是否验证SSL证书
  33. 'user_agent' => 'KKU-ThirdParty/1.0',
  34. 'headers' => [
  35. 'Accept' => 'application/json',
  36. 'Content-Type' => 'application/json',
  37. ],
  38. ],
  39. // 重试配置
  40. 'retry' => [
  41. 'max_attempts' => 3, // 最大重试次数
  42. 'delay' => 1000, // 重试延迟(毫秒)
  43. 'multiplier' => 2, // 延迟倍数
  44. 'max_delay' => 10000, // 最大延迟(毫秒)
  45. 'retry_on_status' => [ // 需要重试的HTTP状态码
  46. 429, 500, 502, 503, 504
  47. ],
  48. ],
  49. // 日志配置
  50. 'logging' => [
  51. 'enabled' => true, // 是否启用日志
  52. 'level' => 'INFO', // 默认日志级别
  53. 'max_body_size' => 10240, // 最大请求/响应体大小(字节)
  54. 'sensitive_fields' => [ // 敏感字段(不记录到日志)
  55. 'password',
  56. 'secret',
  57. 'token',
  58. 'key',
  59. 'authorization',
  60. ],
  61. 'retention_days' => 30, // 日志保留天数
  62. ],
  63. // 监控配置
  64. 'monitoring' => [
  65. 'enabled' => true, // 是否启用监控
  66. 'health_check' => [
  67. 'enabled' => true, // 是否启用健康检查
  68. 'interval' => 300, // 检查间隔(秒)
  69. 'timeout' => 10, // 检查超时时间(秒)
  70. 'retry_times' => 2, // 检查重试次数
  71. ],
  72. 'performance' => [
  73. 'enabled' => true, // 是否启用性能监控
  74. 'slow_threshold' => 2000, // 慢请求阈值(毫秒)
  75. 'alert_threshold' => 5000, // 告警阈值(毫秒)
  76. ],
  77. 'availability' => [
  78. 'enabled' => true, // 是否启用可用性监控
  79. 'check_interval' => 60, // 检查间隔(秒)
  80. 'failure_threshold' => 3, // 失败阈值
  81. ],
  82. ],
  83. // 配额管理配置
  84. 'quota' => [
  85. 'enabled' => true, // 是否启用配额管理
  86. 'default_limits' => [
  87. 'PER_MINUTE' => 100, // 每分钟默认限制
  88. 'PER_HOUR' => 1000, // 每小时默认限制
  89. 'PER_DAY' => 10000, // 每天默认限制
  90. 'PER_MONTH' => 100000, // 每月默认限制
  91. ],
  92. 'alert_threshold' => 80, // 默认告警阈值(百分比)
  93. 'auto_reset' => true, // 是否自动重置配额
  94. ],
  95. // 缓存配置
  96. 'cache' => [
  97. 'enabled' => true, // 是否启用缓存
  98. 'prefix' => 'thirdparty:', // 缓存键前缀
  99. 'ttl' => 3600, // 默认缓存时间(秒)
  100. 'credentials_ttl' => 1800, // 凭证缓存时间(秒)
  101. 'quota_ttl' => 300, // 配额缓存时间(秒)
  102. ],
  103. // 安全配置
  104. 'security' => [
  105. 'encryption' => [
  106. 'enabled' => true, // 是否启用加密
  107. 'algorithm' => 'AES-256-CBC', // 加密算法
  108. ],
  109. 'webhook' => [
  110. 'verify_signature' => true, // 是否验证Webhook签名
  111. 'signature_header' => 'X-Signature',
  112. 'signature_algorithm' => 'sha256',
  113. ],
  114. 'rate_limiting' => [
  115. 'enabled' => true, // 是否启用频率限制
  116. 'max_requests_per_minute' => 60,
  117. ],
  118. ],
  119. // 告警配置
  120. 'alerts' => [
  121. 'enabled' => true, // 是否启用告警
  122. 'channels' => ['mail', 'sms'], // 告警渠道
  123. 'thresholds' => [
  124. 'quota_usage' => 80, // 配额使用告警阈值(百分比)
  125. 'error_rate' => 10, // 错误率告警阈值(百分比)
  126. 'response_time' => 5000, // 响应时间告警阈值(毫秒)
  127. ],
  128. 'cooldown' => 300, // 告警冷却时间(秒)
  129. ],
  130. // 服务提供商配置模板
  131. 'providers' => [
  132. 'aliyun' => [
  133. 'name' => '阿里云',
  134. 'base_url' => 'https://ecs.aliyuncs.com',
  135. 'auth_type' => 'API_KEY',
  136. 'required_credentials' => ['access_key_id', 'access_key_secret'],
  137. 'regions' => ['cn-hangzhou', 'cn-beijing', 'cn-shanghai'],
  138. ],
  139. 'tencent' => [
  140. 'name' => '腾讯云',
  141. 'base_url' => 'https://cvm.tencentcloudapi.com',
  142. 'auth_type' => 'SIGNATURE',
  143. 'required_credentials' => ['secret_id', 'secret_key'],
  144. 'regions' => ['ap-beijing', 'ap-shanghai', 'ap-guangzhou'],
  145. ],
  146. 'baidu' => [
  147. 'name' => '百度云',
  148. 'base_url' => 'https://bcc.bj.baidubce.com',
  149. 'auth_type' => 'SIGNATURE',
  150. 'required_credentials' => ['access_key', 'secret_key'],
  151. 'regions' => ['bj', 'gz', 'su'],
  152. ],
  153. ],
  154. // 服务类型配置
  155. 'service_types' => [
  156. 'SMS' => [
  157. 'name' => '短信服务',
  158. 'icon' => 'fa-sms',
  159. 'color' => 'primary',
  160. 'default_timeout' => 10,
  161. 'default_retry' => 3,
  162. ],
  163. 'EMAIL' => [
  164. 'name' => '邮件服务',
  165. 'icon' => 'fa-envelope',
  166. 'color' => 'info',
  167. 'default_timeout' => 30,
  168. 'default_retry' => 2,
  169. ],
  170. 'PUSH' => [
  171. 'name' => '推送服务',
  172. 'icon' => 'fa-bell',
  173. 'color' => 'warning',
  174. 'default_timeout' => 15,
  175. 'default_retry' => 3,
  176. ],
  177. 'PAYMENT' => [
  178. 'name' => '支付服务',
  179. 'icon' => 'fa-credit-card',
  180. 'color' => 'success',
  181. 'default_timeout' => 60,
  182. 'default_retry' => 1,
  183. ],
  184. 'STORAGE' => [
  185. 'name' => '存储服务',
  186. 'icon' => 'fa-cloud',
  187. 'color' => 'secondary',
  188. 'default_timeout' => 120,
  189. 'default_retry' => 2,
  190. ],
  191. ],
  192. // 环境配置
  193. 'environments' => [
  194. 'production' => [
  195. 'name' => '生产环境',
  196. 'color' => 'danger',
  197. 'requires_approval' => true,
  198. ],
  199. 'staging' => [
  200. 'name' => '预发布环境',
  201. 'color' => 'warning',
  202. 'requires_approval' => false,
  203. ],
  204. 'development' => [
  205. 'name' => '开发环境',
  206. 'color' => 'info',
  207. 'requires_approval' => false,
  208. ],
  209. 'testing' => [
  210. 'name' => '测试环境',
  211. 'color' => 'secondary',
  212. 'requires_approval' => false,
  213. ],
  214. ],
  215. // 数据清理配置
  216. 'cleanup' => [
  217. 'enabled' => true, // 是否启用自动清理
  218. 'schedule' => '0 2 * * *', // 清理计划(Cron表达式)
  219. 'retention' => [
  220. 'logs' => 30, // 日志保留天数
  221. 'monitors' => 90, // 监控记录保留天数
  222. 'inactive_credentials' => 180, // 未使用凭证保留天数
  223. ],
  224. ],
  225. // 导出配置
  226. 'export' => [
  227. 'formats' => ['csv', 'excel', 'json'],
  228. 'max_records' => 10000, // 最大导出记录数
  229. 'chunk_size' => 1000, // 分块大小
  230. ],
  231. ];