clickhouse_multi

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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) FindEndsByMSISDN

func (q *DBQuerier) FindEndsByMSISDN(ctx context.Context, msisdnA string) ([]FindEndsByMSISDNRow, error)

FindEndsByMSISDN implements Querier.FindEndsByMSISDN.

func (*DBQuerier) SumBusySubscribers

func (q *DBQuerier) SumBusySubscribers(ctx context.Context, minUnits int64) ([]UsageRow, error)

SumBusySubscribers implements Querier.SumBusySubscribers.

func (*DBQuerier) SumByMSISDN

func (q *DBQuerier) SumByMSISDN(ctx context.Context, msisdnA string) ([]UsageRow, error)

SumByMSISDN implements Querier.SumByMSISDN.

func (*DBQuerier) SumByProvider

func (q *DBQuerier) SumByProvider(ctx context.Context, provider string) ([]UsageRow, error)

SumByProvider implements Querier.SumByProvider.

type FindEndsByMSISDNRow

type FindEndsByMSISDNRow struct {
	EndedAt *time.Time          `ch:"ended_at" json:"ended_at"`
	TagSets []map[string]string `ch:"tag_sets" json:"tag_sets"`
}

type Querier

type Querier interface {
	// Sums usage per subscriber for one provider.
	SumByProvider(ctx context.Context, provider string) ([]UsageRow, error)

	// The same shape over a different filter, so the two share one Go struct.
	SumBusySubscribers(ctx context.Context, minUnits int64) ([]UsageRow, error)

	// Sums usage for one subscriber, sharing UsageRow across files.
	SumByMSISDN(ctx context.Context, msisdnA string) ([]UsageRow, error)

	// Returns the two columns whose Go types are built out of wrappers. A pointer
	// reports no import of its own and a map reports none either — its key and
	// value can come from different packages — so this file needs "time" from
	// inside a *time.Time and nothing else brings it in.
	FindEndsByMSISDN(ctx context.Context, msisdnA string) ([]FindEndsByMSISDNRow, error)
}

Querier is a typesafe Go interface backed by SQL queries.

type RecordType

type RecordType struct {
	Label string
}

RecordType is what --go-type maps the enum column to, in place of the string chgen would pick on its own.

It implements sql.Scanner because clickhouse-go decodes into the Go type the column maps to natively, or into a sql.Scanner — and into nothing else. A plain named type like `type RecordType string` compiles and then fails at run time with "converting Enum8 to *RecordType is unsupported", so an override that is only a rename does not work here.

func (*RecordType) Scan

func (r *RecordType) Scan(src any) error

func (RecordType) String

func (r RecordType) String() string

type UsageRow

type UsageRow struct {
	MSISDNA    string     `ch:"msisdn_a"    json:"msisdn_a"`
	RecordType RecordType `ch:"record_type" json:"record_type"`
	Units      int64      `ch:"units"       json:"units"`
}

Jump to

Keyboard shortcuts

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