services

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package services contains business logic implementations.

Package services contains business logic implementations.

Package services contains business logic implementations.

Package services contains business logic implementations.

Package services contains business logic implementations.

Package services contains business logic implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnterpriseStatementClassifier

type EnterpriseStatementClassifier struct {
	// contains filtered or unexported fields
}

EnterpriseStatementClassifier provides comprehensive SQL statement analysis.

func NewEnterpriseStatementClassifier

func NewEnterpriseStatementClassifier() *EnterpriseStatementClassifier

NewEnterpriseStatementClassifier creates a new enterprise-grade statement classifier.

func NewStatementClassifier

func NewStatementClassifier() *EnterpriseStatementClassifier

NewStatementClassifier creates a new statement classifier (legacy compatibility).

func (*EnterpriseStatementClassifier) AnalyzeStatement

func (esc *EnterpriseStatementClassifier) AnalyzeStatement(sql string) (*StatementInfo, error)

AnalyzeStatement performs comprehensive analysis of a SQL statement.

func (*EnterpriseStatementClassifier) ClassifyStatement

func (esc *EnterpriseStatementClassifier) ClassifyStatement(sql string) StatementType

ClassifyStatement determines the type of a SQL statement (legacy method for compatibility).

func (*EnterpriseStatementClassifier) GetExpectedResponseType

func (esc *EnterpriseStatementClassifier) GetExpectedResponseType(sql string) string

GetExpectedResponseType returns the expected response type for a statement.

func (*EnterpriseStatementClassifier) GetStatementType

func (esc *EnterpriseStatementClassifier) GetStatementType(sql string) StatementType

GetStatementType returns the statement type (alias for ClassifyStatement).

func (*EnterpriseStatementClassifier) IsQueryStatement

func (esc *EnterpriseStatementClassifier) IsQueryStatement(sql string) bool

IsQueryStatement returns true if the statement is a DQL statement that should return a result set.

func (*EnterpriseStatementClassifier) IsUpdateStatement

func (esc *EnterpriseStatementClassifier) IsUpdateStatement(sql string) bool

IsUpdateStatement returns true if the statement is a DDL or DML statement that should return an update count rather than a result set.

func (*EnterpriseStatementClassifier) ValidateStatement

func (esc *EnterpriseStatementClassifier) ValidateStatement(sql string) error

ValidateStatement performs basic SQL statement validation.

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Warn(msg string, keysAndValues ...interface{})
	Error(msg string, keysAndValues ...interface{})
}

Logger defines logging interface.

type MetadataService

type MetadataService interface {
	GetCatalogs(ctx context.Context) ([]models.Catalog, error)
	GetSchemas(ctx context.Context, catalog string, pattern string) ([]models.Schema, error)
	GetTables(ctx context.Context, opts models.GetTablesOptions) ([]models.Table, error)
	GetTableTypes(ctx context.Context) ([]string, error)
	GetColumns(ctx context.Context, table models.TableRef) ([]models.Column, error)
	GetTableSchema(ctx context.Context, table models.TableRef) (*arrow.Schema, error)
	GetPrimaryKeys(ctx context.Context, table models.TableRef) ([]models.Key, error)
	GetImportedKeys(ctx context.Context, table models.TableRef) ([]models.ForeignKey, error)
	GetExportedKeys(ctx context.Context, table models.TableRef) ([]models.ForeignKey, error)
	GetCrossReference(ctx context.Context, ref models.CrossTableRef) ([]models.ForeignKey, error)
	GetTypeInfo(ctx context.Context, dataType *int32) ([]models.XdbcTypeInfo, error)
	GetSQLInfo(ctx context.Context, infoTypes []uint32) ([]models.SQLInfo, error)
}

MetadataService defines metadata operations.

func NewMetadataService

func NewMetadataService(
	repo repositories.MetadataRepository,
	logger Logger,
	metrics MetricsCollector,
) MetadataService

NewMetadataService creates a new metadata service.

type MetricsCollector

type MetricsCollector interface {
	IncrementCounter(name string, labels ...string)
	RecordHistogram(name string, value float64, labels ...string)
	RecordGauge(name string, value float64, labels ...string)
	StartTimer(name string) Timer
}

MetricsCollector defines metrics collection interface.

type PreparedStatementService

