| 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
Source #type JobPayloadRegistry = [QueueSpec]
A type-level registry mapping table names to payload 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 Source #registryTablePolicies :: [(Text, Set p)] | |
| (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 Source #registryTablePolicies :: [(Text, Set p)] | |
Source #type Queue (table :: Symbol) payload = 'QueueWithResult table payload ()
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
Source #type family TableForPayload payload (registry :: JobPayloadRegistry) :: Symbol where ...
Look up the table name for a payload type. Compile-time error if not registered.
Equations
| TableForPayload payload registry = SpecName (SpecForPayload payload registry) |
Source #type family ResultFor payload (registry :: JobPayloadRegistry) where ...
The result type a queue's handlers produce.
Equations
| ResultFor payload registry = SpecResult (SpecForPayload payload registry) |
Source #type family SpecForPayload payload (registry :: JobPayloadRegistry) :: QueueSpec where ...
Look up a payload type's registry entry.
Equations
| SpecForPayload payload registry = MatchIn payload ('[] :: [QueueSpec]) registry |
Source #type family SpecName (spec :: QueueSpec) :: Symbol where ...
A queue's table name.
Equations
| SpecName ('QueueWithResult table _1 _2) = table |
Source #type family SpecPayload (spec :: QueueSpec) where ...
A queue's payload type.
Equations
| SpecPayload ('QueueWithResult _1 payload _2) = payload |
Source #type family SpecResult (spec :: QueueSpec) where ...
A queue's result type. A Queue entry produces ().
Equations
| SpecResult ('QueueWithResult _1 _2 result) = result |
Registry validation
Source #type family AllQueuesUnique (registry :: JobPayloadRegistry) where ...
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
Source #class AllQueuesUnique registry => RegistryTables (registry :: JobPayloadRegistry) where
Extract table names from a type-level registry at runtime (used by migrations).
Methods
Source #registryTableNames :: Proxy registry -> [Text]
Source #registryQueueKinds :: Proxy registry -> [(Text, [Text])]
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 | |