NewBaseAsyncPluginWithFilter 创建基础异步插件(支持设置Service层过滤参数)
(name string, priority int, skipServiceFilter bool)
| 449 | |
| 450 | // NewBaseAsyncPluginWithFilter 创建基础异步插件(支持设置Service层过滤参数) |
| 451 | func NewBaseAsyncPluginWithFilter(name string, priority int, skipServiceFilter bool) *BaseAsyncPlugin { |
| 452 | // 确保异步插件已初始化 |
| 453 | if !initialized { |
| 454 | initAsyncPlugin() |
| 455 | } |
| 456 | |
| 457 | // 确定超时和缓存时间 |
| 458 | responseTimeout := defaultAsyncResponseTimeout |
| 459 | processingTimeout := defaultPluginTimeout |
| 460 | cacheTTL := defaultCacheTTL |
| 461 | |
| 462 | // 如果配置已初始化,则使用配置中的值 |
| 463 | if config.AppConfig != nil { |
| 464 | responseTimeout = config.AppConfig.AsyncResponseTimeoutDur |
| 465 | processingTimeout = config.AppConfig.PluginTimeout |
| 466 | cacheTTL = time.Duration(config.AppConfig.AsyncCacheTTLHours) * time.Hour |
| 467 | } |
| 468 | |
| 469 | return &BaseAsyncPlugin{ |
| 470 | name: name, |
| 471 | priority: priority, |
| 472 | client: &http.Client{ |
| 473 | Timeout: responseTimeout, |
| 474 | }, |
| 475 | backgroundClient: &http.Client{ |
| 476 | Timeout: processingTimeout, |
| 477 | }, |
| 478 | cacheTTL: cacheTTL, |
| 479 | finalUpdateTracker: make(map[string]bool), // 初始化缓存更新追踪器 |
| 480 | skipServiceFilter: skipServiceFilter, // 使用传入的过滤设置 |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | // ============================================================ |
| 485 | // 第七部分:BaseAsyncPlugin 接口实现方法 |
no test coverage detected