type PreparedStatementService interface {
	Create(ctx context.Context, query string, transactionID string) (*models.PreparedStatement, error)
	Get(ctx context.Context, handle string) (*models.PreparedStatement, error)
	Close(ctx context.Context, handle string) error
	ExecuteQuery(ctx context.Context, handle string, params [][]interface{}) (*models.QueryResult, error)
	ExecuteUpdate(ctx context.Context, handle string, params [][]interface{}) (*models.UpdateResult, error)
	List(ctx context.Context, transactionID string) ([]*models.PreparedStatement, error)
	SetParameters(ctx context.Context, handle string, params [][]interface{}) error
}

PreparedStatementService defines prepared statement operations.

func NewPreparedStatementService

func NewPreparedStatementService(
	repo repositories.PreparedStatementRepository,
	txnService TransactionService,
	logger Logger,
	metrics MetricsCollector,
) PreparedStatementService

NewPreparedStatementService creates a new prepared statement service.

type QueryService

type QueryService interface {
	ExecuteQuery(ctx context.Context, req *models.QueryRequest) (*models.QueryResult, error)
	ExecuteUpdate(ctx context.Context, req *models.UpdateRequest) (*models.UpdateResult, error)
	ValidateQuery(ctx context.Context, query string) error
	GetStatementType(query string) StatementType
	IsUpdateStatement(query string) bool
	IsQueryStatement(query string) bool
}

QueryService defines query operations.

func NewQueryService

func NewQueryService(
	repo repositories.QueryRepository,
	txnService TransactionService,
	logger Logger,
	metrics MetricsCollector,
) QueryService

NewQueryService creates a new query service.

type SecurityRiskLevel

type SecurityRiskLevel int

SecurityRiskLevel indicates the security risk level of a statement.

const (
	SecurityRiskNone SecurityRiskLevel = iota
	SecurityRiskLow
	SecurityRiskMedium
	SecurityRiskHigh
	SecurityRiskCritical
)

func (SecurityRiskLevel) String

func (srl SecurityRiskLevel) String() string

String returns the string representation of security risk level.

type StatementClassifier

type StatementClassifier = EnterpriseStatementClassifier

StatementClassifier type alias for backward compatibility.

type StatementComplexity

type StatementComplexity int

StatementComplexity indicates the estimated complexity of a SQL statement.

const (
	ComplexitySimple StatementComplexity = iota
	ComplexityModerate
	ComplexityComplex
	ComplexityVeryComplex
)

func (StatementComplexity) String

func (sc StatementComplexity) String() string

String returns the string representation of statement complexity.

type StatementInfo

type StatementInfo struct {
	Type                StatementType
	Complexity          StatementComplexity
	ExpectsResultSet    bool
	ExpectsUpdateCount  bool
	RequiresTransaction bool
	IsReadOnly          bool
	IsDangerous         bool
	HasSQLInjectionRisk bool
	Keywords            []string
	Tables              []string
	Operations          []string
	SecurityRisk        SecurityRiskLevel
}

StatementInfo provides comprehensive information about a SQL statement.

type StatementType

type StatementType int

StatementType represents the type of SQL statement.

const (
	StatementTypeDDL     StatementType = iota // CREATE, DROP, ALTER, TRUNCATE
	StatementTypeDML                          // INSERT, UPDATE, DELETE, REPLACE, MERGE
	StatementTypeDQL                          // SELECT, WITH...SELECT
	StatementTypeTCL                          // COMMIT, ROLLBACK, SAVEPOINT, BEGIN
	StatementTypeDCL                          // GRANT, REVOKE, DENY
	StatementTypeUtility                      // SHOW, DESCRIBE, EXPLAIN, ANALYZE, SET, USE, PRAGMA
	StatementTypeOther                        // Unrecognized statements
)

func (StatementType) String

func (st StatementType) String() string

String returns the string representation of the statement type.

type Timer

type Timer interface {
	Stop() time.Duration
}

Timer represents a timing measurement.

type TransactionService

type TransactionService interface {
	Begin(ctx context.Context, opts models.TransactionOptions) (string, error)
	Get(ctx context.Context, id string) (repositories.Transaction, error)
	Commit(ctx context.Context, id string) error
	Rollback(ctx context.Context, id string) error
	List(ctx context.Context) ([]repositories.Transaction, error)
	CleanupInactive(ctx context.Context) error
}

TransactionService defines transaction operations.

func NewTransactionService

func NewTransactionService(
	repo repositories.TransactionRepository,
	cleanupInterval time.Duration,
	logger Logger,
	metrics MetricsCollector,
) TransactionService

NewTransactionService creates a new transaction service.

Jump to

Keyboard shortcuts

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