Documentation
¶
Index ¶
- type ChargeRow
- type DBQuerier
- func (q *DBQuerier) FindCDRsByProvider(ctx context.Context, provider string) ([]FindCDRsByProviderRow, error)
- func (q *DBQuerier) FindChargesByLabel(ctx context.Context, label string) ([]ChargeRow, error)
- func (q *DBQuerier) FindChargesByProvider(ctx context.Context, provider string) ([]ChargeRow, error)
- func (q *DBQuerier) FindDataUsage(ctx context.Context, params FindDataUsageParams) ([]FindDataUsageRow, error)
- func (q *DBQuerier) FindOldestStart(ctx context.Context, provider string) (time.Time, error)
- func (q *DBQuerier) InsertCDR(ctx context.Context, params InsertCDRParams) error
- func (q *DBQuerier) ListCDRsPaged(ctx context.Context, params ListCDRsPagedParams) ([]ListCDRsPagedRow, error)
- func (q *DBQuerier) ListProviders(ctx context.Context) ([]string, error)
- type FindCDRsByProviderRow
- type FindDataUsageParams
- type FindDataUsageRow
- type InsertCDRParams
- type ListCDRsPagedParams
- type ListCDRsPagedRow
- type Querier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBQuerier ¶
type DBQuerier struct {
// contains filtered or unexported fields
}
func NewQuerier ¶
func NewQuerier(conn genericConn) *DBQuerier
NewQuerier creates a DBQuerier that implements Querier. conn is typically a clickhouse.Conn.
func (*DBQuerier) FindCDRsByProvider ¶
func (q *DBQuerier) FindCDRsByProvider(ctx context.Context, provider string) ([]FindCDRsByProviderRow, error)
FindCDRsByProvider implements Querier.FindCDRsByProvider.
func (*DBQuerier) FindChargesByLabel ¶
FindChargesByLabel implements Querier.FindChargesByLabel.
func (*DBQuerier) FindChargesByProvider ¶
func (q *DBQuerier) FindChargesByProvider(ctx context.Context, provider string) ([]ChargeRow, error)
FindChargesByProvider implements Querier.FindChargesByProvider.
func (*DBQuerier) FindDataUsage ¶
func (q *DBQuerier) FindDataUsage(ctx context.Context, params FindDataUsageParams) ([]FindDataUsageRow, error)
FindDataUsage implements Querier.FindDataUsage.
func (*DBQuerier) FindOldestStart ¶
FindOldestStart implements Querier.FindOldestStart.
func (*DBQuerier) InsertCDR ¶
func (q *DBQuerier) InsertCDR(ctx context.Context, params InsertCDRParams) error
InsertCDR implements Querier.InsertCDR.
func (*DBQuerier) ListCDRsPaged ¶
func (q *DBQuerier) ListCDRsPaged(ctx context.Context, params ListCDRsPagedParams) ([]ListCDRsPagedRow, error)
ListCDRsPaged implements Querier.ListCDRsPaged.
type FindCDRsByProviderRow ¶
type FindCDRsByProviderRow struct {
ANum string `ch:"a_num" json:"a_num"`
RecordType string `ch:"record_type" json:"record_type"`
Rat *string `ch:"rat" json:"rat"`
Provider string `ch:"provider" json:"provider"`
Units int64 `ch:"units" json:"units"`
Charge decimal.Decimal `ch:"charge" json:"charge"`
StartDate time.Time `ch:"start_date" json:"start_date"`
EndDate *time.Time `ch:"end_date" json:"end_date"`
UpdatedAt time.Time `ch:"updated_at" json:"updated_at"`
Labels []string `ch:"labels" json:"labels"`
Metadata map[string]string `ch:"metadata" json:"metadata"`
SubscriptionID uuid.UUID `ch:"subscription_id" json:"subscription_id"`
CustomerID *uuid.UUID `ch:"customer_id" json:"customer_id"`
Premium bool `ch:"premium" json:"premium"`
}
type FindDataUsageParams ¶
type FindDataUsageRow ¶
type InsertCDRParams ¶
type InsertCDRParams struct {
ANum string `json:"a_num"`
RecordType string `json:"record_type"`
Rat *string `json:"rat"`
Provider string `json:"provider"`
Units int64 `json:"units"`
Charge decimal.Decimal `json:"charge"`
StartDate time.Time `json:"start_date"`
EndDate *time.Time `json:"end_date"`
UpdatedAt time.Time `json:"updated_at"`
Labels []string `json:"labels"`
Metadata map[string]string `json:"metadata"`
SubscriptionID uuid.UUID `json:"subscription_id"`
CustomerID *uuid.UUID `json:"customer_id"`
Premium bool `json:"premium"`
}
type ListCDRsPagedParams ¶
type ListCDRsPagedRow ¶
type Querier ¶
type Querier interface {
// Sums data usage per subscriber over a time window. Inputs use ClickHouse's
// own parameter syntax, so this file also runs as-is in clickhouse-client.
FindDataUsage(ctx context.Context, params FindDataUsageParams) ([]FindDataUsageRow, error)
// Returns every column, so the generated row struct covers the whole type
// vocabulary.
FindCDRsByProvider(ctx context.Context, provider string) ([]FindCDRsByProviderRow, error)
// A single row.
FindOldestStart(ctx context.Context, provider string) (time.Time, error)
// A single column over many rows, which cannot use struct scanning.
ListProviders(ctx context.Context) ([]string, error)
InsertCDR(ctx context.Context, params InsertCDRParams) error
// Two queries share one row struct through output=. The struct is declared
// once, and chgen checks the two agree on every column before sharing it.
FindChargesByProvider(ctx context.Context, provider string) ([]ChargeRow, error)
// The same shape over a different filter. end_date is Nullable here too, so
// the shared struct keeps the pointer.
FindChargesByLabel(ctx context.Context, label string) ([]ChargeRow, error)
// A parameter named after a ClickHouse setting. Inference sends parameters as
// settings, so it has to rename them to describe the query; see
// ch.RenameParams.
ListCDRsPaged(ctx context.Context, params ListCDRsPagedParams) ([]ListCDRsPagedRow, error)
}
Querier is a typesafe Go interface backed by SQL queries.
Click to show internal directories.
Click to hide internal directories.