xtr_lock.bundle ¶
The xtr-dependency-injection bundle for xtr-lock.
DEFAULT_RESOURCE
module-attribute
¶
The resource whose factory is provided without a qualifier.
StoreEntry ¶
One store: a DSN or keyword :class:~xtr_lock.store.StoreFactory reads, or a connection.
LockBundle ¶
Bases: Bundle[LockConfig]
Turns a :class:LockConfig into a store and a lock factory per resource.
prepend_extension ¶
When logging is active, add the lock channel to its config.
load_extension ¶
load_extension(config: LockConfig, services: ServiceConfigurator, builder: ContainerBuilder) -> None
Register a store and a lock factory under each resource's name.
The lock directory is read from the builder, not from the container when a store is built: a container compiled without the kernel's parameters — plain wireup — still gets the project's own directory.
boot
async
¶
Refuse a store no DSN serves, or a connection nobody registered, before any lock.
The configuration is read resolved, so a DSN given as env(...) is
read here, and a variable that is not set fails the boot.
Raises:
-
InvalidArgumentError–Naming the resource whose store is wrong.
LockConfig
dataclass
¶
Which lock resources exist, and which stores keep each one's locks.
Every resource becomes a :class:~xtr_lock.lock_factory.LockFactory
qualified by its name, the one named "default" also without a
qualifier. A resource with several stores keeps each lock in all of them
and counts it held once a majority agree.
A store is one of:
"flock"— files inlockunder the kernel'sshare_dir,var/sharein the project;- any DSN :meth:
~xtr_lock.store.StoreFactory.create_storereads —"flock:///var/lock/app","in-memory","null","redis://host:6379"and the like — includingenv(...); - a :class:
Referenceto a client the container provides.
LockConfig(
resources={
"default": "flock",
"invoices": ["redis://a:6379", "redis://b:6379", "redis://c:6379"],
}
)
Attributes:
-
resources(Mapping[str, StoreEntry | Sequence[StoreEntry]]) –Each resource's store, or stores. An empty mapping means the default; a resource given no store at all is skipped.
stores_by_resource ¶
Return each resource's stores as a tuple; the default resource when none is set.