report

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SalesOrderLabel = "sales_order"

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, odoo OdooClient, prom PromQuerier, args ReportArgs, from time.Time, options ...Option) error

Run executes a prometheus query loaded from queries with using the `queryName` and the timestamp. The results of the query are saved in the facts table.

func RunRange

func RunRange(ctx context.Context, odoo OdooClient, prom PromQuerier, args ReportArgs, from time.Time, until time.Time, options ...Option) (int, error)

RunRange executes prometheus queries like Run() until the `until` timestamp is reached or an error occurred. Returns the number of reports run and a possible error.

Types

type OdooClient

type OdooClient interface {
	SendData(ctx context.Context, data []odoo.OdooMeteredBillingRecord) error
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option represents a report option.

func WithProgressReporter

func WithProgressReporter(r func(Progress)) Option

WithProgressReporter allows setting a callback function. The callback receives a progress report when generating multiple reports.

func WithPrometheusQueryTimeout

func WithPrometheusQueryTimeout(tm time.Duration) Option

WithPrometheusQueryTimeout allows setting a timout when querying prometheus.

type Progress

type Progress struct {
	Timestamp time.Time
	Count     int
}

Progress represent the progress when generating multiple reports.

type PromQuerier

type PromQuerier interface {
	Query(ctx context.Context, query string, ts time.Time, opts ...apiv1.Option) (model.Value, apiv1.Warnings, error)
}

type ReportArgs

type ReportArgs struct {
	Query                       string
	InstanceJsonnet             string
	ItemDescriptionJsonnet      string
	ItemGroupDescriptionJsonnet string
	UnitID                      string
	ProductID                   string
	TimerangeSize               time.Duration
	OverrideSalesOrderID        string
}

Jump to

Keyboard shortcuts

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