Documentation
¶
Overview ¶
Package billstat implements the AdGuard DNS billing statistics database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmptyMetrics ¶
type EmptyMetrics struct{}
EmptyMetrics is the implementation of the Metrics interface that does nothing.
func (EmptyMetrics) BufferSizeSet ¶
func (EmptyMetrics) BufferSizeSet(_ context.Context, _ float64)
BufferSizeSet implements the Metrics interface for EmptyMetrics.
func (EmptyMetrics) HandleUploadDuration ¶
func (EmptyMetrics) HandleUploadDuration(_ context.Context, _ float64, _ bool)
HandleUploadDuration implements the Metrics interface for EmptyMetrics.
type EmptyRecorder ¶
type EmptyRecorder struct{}
EmptyRecorder is a billing statistics recorder that does nothing.
type Metrics ¶
type Metrics interface { // BufferSizeSet sets the number of stored records to n. BufferSizeSet(ctx context.Context, n float64) // HandleUploadDuration handles the upload duration of billing statistics. HandleUploadDuration(ctx context.Context, dur float64, isSuccess bool) }
Metrics is an interface that is used for the collection of the billing statistics.
type Record ¶
type Record struct { // Time is the time of the most recent query from the device. Time time.Time // Country is the detected country of the client's IP address, if any. Country geoip.Country // ASN is the detected ASN of the client's IP address, if any. ASN geoip.ASN // Queries is the total number of Queries the device has performed since the // most recent sync. This value is an int32 to be in sync with the business // logic backend which uses this type. Change it if it is changed there. // Queries must not be negative. Queries int32 // Proto is the DNS protocol of the most recent query from the device. Proto agd.Protocol }
Record is a single billing statistics Record.
type Recorder ¶
type Recorder interface { Record( ctx context.Context, id agd.DeviceID, ctry geoip.Country, asn geoip.ASN, start time.Time, proto agd.Protocol, ) }
Recorder is the billing statistics recorder interface.
type Records ¶
Records is a helpful alias for a mapping of devices to their billing statistics records.
type RuntimeRecorder ¶
type RuntimeRecorder struct {
// contains filtered or unexported fields
}
RuntimeRecorder is the runtime billing statistics recorder. The records kept here are not persistent.
func NewRuntimeRecorder ¶
func NewRuntimeRecorder(c *RuntimeRecorderConfig) (r *RuntimeRecorder)
NewRuntimeRecorder creates a new runtime billing statistics database. c must be non-nil.
type RuntimeRecorderConfig ¶
type RuntimeRecorderConfig struct { // Logger is used for logging the operation of the recorder. Logger *slog.Logger // ErrColl is used to collect errors during refreshes. ErrColl errcoll.Interface // Uploader is used to upload the billing statistics records to. Uploader Uploader // Metrics is used for the collection of the billing statistics. Metrics Metrics }
RuntimeRecorderConfig is the configuration structure for a runtime billing statistics recorder. All fields must be non-empty.