Documentation
¶
Index ¶
- func NewDocumentRepository(writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, ...) interfaces.DocumentRepository
- func NewTaskRepository(writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, ...) interfaces.TaskRepository
- func NewWorkflowRepository(writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, ...) interfaces.WorkflowRepository
- func NewWorkspaceRepository(writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, ...) interfaces.WorkspaceRepository
- type BaseRepository
- func (r *BaseRepository) CacheDelete(ctx context.Context, key string) error
- func (r *BaseRepository) CacheGet(ctx context.Context, key string, dest interface{}) error
- func (r *BaseRepository) CacheSet(ctx context.Context, key string, value interface{}, ttl time.Duration) error
- func (r *BaseRepository) Close() error
- func (r *BaseRepository) ExecuteQuery(ctx context.Context, operation string, fn func(ctx context.Context) error) error
- func (r *BaseRepository) ExecuteQueryWithRetry(ctx context.Context, operation string, fn func(ctx context.Context) error) error
- func (r *BaseRepository) ExecuteWithCircuitBreaker(ctx context.Context, name string, fn func() (interface{}, error)) (interface{}, error)
- func (r *BaseRepository) GetMetrics() map[string]interface{}
- func (r *BaseRepository) GetPreparedStatement(name, query string, db *sqlx.DB) (*sqlx.NamedStmt, error)
- func (r *BaseRepository) InvalidateCachePattern(ctx context.Context, pattern string) error
- func (r *BaseRepository) TranslateError(err error, entity string) error
- func (r *BaseRepository) WithTransaction(ctx context.Context, fn func(tx *sqlx.Tx) error) error
- func (r *BaseRepository) WithTransactionOptions(ctx context.Context, opts *types.TxOptions, fn func(tx *sqlx.Tx) error) error
- func (r *BaseRepository) WithTx(tx *sqlx.Tx) *BaseRepository
- type BaseRepositoryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDocumentRepository ¶
func NewDocumentRepository( writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, tracer observability.StartSpanFunc, ) interfaces.DocumentRepository
NewDocumentRepository creates a production-ready document repository
func NewTaskRepository ¶
func NewTaskRepository( writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, tracer observability.StartSpanFunc, metrics observability.MetricsClient, ) interfaces.TaskRepository
NewTaskRepository creates a production-ready task repository
func NewWorkflowRepository ¶
func NewWorkflowRepository( writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, tracer observability.StartSpanFunc, metrics observability.MetricsClient, ) interfaces.WorkflowRepository
NewWorkflowRepository creates a production-ready workflow repository
func NewWorkspaceRepository ¶
func NewWorkspaceRepository( writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, tracer observability.StartSpanFunc, ) interfaces.WorkspaceRepository
NewWorkspaceRepository creates a production-ready workspace repository
Types ¶
type BaseRepository ¶
type BaseRepository struct {
// contains filtered or unexported fields
}
BaseRepository provides common functionality for all repositories
func NewBaseRepository ¶
func NewBaseRepository( writeDB, readDB *sqlx.DB, cache cache.Cache, logger observability.Logger, tracer observability.StartSpanFunc, metrics observability.MetricsClient, config BaseRepositoryConfig, ) *BaseRepository
NewBaseRepository creates a new base repository
func (*BaseRepository) CacheDelete ¶
func (r *BaseRepository) CacheDelete(ctx context.Context, key string) error
CacheDelete removes a value from cache
func (*BaseRepository) CacheGet ¶
func (r *BaseRepository) CacheGet(ctx context.Context, key string, dest interface{}) error
CacheGet retrieves a value from cache with proper error handling and metrics
func (*BaseRepository) CacheSet ¶
func (r *BaseRepository) CacheSet(ctx context.Context, key string, value interface{}, ttl time.Duration) error
CacheSet stores a value in cache with proper error handling and metrics
func (*BaseRepository) ExecuteQuery ¶
func (r *BaseRepository) ExecuteQuery(ctx context.Context, operation string, fn func(ctx context.Context) error) error
ExecuteQuery executes a query with timeout and metrics
func (*BaseRepository) ExecuteQueryWithRetry ¶
func (r *BaseRepository) ExecuteQueryWithRetry(ctx context.Context, operation string, fn func(ctx context.Context) error) error
ExecuteQueryWithRetry executes a query with retry logic
func (*BaseRepository) ExecuteWithCircuitBreaker ¶
func (r *BaseRepository) ExecuteWithCircuitBreaker(ctx context.Context, name string, fn func() (interface{}, error)) (interface{}, error)
ExecuteWithCircuitBreaker executes a function with circuit breaker protection
func (*BaseRepository) GetMetrics ¶
func (r *BaseRepository) GetMetrics() map[string]interface{}
GetMetrics returns current repository metrics
func (*BaseRepository) GetPreparedStatement ¶
func (r *BaseRepository) GetPreparedStatement(name, query string, db *sqlx.DB) (*sqlx.NamedStmt, error)
GetPreparedStatement gets or creates a prepared statement
func (*BaseRepository) InvalidateCachePattern ¶
func (r *BaseRepository) InvalidateCachePattern(ctx context.Context, pattern string) error
InvalidateCachePattern invalidates cache entries matching a pattern
func (*BaseRepository) TranslateError ¶
func (r *BaseRepository) TranslateError(err error, entity string) error
TranslateError converts database errors to domain errors
func (*BaseRepository) WithTransaction ¶
WithTransaction executes a function within a database transaction
func (*BaseRepository) WithTransactionOptions ¶
func (r *BaseRepository) WithTransactionOptions(ctx context.Context, opts *types.TxOptions, fn func(tx *sqlx.Tx) error) error
WithTransactionOptions executes a function within a database transaction with options
func (*BaseRepository) WithTx ¶
func (r *BaseRepository) WithTx(tx *sqlx.Tx) *BaseRepository
WithTx creates a new repository instance that uses the provided transaction
type BaseRepositoryConfig ¶
type BaseRepositoryConfig struct {
QueryTimeout time.Duration
MaxRetries int
CacheTimeout time.Duration
CircuitBreaker *resilience.CircuitBreaker
}
BaseRepositoryConfig holds configuration for BaseRepository