Documentation
¶
Index ¶
Constants ¶
const ( // MinimumWindowSizeDuration is the minimum window size the aggregation can represent. MinimumWindowSizeDuration = time.Second // MinimumWindowSize is the minimum window size the aggregation can represent. MinimumWindowSize = meter.WindowSizeSecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface {
namespace.Handler
CountEvents(ctx context.Context, namespace string, params CountEventsParams) ([]CountEventRow, error)
ListEvents(ctx context.Context, namespace string, params ListEventsParams) ([]RawEvent, error)
ListEventsV2(ctx context.Context, params ListEventsV2Params) ([]RawEvent, error)
// ListSubjects lists the subjects that have events in the database
ListSubjects(ctx context.Context, params ListSubjectsParams) ([]string, error)
// ListGroupByValues lists the group by values that have events in the database
ListGroupByValues(ctx context.Context, params ListGroupByValuesParams) ([]string, error)
QueryMeter(ctx context.Context, namespace string, meter meter.Meter, params QueryParams) ([]meter.MeterQueryRow, error)
BatchInsert(ctx context.Context, events []RawEvent) error
ValidateJSONPath(ctx context.Context, jsonPath string) (bool, error)
}
type CountEventRow ¶
CountEventRow represents a row in the count events response.
type CountEventsParams ¶
type Customer ¶
type Customer interface {
GetUsageAttribution() CustomerUsageAttribution
}
Customer is a customer that can be used in a meter query
type CustomerUsageAttribution ¶
type CustomerUsageAttribution struct {
// We don't attribute usage to the customer by ID but we need it to be able to map subjects to customers
ID string `json:"id"`
// We attribute usage to the customer by key
Key *string `json:"key"`
// We attribute usage to the customer by subject keys
SubjectKeys []string `json:"subjectKeys"`
}
CustomerUsageAttribution holds customer fields that map usage to a customer
func NewCustomerUsageAttribution ¶
func NewCustomerUsageAttribution(id string, key *string, subjectKeys []string) CustomerUsageAttribution
NewCustomerUsageAttribution creates a new CustomerUsageAttribution
func (CustomerUsageAttribution) Equal ¶
func (ua CustomerUsageAttribution) Equal(other CustomerUsageAttribution) bool
Equal checks if two CustomerUsageAttributions are equal
func (CustomerUsageAttribution) GetValues ¶
func (ua CustomerUsageAttribution) GetValues() []string
GetValues returns the values by which the usage is attributed to the customer
func (CustomerUsageAttribution) Validate ¶
func (ua CustomerUsageAttribution) Validate() error
Validate validates the CustomerUsageAttribution
type EventSortField ¶
type EventSortField string
EventSortField is the column used to order events returned by ListEventsV2.
const ( EventSortFieldTime EventSortField = "time" EventSortFieldIngestedAt EventSortField = "ingested_at" EventSortFieldStoredAt EventSortField = "stored_at" )
func (EventSortField) Validate ¶
func (f EventSortField) Validate() error
Validate returns an error when the sort field is not one of the known values. The zero value is treated as valid and resolved to EventSortFieldTime at query time.
func (EventSortField) Values ¶
func (f EventSortField) Values() []string
Values returns the known values for the event sort field.
type ListEventsParams ¶
type ListEventsParams struct {
// The namespace.
Namespace string
// The client ID.
ClientID *string
// Start date-time. Inclusive.
IngestedAtFrom *time.Time
// End date-time. Inclusive.
IngestedAtTo *time.Time
// The event ID. Accepts partial ID.
ID *string
// The event subject. Accepts partial subject.
Subject *string
// The event customer ID.
Customers *[]Customer
// Start date-time. Inclusive.
From time.Time
// End date-time. Inclusive.
To *time.Time
// Number of events to return.
Limit int
}
ListEventsParams represents the input for ListEvents method.
func (ListEventsParams) Validate ¶
func (i ListEventsParams) Validate() error
Validate validates the input.
type ListEventsV2Params ¶
type ListEventsV2Params struct {
// The namespace.
Namespace string
// The client ID.
ClientID *string
// The cursor.
Cursor *pagination.Cursor
// The limit.
Limit *int
// The ID filter.
ID *filter.FilterString
// The source filter.
Source *filter.FilterString
// The subject filter.
Subject *filter.FilterString
// The event customer ID.
Customers *[]Customer
// The type filter.
Type *filter.FilterString
// The time filter.
Time *filter.FilterTime
// The ingested at filter.
IngestedAt *filter.FilterTime
// The stored at filter.
StoredAt *filter.FilterTime
// The sort column; zero value defaults to EventSortFieldTime.
SortBy EventSortField
// The sort direction; zero value defaults to sortx.OrderDesc.
SortOrder sortx.Order
}
ListEventsV2Params is a parameter object for listing events.
func (ListEventsV2Params) Validate ¶
func (p ListEventsV2Params) Validate() error
Validate validates the list events parameters.
type ListGroupByValuesParams ¶
type ListGroupByValuesParams struct {
Namespace string
Meter meter.Meter
GroupByKey string
From *time.Time
To *time.Time
Search *string
}
ListGroupByValuesParams is a parameter object for listing group by values.
func (ListGroupByValuesParams) Validate ¶
func (p ListGroupByValuesParams) Validate() error
Validate validates the list group by values parameters.
type ListSubjectsParams ¶
type ListSubjectsParams struct {
Namespace string
Meter *meter.Meter
From *time.Time
To *time.Time
Search *string
}
ListSubjectsParams is a parameter object for listing subjects.
func (ListSubjectsParams) Validate ¶
func (p ListSubjectsParams) Validate() error
Validate validates the list meters parameters.
type QueryParams ¶
type QueryParams struct {
ClientID *string
From *time.Time
To *time.Time
FilterCustomer []Customer
FilterSubject []string
FilterGroupBy map[string]filter.FilterString
FilterStoredAt *filter.FilterTimeUnix
GroupBy []string
WindowSize *meter.WindowSize
WindowTimeZone *time.Location
}
func (*QueryParams) Validate ¶
func (p *QueryParams) Validate() error
Validate validates query params focusing on `from` and `to` being aligned with query and meter window sizes
type RawEvent ¶
type RawEvent struct {
Namespace string `ch:"namespace" json:"-"`
ID string `ch:"id" json:"id"`
Type string `ch:"type" json:"type"`
Source string `ch:"source" json:"source"`
Subject string `ch:"subject" json:"subject"`
Time time.Time `ch:"time" json:"time"`
Data string `ch:"data" json:"data"`
IngestedAt time.Time `ch:"ingested_at" json:"ingested_at,omitempty,omitzero"`
StoredAt time.Time `ch:"stored_at" json:"stored_at,omitempty,omitzero"`
StoreRowID string `ch:"store_row_id" json:"store_row_id,omitempty,omitzero"`
CustomerID *string `ch:"customer_id" json:"customer_id,omitempty,omitzero"`
}
RawEvent represents a single raw event