Documentation
¶
Index ¶
- func IsMeterNotFoundError(err error) bool
- func NewMeterNotFoundError(meterSlug string) error
- func ParseEvent(meter Meter, ev event.Event) (*float64, *string, map[string]string, error)
- type CreateMeterInput
- type DeleteMeterInput
- type GetMeterInput
- type ListMetersParams
- type ManageService
- type Meter
- type MeterAggregation
- type MeterNotFoundError
- type MeterQueryRow
- type PreUpdateMeterHook
- type Service
- type UpdateMeterInput
- type WindowSize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMeterNotFoundError ¶
IsMeterNotFoundError returns true if the error is a MeterNotFoundError.
func NewMeterNotFoundError ¶
NewMeterNotFoundError returns a new MeterNotFoundError.
Types ¶
type CreateMeterInput ¶
type CreateMeterInput struct {
Namespace string
Name string
Key string
Description *string
Aggregation MeterAggregation
EventType string
EventFrom *time.Time
ValueProperty *string
GroupBy map[string]string
}
CreateMeterInput is a parameter object for creating a meter.
func (CreateMeterInput) Validate ¶
func (i CreateMeterInput) Validate() error
Validate validates the create meter input.
type DeleteMeterInput ¶
DeleteMeterInput is a parameter object for deleting a meter.
func (DeleteMeterInput) Validate ¶
func (i DeleteMeterInput) Validate() error
Validate validates the delete meter input.
type GetMeterInput ¶
GetMeterInput is a parameter object for getting a meter.
func (GetMeterInput) Validate ¶
func (i GetMeterInput) Validate() error
Validate validates the get meter input.
type ListMetersParams ¶
type ListMetersParams struct {
pagination.Page
Namespace string
SlugFilter *[]string
// WithoutNamespace is a flag to list meters without a namespace.
// We do this instead of letting the namespace be empty to avoid
// accidental listing of all meters across all namespaces.
WithoutNamespace bool
}
ListMetersParams is a parameter object for listing meters.
func (ListMetersParams) Validate ¶
func (p ListMetersParams) Validate() error
Validate validates the list meters parameters.
type ManageService ¶
type ManageService interface {
Service
CreateMeter(ctx context.Context, input CreateMeterInput) (Meter, error)
UpdateMeter(ctx context.Context, input UpdateMeterInput) (Meter, error)
DeleteMeter(ctx context.Context, input DeleteMeterInput) error
// Observer hooks
// Useful to coordinate with other services
RegisterPreUpdateMeterHook(hook PreUpdateMeterHook) error
}
ManageService is an interface to manage meter service.
type Meter ¶
type Meter struct {
models.ManagedResource `mapstructure:",squash"`
Key string `mapstructure:"slug"`
Aggregation MeterAggregation
EventType string
EventFrom *time.Time
ValueProperty *string
GroupBy map[string]string
// Deprecated, always set to MINUTE
WindowSize WindowSize
}
func ListAll ¶
ListAll returns a list of meters. Helper function for listing all meters. Page param will be ignored.
func ListMetersForAllNamespaces ¶
ListMetersForAllNamespaces returns a list of meters. Helper function for listing all meters across all namespaces.
func (*Meter) SupportsWindowSize ¶
func (m *Meter) SupportsWindowSize(w *WindowSize) error
type MeterAggregation ¶
type MeterAggregation string
const ( MeterAggregationSum MeterAggregation = "SUM" MeterAggregationCount MeterAggregation = "COUNT" MeterAggregationAvg MeterAggregation = "AVG" MeterAggregationMin MeterAggregation = "MIN" MeterAggregationMax MeterAggregation = "MAX" MeterAggregationUniqueCount MeterAggregation = "UNIQUE_COUNT" )
Note: keep values up to date in the meter package
func (MeterAggregation) IsValid ¶
func (MeterAggregation) IsValid(input string) bool
func (MeterAggregation) Values ¶
func (MeterAggregation) Values() (kinds []string)
Values provides list valid values for Enum
type MeterNotFoundError ¶
type MeterNotFoundError struct {
// contains filtered or unexported fields
}
MeterNotFoundError is returned when a meter is not found.
func (*MeterNotFoundError) Error ¶
func (e *MeterNotFoundError) Error() string
Error returns the error message.
func (*MeterNotFoundError) Unwrap ¶
func (e *MeterNotFoundError) Unwrap() error
Unwrap returns the wrapped error.
type MeterQueryRow ¶
type MeterQueryRow struct {
Value float64 `json:"value"`
WindowStart time.Time `json:"windowStart"`
WindowEnd time.Time `json:"windowEnd"`
Subject *string `json:"subject"`
GroupBy map[string]*string `json:"groupBy"`
}
MeterQueryRow returns a single row from the meter dataset.
type PreUpdateMeterHook ¶
type PreUpdateMeterHook = func(context.Context, UpdateMeterInput) error
PreUpdateMeterHook is a hook function to be called before updating a meter.
type Service ¶
type Service interface {
ListMeters(ctx context.Context, params ListMetersParams) (pagination.PagedResponse[Meter], error)
GetMeterByIDOrSlug(ctx context.Context, input GetMeterInput) (Meter, error)
}
Meter is an interface for the meter service.
type UpdateMeterInput ¶
type UpdateMeterInput struct {
ID models.NamespacedID
Name string
Description *string
GroupBy map[string]string
}
UpdateMeterInput is a parameter object for creating a meter.
func (UpdateMeterInput) Validate ¶
func (i UpdateMeterInput) Validate(valueProperty *string) error
Validate validates the create meter input.
type WindowSize ¶
type WindowSize string
const ( WindowSizeMinute WindowSize = "MINUTE" WindowSizeHour WindowSize = "HOUR" WindowSizeDay WindowSize = "DAY" )
Note: keep values up to date in the meter package
func WindowSizeFromDuration ¶
func WindowSizeFromDuration(duration time.Duration) (WindowSize, error)
func (WindowSize) Duration ¶
func (w WindowSize) Duration() time.Duration
Duration returns the duration of the window size BEWARE: a day is NOT 24 hours
func (WindowSize) Values ¶
func (WindowSize) Values() (kinds []string)
Values provides list valid values for Enum