mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-18 06:03:42 +08:00
账单作为可选开关
This commit is contained in:
32
monitor/monitor.go
Normal file
32
monitor/monitor.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package monitor
|
||||
|
||||
import "github.com/songquanpeng/one-api/relay/model"
|
||||
|
||||
type MonitorInstance interface {
|
||||
Emit(ChannelId int, success bool)
|
||||
ShouldDisableChannel(err *model.Error, statusCode int) bool
|
||||
DisableChannel(channelId int, channelName string, reason string)
|
||||
}
|
||||
|
||||
type defaultMonitor struct {
|
||||
}
|
||||
|
||||
func NewMonitorInstance() MonitorInstance {
|
||||
return &defaultMonitor{}
|
||||
}
|
||||
|
||||
func (m *defaultMonitor) Emit(channelId int, success bool) {
|
||||
if success {
|
||||
metricSuccessChan <- channelId
|
||||
} else {
|
||||
metricFailChan <- channelId
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultMonitor) ShouldDisableChannel(err *model.Error, statusCode int) bool {
|
||||
return ShouldDisableChannel(err, statusCode)
|
||||
}
|
||||
|
||||
func (m *defaultMonitor) DisableChannel(channelId int, channelName string, reason string) {
|
||||
DisableChannel(channelId, channelName, reason)
|
||||
}
|
||||
Reference in New Issue
Block a user