fix(gateway): 收敛 sdk.Channel 与 adapter.PlatformAdapter 接口漂移,/admin/channels 恢复枚举
根因:sdk.Channel.Connect 为 2 参 (ctx, config any),adapter.PlatformAdapter.Connect 为 1 参 (ctx),Go 无重载 → 4 个渠道(qq-obv11/weixin-ilink/telegram/webhook)只实现 1 参 Connect,类型断言 cap.Value.(sdk.Channel) 恒失败 → /api/v1/admin/channels 恒返回 []。 收敛方向:sdk.Channel.Connect 改 1 参 (ctx),与 PlatformAdapter 生命周期子集一致; 4 个真实适配器自动满足新接口,adminListChannels 枚举成功。最小改动(不改渠道实现、 不引依赖)。同步修正 sdk_test/registry_test/extra_test 的 mock。
This commit is contained in:
1 parent
77f75b0d99
commit
5dae2b9741
4 files changed
+31
-20
No files matched your search
@@ -16,9 +16,9 @@ import "context"
|
||||
type Channel interface {
|
||||
// Name returns the platform identifier (for example "qq", "telegram").
|
||||
Name() string
|
||||
// Connect establishes the platform connection using config. It may be
|
||||
// called more than once and must be idempotent.
|
||||
Connect(ctx context.Context, config any) error
|
||||
// Connect establishes the platform connection. It may be called more than
|
||||
// once and must be idempotent.
|
||||
Connect(ctx context.Context) error
|
||||
// Disconnect tears the connection down gracefully. It returns nil when the
|
||||
// adapter was already disconnected.
|
||||
Disconnect(ctx context.Context) error
|
||||
|
||||
@@ -31,7 +31,7 @@ func (s stubSkill) Guardrails() []Guardrail {
|
||||
type stubChannel struct{ name string }
|
||||
|
||||
func (s stubChannel) Name() string { return s.name }
|
||||
func (s stubChannel) Connect(_ context.Context, _ any) error { return nil }
|
||||
func (s stubChannel) Connect(_ context.Context) error { return nil }
|
||||
func (s stubChannel) Disconnect(_ context.Context) error { return nil }
|
||||
func (s stubChannel) IsConnected() bool { return true }
|
||||
func (s stubChannel) HealthCheck(_ context.Context) error { return nil }
|
||||
|
||||
Reference in new issue
Block a user