Documentation
¶
Index ¶
- Constants
- type AppDb
- func (adb *AppDb) Close() error
- func (adb *AppDb) Conn() *DbConnection
- func (adb *AppDb) Connect() (err error)
- func (adb *AppDb) EnsureTablesExist() (err error)
- func (adb *AppDb) Init(name string, tables DbTables)
- func (adb *AppDb) Name() string
- func (adb *AppDb) Ping() error
- func (adb *AppDb) Setup(dbcfg *config.DBConfig) error
- func (adb *AppDb) String() string
- type ClientsRow
- func (c *ClientsRow) ClientIdExists() bool
- func (c *ClientsRow) Delete() (err error)
- func (c *ClientsRow) Exists() bool
- func (c *ClientsRow) GetClientRegistration() *types.ClientRegistration
- func (c *ClientsRow) InitAuthentication(caReq *restapi.ClientAuthenticationRequest)
- func (c *ClientsRow) InitClientId(crReq *restapi.ClientRegistrationRequest)
- func (c *ClientsRow) InitClientRegistration(reg *types.ClientRegistration)
- func (c *ClientsRow) InitRegistration(crReq *restapi.ClientRegistrationRequest)
- func (c *ClientsRow) InitRegistrationId(registrationId int64)
- func (c *ClientsRow) Insert() (err error)
- func (c *ClientsRow) RegistrationExists() bool
- func (c *ClientsRow) RowId() int64
- func (c *ClientsRow) SetupDB(adb *AppDb) (err error)
- func (c *ClientsRow) String() string
- func (c *ClientsRow) TableName() string
- func (c *ClientsRow) Update() (err error)
- type CustomersRow
- func (r *CustomersRow) Delete() (err error)
- func (r *CustomersRow) Exists() bool
- func (r *CustomersRow) IdExists() bool
- func (r *CustomersRow) Init(customerId string)
- func (r *CustomersRow) Insert() (err error)
- func (r *CustomersRow) RowId() int64
- func (r *CustomersRow) SetupDB(adb *AppDb) (err error)
- func (r *CustomersRow) String() string
- func (r *CustomersRow) TableName() string
- func (r *CustomersRow) Update() (err error)
- type DbConnection
- func (d *DbConnection) AcquireAdvisoryLock(lockId int64, tx *sql.Tx, shared bool) (err error)
- func (d *DbConnection) AcquireAdvisoryLockPostgres(lockId int64, tx *sql.Tx, shared bool) (err error)
- func (d *DbConnection) CheckTableExists(table *TableSpec) (bool, error)
- func (d DbConnection) Close() (err error)
- func (d *DbConnection) Connect() (err error)
- func (d *DbConnection) CreateTableFromSpec(table *TableSpec) (err error)
- func (d *DbConnection) DB() *sql.DB
- func (d DbConnection) DbMgr() dbmanager.DbManager
- func (d *DbConnection) EnsureTableSpecsExist(tables []*TableSpec) (err error)
- func (d DbConnection) Name() string
- func (d *DbConnection) Ping() (err error)
- func (d *DbConnection) ReleaseAdvisdoryLock(lockId int64, tx *sql.Tx, shared bool) (err error)
- func (d *DbConnection) ReleaseAdvisoryLockPostgres(lockId int64, tx *sql.Tx, shared bool) (err error)
- func (d *DbConnection) Setup(name string, dbcfg *config.DBConfig) error
- func (d DbConnection) String() string
- type DbTables
- type ReportStagingTableRow
- func (r *ReportStagingTableRow) Delete() (err error)
- func (r *ReportStagingTableRow) Exists() bool
- func (r *ReportStagingTableRow) FirstUnallocated() bool
- func (r *ReportStagingTableRow) Init(clientId, reportId string, data any)
- func (r *ReportStagingTableRow) Insert() (stagingId int64, err error)
- func (r *ReportStagingTableRow) ReportIdentifer() string
- func (r *ReportStagingTableRow) SetupDB(adb *AppDb) error
- type SelectOpts
- type TableRowCommon
- func (t *TableRowCommon) ColumnName(ind int) string
- func (t *TableRowCommon) Columns(inputColumns ...string) (columns []string, err error)
- func (t *TableRowCommon) DB() *sql.DB
- func (t *TableRowCommon) DeleteStmt(whereCols []string) (stmt string, err error)
- func (t *TableRowCommon) GetTableSpec() *TableSpec
- func (t *TableRowCommon) InsertStmt(insertCols []string, returning string) (stmt string, err error)
- func (t *TableRowCommon) SelectStmt(selectCols, whereCols []string, opts SelectOpts) (stmt string, err error)
- func (t *TableRowCommon) SetTableSpec(ts *TableSpec)
- func (t *TableRowCommon) SetupDB(adb *AppDb) (err error)
- func (t *TableRowCommon) TableName() string
- func (t *TableRowCommon) UpdateStmt(updateCols, whereCols []string) (stmt string, err error)
- type TableRowHandler
- type TableSpec
- type TableSpecColumn
- type TableSpecForeignKey
- type TagSetRow
- func (t *TagSetRow) Delete() (err error)
- func (t *TagSetRow) Exists() bool
- func (t *TagSetRow) Init(tagSet string)
- func (t *TagSetRow) Insert() (err error)
- func (t *TagSetRow) RowId() int64
- func (t *TagSetRow) SetupDB(adb *AppDb) error
- func (t *TagSetRow) String() string
- func (t *TagSetRow) Update() (err error)
- type TelemetryDataRow
- func (t *TelemetryDataRow) Delete() (err error)
- func (t *TelemetryDataRow) Exists() bool
- func (t *TelemetryDataRow) Init(dItm *telemetrylib.TelemetryDataItem, bHdr *telemetrylib.TelemetryBundleHeader, ...) (err error)
- func (t *TelemetryDataRow) Insert() (err error)
- func (t *TelemetryDataRow) RowId() int64
- func (t *TelemetryDataRow) SetupDB(adb *AppDb) (err error)
- func (t *TelemetryDataRow) String() string
- func (t *TelemetryDataRow) TableName() string
- func (t *TelemetryDataRow) Update() (err error)
- type TelemetryDataRowHandler
Constants ¶
View Source
const (
CREATE_TABLE_ADVISORY = 3141592653589793
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppDb ¶
type AppDb struct {
// contains filtered or unexported fields
}
func (*AppDb) Conn ¶
func (adb *AppDb) Conn() *DbConnection
func (*AppDb) EnsureTablesExist ¶
type ClientsRow ¶
type ClientsRow struct {
// include common table row fields
TableRowCommon
Id int64 `json:"id"`
ClientId string `json:"clientId"`
SystemUUID string `json:"systemUUID"`
ClientTimestamp string `json:"clientTimestamp"`
RegistrationDate string `json:"registrationDate"`
AuthToken string `json:"authToken"`
}
func (*ClientsRow) ClientIdExists ¶
func (c *ClientsRow) ClientIdExists() bool
func (*ClientsRow) Delete ¶
func (c *ClientsRow) Delete() (err error)
func (*ClientsRow) Exists ¶
func (c *ClientsRow) Exists() bool
func (*ClientsRow) GetClientRegistration ¶
func (c *ClientsRow) GetClientRegistration() *types.ClientRegistration
func (*ClientsRow) InitAuthentication ¶
func (c *ClientsRow) InitAuthentication(caReq *restapi.ClientAuthenticationRequest)
func (*ClientsRow) InitClientId ¶
func (c *ClientsRow) InitClientId(crReq *restapi.ClientRegistrationRequest)
func (*ClientsRow) InitClientRegistration ¶
func (c *ClientsRow) InitClientRegistration(reg *types.ClientRegistration)
func (*ClientsRow) InitRegistration ¶
func (c *ClientsRow) InitRegistration(crReq *restapi.ClientRegistrationRequest)
func (*ClientsRow) InitRegistrationId ¶
func (c *ClientsRow) InitRegistrationId(registrationId int64)
func (*ClientsRow) Insert ¶
func (c *ClientsRow) Insert() (err error)
func (*ClientsRow) RegistrationExists ¶
func (c *ClientsRow) RegistrationExists() bool
func (*ClientsRow) RowId ¶
func (c *ClientsRow) RowId() int64
func (*ClientsRow) SetupDB ¶
func (c *ClientsRow) SetupDB(adb *AppDb) (err error)
func (*ClientsRow) String ¶
func (c *ClientsRow) String() string
func (*ClientsRow) TableName ¶
func (c *ClientsRow) TableName() string
func (*ClientsRow) Update ¶
func (c *ClientsRow) Update() (err error)
type CustomersRow ¶
type CustomersRow struct {
// include common table row fields
TableRowCommon
Id int64 `json:"id"`
CustomerId string `json:"customerId"`
Deleted bool `json:"deleted"`
DeletedAt string `json:"deletedAt"`
}
func (*CustomersRow) Delete ¶
func (r *CustomersRow) Delete() (err error)
func (*CustomersRow) Exists ¶
func (r *CustomersRow) Exists() bool
func (*CustomersRow) IdExists ¶
func (r *CustomersRow) IdExists() bool
func (*CustomersRow) Init ¶
func (r *CustomersRow) Init(customerId string)
func (*CustomersRow) Insert ¶
func (r *CustomersRow) Insert() (err error)
func (*CustomersRow) RowId ¶
func (r *CustomersRow) RowId() int64
func (*CustomersRow) SetupDB ¶
func (r *CustomersRow) SetupDB(adb *AppDb) (err error)
func (*CustomersRow) String ¶
func (r *CustomersRow) String() string
func (*CustomersRow) TableName ¶
func (r *CustomersRow) TableName() string
func (*CustomersRow) Update ¶
func (r *CustomersRow) Update() (err error)
type DbConnection ¶
type DbConnection struct {
Placeholder dialect.PlaceholderGenerator
// contains filtered or unexported fields
}
DbConnection is a struct tracking a DB connection and associated DB settings
func (*DbConnection) AcquireAdvisoryLock ¶
func (*DbConnection) AcquireAdvisoryLockPostgres ¶
func (*DbConnection) CheckTableExists ¶
func (d *DbConnection) CheckTableExists(table *TableSpec) (bool, error)
func (DbConnection) Close ¶
func (d DbConnection) Close() (err error)
func (*DbConnection) Connect ¶
func (d *DbConnection) Connect() (err error)
func (*DbConnection) CreateTableFromSpec ¶
func (d *DbConnection) CreateTableFromSpec(table *TableSpec) (err error)
func (*DbConnection) DB ¶
func (d *DbConnection) DB() *sql.DB
func (DbConnection) DbMgr ¶
func (d DbConnection) DbMgr() dbmanager.DbManager
func (*DbConnection) EnsureTableSpecsExist ¶
func (d *DbConnection) EnsureTableSpecsExist(tables []*TableSpec) (err error)
func (DbConnection) Name ¶
func (d DbConnection) Name() string
func (*DbConnection) Ping ¶
func (d *DbConnection) Ping() (err error)
func (*DbConnection) ReleaseAdvisdoryLock ¶
func (*DbConnection) ReleaseAdvisoryLockPostgres ¶
func (*DbConnection) Setup ¶
func (d *DbConnection) Setup(name string, dbcfg *config.DBConfig) error
func (DbConnection) String ¶
func (d DbConnection) String() string
type ReportStagingTableRow ¶
type ReportStagingTableRow struct {
TableRowCommon
Id int64 `json:"id"`
ClientId string `json:"clientId"`
ReportId string `json:"reportId"`
Data any `json:"data"`
ReceivedAt string `json:"receivedAt"`
Allocated bool `json:"allocated"`
AllocatedAt string `json:"allocatedAt"`
}
func (*ReportStagingTableRow) Delete ¶
func (r *ReportStagingTableRow) Delete() (err error)
func (*ReportStagingTableRow) Exists ¶
func (r *ReportStagingTableRow) Exists() bool
func (*ReportStagingTableRow) FirstUnallocated ¶
func (r *ReportStagingTableRow) FirstUnallocated() bool
func (*ReportStagingTableRow) Init ¶
func (r *ReportStagingTableRow) Init(clientId, reportId string, data any)
func (*ReportStagingTableRow) Insert ¶
func (r *ReportStagingTableRow) Insert() (stagingId int64, err error)
func (*ReportStagingTableRow) ReportIdentifer ¶
func (r *ReportStagingTableRow) ReportIdentifer() string
func (*ReportStagingTableRow) SetupDB ¶
func (r *ReportStagingTableRow) SetupDB(adb *AppDb) error
type SelectOpts ¶
type TableRowCommon ¶
type TableRowCommon struct {
// contains filtered or unexported fields
}
func (*TableRowCommon) ColumnName ¶
func (t *TableRowCommon) ColumnName(ind int) string
func (*TableRowCommon) Columns ¶
func (t *TableRowCommon) Columns(inputColumns ...string) (columns []string, err error)
func (*TableRowCommon) DB ¶
func (t *TableRowCommon) DB() *sql.DB
func (*TableRowCommon) DeleteStmt ¶
func (t *TableRowCommon) DeleteStmt(whereCols []string) (stmt string, err error)
func (*TableRowCommon) GetTableSpec ¶
func (t *TableRowCommon) GetTableSpec() *TableSpec
func (*TableRowCommon) InsertStmt ¶
func (t *TableRowCommon) InsertStmt(insertCols []string, returning string) (stmt string, err error)
func (*TableRowCommon) SelectStmt ¶
func (t *TableRowCommon) SelectStmt(selectCols, whereCols []string, opts SelectOpts) (stmt string, err error)
func (*TableRowCommon) SetTableSpec ¶
func (t *TableRowCommon) SetTableSpec(ts *TableSpec)
func (*TableRowCommon) SetupDB ¶
func (t *TableRowCommon) SetupDB(adb *AppDb) (err error)
func (*TableRowCommon) TableName ¶
func (t *TableRowCommon) TableName() string
func (*TableRowCommon) UpdateStmt ¶
func (t *TableRowCommon) UpdateStmt(updateCols, whereCols []string) (stmt string, err error)
type TableRowHandler ¶
type TableRowHandler interface {
// Set the associated TableSpec
SetTableSpec(ts *TableSpec)
// Get the associated TableSpec
GetTableSpec() *TableSpec
// Setup DB access
SetupDB(*AppDb) error
// Retrieve the TableName
TableName() string
// Retrieve the RowId
RowId() int64
// Return string representation of the row
String() string
// Check if the row exists in the DB, and if so populate it
Exists() bool
// Insert row into the table
Insert() error
// Update row in the table
Update() error
// Delete row from the table
Delete() error
}
type TableSpec ¶
type TableSpec struct {
Name string
Columns []TableSpecColumn
ForeignKeys []TableSpecForeignKey
Extras []string
}
func GetClientsTableSpec ¶
func GetClientsTableSpec() *TableSpec
func GetCustomersTableSpec ¶
func GetCustomersTableSpec() *TableSpec
func GetReportsStagingTableSpec ¶
func GetReportsStagingTableSpec() *TableSpec
func GetTagSetsTableSpec ¶
func GetTagSetsTableSpec() *TableSpec
func GetTelemetryTableSpec ¶
func GetTelemetryTableSpec() *TableSpec
func (*TableSpec) CheckColumnNames ¶
type TableSpecColumn ¶
type TableSpecColumn struct {
Name string
Type string
Nullable bool
Default string
PrimaryKey bool
Identity bool
Unique bool
}
func (*TableSpecColumn) Create ¶
func (c *TableSpecColumn) Create(db *DbConnection) string
type TableSpecForeignKey ¶
type TableSpecForeignKey struct {
Name string
Column string
ReferencedTable string
ReferencedColumn string
}
func (*TableSpecForeignKey) Create ¶
func (fk *TableSpecForeignKey) Create(db *DbConnection) string
type TagSetRow ¶
type TagSetRow struct {
TableRowCommon
Id int64 `json:"id"`
TagSet string `json:"tagSet"`
}
type TelemetryDataRow ¶
type TelemetryDataRow struct {
TableRowCommon
// public table fields
Id int64 `json:"id"`
ClientId string `json:"clientId"`
CustomerRefId int64 `json:"customerRefId"`
TelemetryId string `json:"telemetryId"`
TelemetryType string `json:"telemetryType"`
Timestamp string `json:"timestamp"`
TagSetId int64 `json:"tagSetId"`
DataItem []byte `json:"dataItem"`
}
func (*TelemetryDataRow) Delete ¶
func (t *TelemetryDataRow) Delete() (err error)
func (*TelemetryDataRow) Exists ¶
func (t *TelemetryDataRow) Exists() bool
func (*TelemetryDataRow) Init ¶
func (t *TelemetryDataRow) Init( dItm *telemetrylib.TelemetryDataItem, bHdr *telemetrylib.TelemetryBundleHeader, tagSetId int64, customerRefId int64, ) (err error)
func (*TelemetryDataRow) Insert ¶
func (t *TelemetryDataRow) Insert() (err error)
func (*TelemetryDataRow) RowId ¶
func (t *TelemetryDataRow) RowId() int64
func (*TelemetryDataRow) SetupDB ¶
func (t *TelemetryDataRow) SetupDB(adb *AppDb) (err error)
func (*TelemetryDataRow) String ¶
func (t *TelemetryDataRow) String() string
func (*TelemetryDataRow) TableName ¶
func (t *TelemetryDataRow) TableName() string
func (*TelemetryDataRow) Update ¶
func (t *TelemetryDataRow) Update() (err error)
type TelemetryDataRowHandler ¶
type TelemetryDataRowHandler interface {
// TelemetryDataRow is a superset of TableRow
TableRowHandler
// Initialise the row fields
Init(
dItm *telemetrylib.TelemetryDataItem,
bHdr *telemetrylib.TelemetryBundleHeader,
tagSetId int64,
customerRefId int64,
) error
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.