works.iterative.sqldb
Members list
Type members
Classlikes
Database-backed implementation of PermissionService with fail-closed error handling.
Database-backed implementation of PermissionService with fail-closed error handling.
This implementation provides production-ready permission storage that:
- Persists RelationTuples to a SQL database via PermissionRepository
- Delegates permission logic to PermissionLogic (pure domain logic)
- Implements fail-closed pattern: database errors result in access denial (return false)
- Logs infrastructure failures before denying access for debugging
SECURITY CRITICAL: Database errors must NEVER bypass authorization checks. The fail-closed pattern ensures that any infrastructure failure (database down, connection timeout, query error) results in access denial rather than granting unintended permissions.
Value parameters
- config
-
Permission configuration defining inheritance rules
- repository
-
The repository for persisting relation tuples
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait MutablePermissionServicetrait EnumerablePermissionServicetrait PermissionServiceclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
Configuration for Flyway migrations
Configuration for Flyway migrations
Value parameters
- cleanDisabled
-
Whether database cleaning is disabled (true by default for safety)
- locations
-
Classpath locations to scan for migrations
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
FlywayConfig.type
Service for managing database migrations using Flyway
Service for managing database migrations using Flyway
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Data model representing a message catalogue entry for SQL storage. Contains persistence-related fields for database storage and audit tracking.
Data model representing a message catalogue entry for SQL storage. Contains persistence-related fields for database storage and audit tracking.
Value parameters
- createdAt
-
Timestamp when this message was first created
- createdBy
-
Optional username of the user who created this message
- description
-
Optional description of the message purpose or context
- language
-
The language code for this message
- messageKey
-
The unique message identifier
- messageText
-
The actual message text content
- updatedAt
-
Timestamp when this message was last updated
- updatedBy
-
Optional username of the user who last updated this message
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Repository interface for persisting RelationTuples to a SQL database.
Repository interface for persisting RelationTuples to a SQL database.
This trait defines the contract for storing Zanzibar-inspired permission tuples, enabling database-backed PermissionService implementations.
Implementation notes:
- All operations return Task[T] to handle database errors
- Database errors should be handled at the service layer (fail-closed pattern)
- Implementations should use parameterized queries to prevent SQL injection
- addRelation should be idempotent (duplicate inserts should succeed)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
MessageCatalogueService implementation with database-backed pre-loaded cache.
MessageCatalogueService implementation with database-backed pre-loaded cache.
This service manages the lifecycle of SQL-backed message catalogues:
- Pre-loads all messages from database at startup (fail-fast via
.orDie) - Stores messages in in-memory cache (ZIO Ref) for fast synchronous access
- Supports hot reload of messages from database without application restart
Lifecycle:
- Startup: Pre-load all configured languages from database (parallel loading) 2. Runtime: Serve messages from in-memory cache (no database queries) 3. On demand: Reload messages from database via
reload()method
Key characteristics:
- Fail-fast startup: Application won't start if messages cannot be loaded
- Zero database queries during message retrieval (all queries at startup/reload)
- Thread-safe concurrent access via ZIO Ref atomic updates
- Hot reload support: Update database, call
reload(), no restart needed - Atomic cache updates: Reload errors leave existing cache unchanged
Performance:
- Startup: ~100-200ms for 10K messages across multiple languages
- Reload: ~50-200ms depending on message count and language count
- Lookup: O(1) map access (identical to JSON implementation)
Value parameters
- cacheRef
-
Reference to the in-memory cache of messages by language
- defaultLanguage
-
The default language to use when messages() is called
- repository
-
The repository for loading messages from database
Attributes
- See also
-
works.iterative.core.service.impl.InMemoryMessageCatalogue for the message catalogue implementation
MessageCatalogueRepository for database access
docs/message-catalogue-reload.md for reload mechanism documentation
- Companion
- object
- Supertypes
-
trait MessageCatalogueServiceclass Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type