daily.go
daily.go - Overview
- Overview
This file defines the DailyProvider
struct and its associated methods for detecting daily anomalies. It leverages the BaseSeasonalProvider
and implements the BaseProvider
interface.
- Detailed Documentation
type DailyProvider struct
- Purpose: Represents a provider for detecting daily anomalies. It embeds
BaseSeasonalProvider
to inherit common seasonal anomaly detection functionalities.
type DailyProvider struct {
BaseSeasonalProvider
}
var _ BaseProvider = (*DailyProvider)(nil)
- Purpose: This is a compile-time check to ensure that
DailyProvider
implements theBaseProvider
interface.
func (dp *DailyProvider) GetBaseSeasonalProvider() *BaseSeasonalProvider
- Purpose: Returns a pointer to the embedded
BaseSeasonalProvider
. - Parameters: None
- Returns:
*BaseSeasonalProvider
: A pointer to theBaseSeasonalProvider
instance.
func (dp *DailyProvider) GetBaseSeasonalProvider() *BaseSeasonalProvider {
return &dp.BaseSeasonalProvider
}
func NewDailyProvider(opts ...GenericProviderOption[*DailyProvider]) *DailyProvider
- Purpose: Creates a new
DailyProvider
instance. It accepts functional options to configure the provider. - Parameters:
opts ...GenericProviderOption[*DailyProvider]
: A variadic list of functional options to configure theDailyProvider
.
- Returns:
*DailyProvider
: A pointer to the newly createdDailyProvider
instance.
func NewDailyProvider(opts ...GenericProviderOption[*DailyProvider]) *DailyProvider {
dp := &DailyProvider{
BaseSeasonalProvider: BaseSeasonalProvider{},
}
for _, opt := range opts {
opt(dp)
}
dp.querierV2 = querierV2.NewQuerier(querierV2.QuerierOptions{
Reader: dp.reader,
Cache: dp.cache,
KeyGenerator: queryBuilder.NewKeyGenerator(),
FluxInterval: dp.fluxInterval,
FeatureLookup: dp.ff,
})
return dp
}
func (p *DailyProvider) GetAnomalies(ctx context.Context, req *GetAnomaliesRequest) (*GetAnomaliesResponse, error)
- Purpose: Retrieves anomalies based on the provided request. It sets the seasonality to
SeasonalityDaily
before calling the basegetAnomalies
method. - Parameters:
ctx context.Context
: The context for the request.req *GetAnomaliesRequest
: The request object containing anomaly detection parameters.
- Returns:
*GetAnomaliesResponse
: The response containing the detected anomalies.error
: An error, if any occurred.
func (p *DailyProvider) GetAnomalies(ctx context.Context, req *GetAnomaliesRequest) (*GetAnomaliesResponse, error) {
req.Seasonality = SeasonalityDaily
return p.getAnomalies(ctx, req)
}
Include in Getting Started: NO