monitor

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequest

func AddRequest(ctx context.Context, model string, channelID int64, isError, tryBan bool) (beyondThreshold bool, banExecution bool, err error)

AddRequest adds a request record and checks if channel should be banned

func ClearAllModelErrors

func ClearAllModelErrors(ctx context.Context) error

ClearAllModelErrors clears all error records

func ClearChannelAllModelErrors

func ClearChannelAllModelErrors(ctx context.Context, channelID int) error

ClearChannelAllModelErrors clears all errors for a specific channel

func ClearChannelModelErrors

func ClearChannelModelErrors(ctx context.Context, model string, channelID int) error

ClearChannelModelErrors clears errors for a specific channel and model

func GetAllBannedModelChannels

func GetAllBannedModelChannels(ctx context.Context) (map[string][]int64, error)

GetAllBannedModelChannels gets all banned channels for all models

func GetAllChannelModelErrorRates

func GetAllChannelModelErrorRates(ctx context.Context) (map[int64]map[string]float64, error)

GetAllChannelModelErrorRates gets error rates for all channels and models

func GetBannedChannelsWithModel

func GetBannedChannelsWithModel(ctx context.Context, model string) ([]int64, error)

GetBannedChannelsWithModel gets banned channels for a specific model

func GetChannelModelErrorRates

func GetChannelModelErrorRates(ctx context.Context, channelID int64) (map[string]float64, error)

GetChannelModelErrorRates gets error rates for a specific channel

func GetModelChannelErrorRate

func GetModelChannelErrorRate(ctx context.Context, model string) (map[int64]float64, error)

func GetModelsErrorRate

func GetModelsErrorRate(ctx context.Context) (map[string]float64, error)

GetModelErrorRate gets error rate for a specific model across all channels

Types

type ChannelStats

type ChannelStats struct {
	// contains filtered or unexported fields
}

type MemModelMonitor

type MemModelMonitor struct {
	// contains filtered or unexported fields
}

func NewMemModelMonitor

func NewMemModelMonitor() *MemModelMonitor

func (*MemModelMonitor) AddRequest

func (m *MemModelMonitor) AddRequest(model string, channelID int64, isError, tryBan bool) (beyondThreshold, banExecution bool)

func (*MemModelMonitor) ClearAllModelErrors

func (m *MemModelMonitor) ClearAllModelErrors(_ context.Context) error

func (*MemModelMonitor) ClearChannelAllModelErrors

func (m *MemModelMonitor) ClearChannelAllModelErrors(_ context.Context, channelID int) error

func (*MemModelMonitor) ClearChannelModelErrors

func (m *MemModelMonitor) ClearChannelModelErrors(_ context.Context, model string, channelID int) error

func (*MemModelMonitor) GetAllBannedModelChannels

func (m *MemModelMonitor) GetAllBannedModelChannels(_ context.Context) (map[string][]int64, error)

func (*MemModelMonitor) GetAllChannelModelErrorRates

func (m *MemModelMonitor) GetAllChannelModelErrorRates(_ context.Context) (map[int64]map[string]float64, error)

func (*MemModelMonitor) GetBannedChannelsWithModel

func (m *MemModelMonitor) GetBannedChannelsWithModel(_ context.Context, model string) ([]int64, error)

func (*MemModelMonitor) GetChannelModelErrorRates

func (m *MemModelMonitor) GetChannelModelErrorRates(_ context.Context, channelID int64) (map[string]float64, error)

func (*MemModelMonitor) GetModelChannelErrorRate

func (m *MemModelMonitor) GetModelChannelErrorRate(_ context.Context, model string) (map[int64]float64, error)

func (*MemModelMonitor) GetModelsErrorRate

func (m *MemModelMonitor) GetModelsErrorRate(_ context.Context) (map[string]float64, error)

type ModelData

type ModelData struct {
	// contains filtered or unexported fields
}

type TimeWindowStats

type TimeWindowStats struct {
	// contains filtered or unexported fields
}

func NewTimeWindowStats

func NewTimeWindowStats() *TimeWindowStats

func (*TimeWindowStats) AddRequest

func (t *TimeWindowStats) AddRequest(now time.Time, isError bool)

func (*TimeWindowStats) GetStats

func (t *TimeWindowStats) GetStats() (totalReq, totalErr int)

func (*TimeWindowStats) HasValidSlices

func (t *TimeWindowStats) HasValidSlices() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL