Documentation
¶
Overview ¶
Package db pkg/db/interfaces.go
Package db is a generated GoMock package.
Index ¶
- Variables
- func NewCNPGPool(ctx context.Context, cfg *models.CNPGDatabase, log logger.Logger) (*pgxpool.Pool, error)
- type DB
- func (db *DB) Close() error
- func (db *DB) InsertOCSFEvents(ctx context.Context, table string, rows []models.OCSFEventRow) error
- func (db *DB) InsertOCSFNetworkActivity(ctx context.Context, table string, rows []models.OCSFNetworkActivity) error
- func (db *DB) InsertOTELLogs(ctx context.Context, table string, rows []models.OTELLogRow) error
- func (db *DB) InsertOTELMetrics(ctx context.Context, table string, rows []models.OTELMetricRow) error
- func (db *DB) InsertOTELTraces(ctx context.Context, table string, rows []models.OTELTraceRow) error
- func (db *DB) StoreNetflowMetrics(ctx context.Context, metrics []*models.NetflowMetric) error
- func (db *DB) UseCNPGReads() bool
- func (db *DB) UseCNPGWrites() bool
- func (db *DB) WithTx(ctx context.Context, fn func(tx Service) error) error
- type MockService
- type MockServiceMockRecorder
- type PgxExecutor
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( ErrDatabaseNotInitialized = errors.New("database connection not initialized") ErrUnknownExecutorType = errors.New("unknown executor type") )
Static errors for err113 compliance
var ( // Core database errors. ErrFailedOpenDB = errors.New("failed to open database") // Netflow validation errors. ErrNetflowMetricNil = errors.New("netflow metric is nil") // CNPG configuration helpers. ErrCNPGConfigMissing = errors.New("cnpg: missing configuration") ErrCNPGLackingTLSFiles = errors.New("cnpg tls requires cert_file, key_file, and ca_file") ErrCNPGTLSDisabled = errors.New("cnpg tls configuration requires sslmode not be disable") )
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents the CNPG-backed database connection.
func (*DB) InsertOCSFEvents ¶ added in v1.0.79
InsertOCSFEvents persists OCSF event rows into the configured CNPG table.
func (*DB) InsertOCSFNetworkActivity ¶ added in v1.0.90
func (db *DB) InsertOCSFNetworkActivity(ctx context.Context, table string, rows []models.OCSFNetworkActivity) error
InsertOCSFNetworkActivity persists OCSF network activity rows into the configured CNPG table.
func (*DB) InsertOTELLogs ¶ added in v1.0.55
InsertOTELLogs persists OTEL log rows into the configured CNPG table.
func (*DB) InsertOTELMetrics ¶ added in v1.0.55
func (db *DB) InsertOTELMetrics(ctx context.Context, table string, rows []models.OTELMetricRow) error
InsertOTELMetrics persists OTEL metric rows into the configured CNPG table.
func (*DB) InsertOTELTraces ¶ added in v1.0.55
InsertOTELTraces persists OTEL trace rows into the configured CNPG table.
func (*DB) StoreNetflowMetrics ¶
StoreNetflowMetrics stores multiple NetFlow metrics in CNPG.
func (*DB) UseCNPGReads ¶ added in v1.0.55
func (*DB) UseCNPGWrites ¶ added in v1.0.55
type MockService ¶
type MockService struct {
// contains filtered or unexported fields
}
MockService is a mock of Service interface.
func NewMockService ¶
func NewMockService(ctrl *gomock.Controller) *MockService
NewMockService creates a new mock instance.
func (*MockService) EXPECT ¶
func (m *MockService) EXPECT() *MockServiceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockService) StoreNetflowMetrics ¶
func (m *MockService) StoreNetflowMetrics(ctx context.Context, metrics []*models.NetflowMetric) error
StoreNetflowMetrics mocks base method.
type MockServiceMockRecorder ¶
type MockServiceMockRecorder struct {
// contains filtered or unexported fields
}
MockServiceMockRecorder is the mock recorder for MockService.
func (*MockServiceMockRecorder) Close ¶
func (mr *MockServiceMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockServiceMockRecorder) StoreNetflowMetrics ¶
func (mr *MockServiceMockRecorder) StoreNetflowMetrics(ctx, metrics any) *gomock.Call
StoreNetflowMetrics indicates an expected call of StoreNetflowMetrics.
type PgxExecutor ¶ added in v1.0.65
type PgxExecutor interface {
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
}
PgxExecutor is an interface satisfied by both *pgxpool.Pool and pgx.Tx