dbManager

package
v0.0.0-...-33e56a9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbParameter

type DbParameter struct {
	Cache *cacheManager.CacheManager

	Db      *gorm.DB
	Metrics map[string]*prometheus.GaugeVec
	Pipe    chan interface{}
	// contains filtered or unexported fields
}

DbParameter is the struct defined to group and contain all the methods that interact with the database. On it there is the following parameters: - Cache: CacheManager pointer for the cache mechanism. - connStr: strings with the connection information to the database. - Db: a gorm.DB pointer to the db to invoke all the db methods.

func New

func New(dbConn string, tables ...interface{}) *DbParameter

New is the function to create the struct DbParameter. Parameters: - dbConn: strings with the connection information to the database. - tables: array of interfaces that will contains the models to migrate to the database on initialization. Returns: - DbParameter: struct to interact with dbManager functionalities.

func (*DbParameter) AddRecord

func (d *DbParameter) AddRecord(cdr models.CReport) (e error)

AddRecord job is to save in the system the provided CDR report to be easy to retrieve later with the usage endpoints. Parameters: - cdr: the CDR report model to be added to the system. Returns: - e: error in case of duplication or failure in the task.

func (*DbParameter) GetReport

func (d *DbParameter) GetReport(id string, metric string, from strfmt.DateTime, to strfmt.DateTime) []*models.CDRReport

GetReport job is to retrieve the compacted usage records from the system for the provided account in the requested time-window with the posibility of filter by metric. Parameters: - id: string containing the id of the account requested. - metric: a string with the metric to filter the records. - from: a datatime reference for the initial border of the time-window. - to: a datatime reference for the final border of the time-window. Returns: - a slice of references with the usage contained in the system within the requested time-window.

func (*DbParameter) GetUsage

func (d *DbParameter) GetUsage(id, metric string, from, to strfmt.DateTime) ([]*models.CReport, error)

GetUsage job is to retrieve the usage report of the system or the specified account within the requested time-window with the posibility to filter by metric. Parameters: - id: string containing the id of the account requested. - metric: a string with the metric to filter the records. - from: a datatime reference for the initial border of the time-window. - to: a datatime reference for the final border of the time-window. Returns: - a slice of references with the usage report contained in the system within the requested time-window. - error in case of duplication or failure in the task.

func (*DbParameter) GetUsageSummary

func (d *DbParameter) GetUsageSummary(id string, from, to strfmt.DateTime) (*models.UISummary, error)

GetUsageSummary job is to retrieve the usage report of the system of the specified account within the requested time-window and process it into an easy to use estructure for the UI. Parameters: - id: string containing the id of the account requested. - from: a datatime reference for the initial border of the time-window. - to: a datatime reference for the final border of the time-window. Returns: - a references with the usage report contained in the system within the requested time-window. - error in case of duplication or failure in the task.

func (*DbParameter) GetUsages

func (d *DbParameter) GetUsages(ids, metric string, from, to strfmt.DateTime) ([]*models.CReport, error)

GetUsages job is to retrieve the usage report of the system or the specified account accounts within the requested time-window with the posibility to filter by metric. Parameters: - ids: string containing the list of ids of the accounts requested. - metric: a string with the metric to filter the records. - from: a datatime reference for the initial border of the time-window. - to: a datatime reference for the final border of the time-window. Returns: - a slice of references with the usage report contained in the system within the requested time-window. - error in case of duplication or failure in the task.

func (*DbParameter) ProcessUDR

func (d *DbParameter) ProcessUDR(report udrModels.UReport, token string) (e error)

ProcessUDR job is to process the UDR Reports and turn then into CDR Reports and store them in the system. Parameters: - report: UDR Report model reference to be processed. - token: an optional keycloak token in case it's provided. Returns: - e: error in case of duplication or failure in the task.

Jump to

Keyboard shortcuts

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