diff --git a/internal/channel/base_channel.go b/internal/channel/base_channel.go index 2c6c771..d6610b7 100644 --- a/internal/channel/base_channel.go +++ b/internal/channel/base_channel.go @@ -23,12 +23,15 @@ type UpstreamInfo struct { // BaseChannel provides common functionality for channel proxies. type BaseChannel struct { - Name string - Upstreams []UpstreamInfo - HTTPClient *http.Client - StreamClient *http.Client - TestModel string - upstreamLock sync.Mutex + Name string + Upstreams []UpstreamInfo + HTTPClient *http.Client + StreamClient *http.Client + TestModel string + upstreamLock sync.Mutex + + // Cached fields from the group for stale check + channelType string groupUpstreams datatypes.JSON effectiveConfig *types.SystemSettings } @@ -87,14 +90,18 @@ func (b *BaseChannel) BuildUpstreamURL(originalURL *url.URL, group *models.Group // IsConfigStale checks if the channel's configuration is stale compared to the provided group. func (b *BaseChannel) IsConfigStale(group *models.Group) bool { + if b.channelType != group.ChannelType { + return true + } + if b.TestModel != group.TestModel { + return true + } if !bytes.Equal(b.groupUpstreams, group.Upstreams) { return true } - if !reflect.DeepEqual(b.effectiveConfig, &group.EffectiveConfig) { return true } - return false } diff --git a/internal/channel/factory.go b/internal/channel/factory.go index ef8fd53..42bed43 100644 --- a/internal/channel/factory.go +++ b/internal/channel/factory.go @@ -145,6 +145,7 @@ func (f *Factory) newBaseChannel(name string, group *models.Group) (*BaseChannel HTTPClient: httpClient, StreamClient: streamClient, TestModel: group.TestModel, + channelType: group.ChannelType, groupUpstreams: group.Upstreams, effectiveConfig: &group.EffectiveConfig, }, nil