cobald.composite.factory module
- class cobald.composite.factory.FactoryPool(*args, **kwargs)[source]
Bases:
CompositePool
Composition that adds and removes pools to satisfy demand
- Parameters:
factory – a callable that produces a new
Pool
interval – how often to adjust the number of children
Adjustment uses two extensions that children must respond to adequately:
When spawned via
factory()
, children shall already be set to their expecteddemand
.When disabled via
demand=0
, children shall shut down and free any resources and tasks.
Once spawned, children are free to adjust their demand if required. A child may disable itself permanently by setting its own
demand = 0
. TheFactoryPool
inspects the demand for all its children before spawning or disabling any children.Any child which satisfies
supply > 0
ordemand > 0
is considered active and contributes to theFactoryPool
supply
,demand
,allocation
, andutilisation
. TheFactoryPool
makes no assumption about the validity or fitness of active children. It is the responsibility of children to report their status accordingly. For example, if a child shuts down and does not allocate itssupply
further, it should scale its reportedallocation
accordingly.- property allocation
Fraction of the provided resources which are assigned for usage
- property children
The individual resource providers making up this pool
- property demand
The volume of resources to be provided by this pool
- property supply
The volume of resources that is provided by this pool
- property utilisation
Fraction of the provided resources which are actively used