| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.QueueRegistry
Description
The type-level registry and the lookups over it. The lookups resolve a payload's
queue name and handler result type at compile time. Queue names and payload types
must be unique. SpecForPayload checks the entry it resolves against the whole
registry. AllQueuesUnique checks the registry up front.
Synopsis
- type JobPayloadRegistry = [QueueSpec]
- data QueueSpec = QueueWithResult Symbol Type Type
- type Queue (table :: Symbol) payload = 'QueueWithResult table payload ()
- type family TableForPayload payload (registry :: JobPayloadRegistry) :: Symbol where ...
- type family ResultFor payload (registry :: JobPayloadRegistry) where ...
- type family SpecForPayload payload (registry :: JobPayloadRegistry) :: QueueSpec where ...
- type family SpecName (spec :: QueueSpec) :: Symbol where ...
- type family SpecPayload (spec :: QueueSpec) where ...
- type family SpecResult (spec :: QueueSpec) where ...
- type family AllQueuesUnique (registry :: JobPayloadRegistry) where ...
- class AllQueuesUnique registry => RegistryTables (registry :: JobPayloadRegistry) where
- registryTableNames :: Proxy registry -> [Text]
- registryQueueKinds :: Proxy registry -> [(Text, [Text])]
Registry type
type JobPayloadRegistry = [QueueSpec]Source #
A type-level registry mapping table names to payload and result types.
Example:
type MyAppRegistry = '[ Queue "email_jobs" EmailPayload , QueueWithResult "image_jobs" ImagePayload Score ]
A queue's table name, payload type, and handler result type. A type data
constructor. It takes no promotion tick.
Constructors
| QueueWithResult Symbol Type Type |
Instances
| RegistryTables ('[] :: [QueueSpec]) Source # | |
Defined in Arbiter.Core.QueueRegistry | |
| RegistryPolicies ('[] :: [QueueSpec]) p Source # | |
Defined in Arbiter.Core.Admission Methods registryTablePolicies :: [(Text, Set p)]Source # | |
| (HasKind (SpecPayload spec), KnownSymbol (SpecName spec), NotInPayloads (SpecPayload spec) rest, NotInTables (SpecName spec) rest, RegistryTables rest) => RegistryTables (spec ': rest) Source # | |
Defined in Arbiter.Core.QueueRegistry | |
| (CollectFor (SpecPayload spec) p, KnownSymbol (SpecName spec), RegistryPolicies rest p) => RegistryPolicies (spec ': rest) p Source # | |
Defined in Arbiter.Core.Admission Methods registryTablePolicies :: [(Text, Set p)]Source # | |
type Queue (table :: Symbol) payload = 'QueueWithResult table payload ()Source #
A queue whose handlers store no result. A module with its own Queue type
needs import Arbiter.Core hiding (Queue) or a qualified import.
Registry lookups
type family TableForPayload payload (registry :: JobPayloadRegistry) :: Symbol where ...Source #
Look up the table name for a payload type. Compile-time error if not registered.
Equations
| TableForPayload payload registry = SpecName (SpecForPayload payload registry) |
type family ResultFor payload (registry :: JobPayloadRegistry) where ...Source #
The result type a queue's handlers produce.
Equations
| ResultFor payload registry = SpecResult (SpecForPayload payload registry) |
type family SpecForPayload payload (registry :: JobPayloadRegistry) :: QueueSpec where ...Source #
Look up a payload type's registry entry.
Equations
| SpecForPayload payload registry = MatchIn payload ('[] :: [QueueSpec]) registry |
type family SpecName (spec :: QueueSpec) :: Symbol where ...Source #
A queue's table name.
Equations
| SpecName ('QueueWithResult table _1 _2) = table |
type family SpecPayload (spec :: QueueSpec) where ...Source #
A queue's payload type.
Equations
| SpecPayload ('QueueWithResult _1 payload _2) = payload |
type family SpecResult (spec :: QueueSpec) where ...Source #
A queue's result type. A Queue entry produces ().
Equations
| SpecResult ('QueueWithResult _1 _2 result) = result |
Registry validation
type family AllQueuesUnique (registry :: JobPayloadRegistry) where ...Source #
Compile-time check that no two entries share a queue name or a payload type.
Equations
| AllQueuesUnique ('[] :: [QueueSpec]) = () | |
| AllQueuesUnique (spec ': rest) = (NotInTables (SpecName spec) rest, NotInPayloads (SpecPayload spec) rest, AllQueuesUnique rest) |
Runtime utilities
class AllQueuesUnique registry => RegistryTables (registry :: JobPayloadRegistry) whereSource #
A type-level registry's queue names and labels, read at runtime.
Methods
registryTableNames :: Proxy registry -> [Text]Source #
Every queue's table name, in registry order.
registryQueueKinds :: Proxy registry -> [(Text, [Text])]Source #
Each queue with the labels its payload declares.
Instances
| RegistryTables ('[] :: [QueueSpec]) Source # | |
Defined in Arbiter.Core.QueueRegistry | |
| (HasKind (SpecPayload spec), KnownSymbol (SpecName spec), NotInPayloads (SpecPayload spec) rest, NotInTables (SpecName spec) rest, RegistryTables rest) => RegistryTables (spec ': rest) Source # | |
Defined in Arbiter.Core.QueueRegistry | |