Documentation
¶
Index ¶
- func ArgsToOrderBy(orderByArgs []string, disallowedFields map[string]string) (orderBy []string, err *errors.ServiceError)
- func ExtractConditionQueries(n tsl.Node, tableName string) (tsl.Node, []sq.Sqlizer, *errors.ServiceError)
- func FieldNameWalk(n tsl.Node, disallowedFields map[string]string) (newNode tsl.Node, err *errors.ServiceError)
- func GetTableName(g2 *gorm.DB) string
- func MarkForRollback(ctx context.Context, err error)
- func Migrate(g2 *gorm.DB) error
- func MigrateTo(sessionFactory SessionFactory, migrationID string)
- func MigrateWithLock(ctx context.Context, factory SessionFactory) error
- func NewAdvisoryLockContext(ctx context.Context, connection SessionFactory, id string, lockType LockType) (context.Context, string, error)
- func NewContext(ctx context.Context, connection SessionFactory) (context.Context, error)
- func PreprocessConditionSubfields(search string) string
- func Resolve(ctx context.Context)
- func TransactionMiddleware(next http.Handler, connection SessionFactory, requestTimeout time.Duration) http.Handler
- func Unlock(ctx context.Context, callerUUID string)
- type AdvisoryLock
- type ConditionExpression
- type LockType
- type SessionFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArgsToOrderBy ¶
func ArgsToOrderBy( orderByArgs []string, disallowedFields map[string]string) (orderBy []string, err *errors.ServiceError)
ArgsToOrderBy returns cleaned orderBy list.
func ExtractConditionQueries ¶
func ExtractConditionQueries(n tsl.Node, tableName string) (tsl.Node, []sq.Sqlizer, *errors.ServiceError)
ExtractConditionQueries walks the TSL tree and extracts condition queries, returning the modified tree (with condition nodes replaced) and the extracted conditions. This is necessary because the TSL library doesn't support JSONB containment operators.
func FieldNameWalk ¶
func FieldNameWalk( n tsl.Node, disallowedFields map[string]string) (newNode tsl.Node, err *errors.ServiceError)
FieldNameWalk walks on the filter tree and check/replace the search fields names: a. the the field name is valid. b. replace the field name with the SQL column name.
func GetTableName ¶
func MarkForRollback ¶
MarkForRollback flags the transaction stored in the context for rollback and logs whatever error caused the rollback
func MigrateTo ¶
func MigrateTo(sessionFactory SessionFactory, migrationID string)
MigrateTo a specific migration will not seed the database, seeds are up to date with the latest schema based on the most recent migration This should be for testing purposes mainly
func MigrateWithLock ¶ added in v0.2.0
func MigrateWithLock(ctx context.Context, factory SessionFactory) error
MigrateWithLock runs migrations with an advisory lock to prevent concurrent migrations
func NewAdvisoryLockContext ¶ added in v0.2.0
func NewAdvisoryLockContext( ctx context.Context, connection SessionFactory, id string, lockType LockType, ) (context.Context, string, error)
NewAdvisoryLockContext returns a new context with AdvisoryLock stored in it. Upon error, the original context is still returned along with an error.
CONCURRENCY: The returned context must not be shared across goroutines that call NewAdvisoryLockContext or Unlock concurrently, as the internal lock map is not protected by a mutex. Each goroutine should derive its own context chain.
func NewContext ¶
NewContext returns a new context with transaction stored in it. Upon error, the original context is still returned along with an error
func PreprocessConditionSubfields ¶ added in v0.2.0
PreprocessConditionSubfields rewrites 4-part condition paths into 3-part paths before TSL parsing. The TSL parser supports at most 3 dot-separated segments. Only replaces in unquoted segments to avoid mutating string literals.
Example: status.conditions.Ready.last_updated_time < '2026-03-06T00:00:00Z' becomes: status.conditions.Ready__last_updated_time < '2026-03-06T00:00:00Z'
func TransactionMiddleware ¶
func TransactionMiddleware(next http.Handler, connection SessionFactory, requestTimeout time.Duration) http.Handler
TransactionMiddleware creates a new HTTP middleware that begins a database transaction and stores it in the request context.
Types ¶
type AdvisoryLock ¶ added in v0.2.0
type AdvisoryLock struct {
// contains filtered or unexported fields
}
AdvisoryLock represents a postgres advisory lock
begin # start a Tx select pg_advisory_xact_lock(id, lockType) # obtain the lock (blocking) end # end the Tx and release the lock
ownerUUID is a way to own the lock. Only the very first service call that owns the lock will have the correct ownerUUID. This is necessary to allow functions to call other service functions as part of the same lock (id, lockType).
type ConditionExpression ¶
ConditionExpression represents an extracted condition query as a Squirrel expression
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package db_context dbContext provides a wrapper around db context handling to allow access to the db context without requiring importing the db package, thus avoiding cyclic imports
|
Package db_context dbContext provides a wrapper around db context handling to allow access to the db context without requiring importing the db package, thus avoiding cyclic imports |