cobald.composite.factory module

class cobald.composite.factory.FactoryPool(*args, **kwargs)[source]

Bases: CompositePool

Composition that adds and removes pools to satisfy demand

  • 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 expected demand.

  • 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. The FactoryPool inspects the demand for all its children before spawning or disabling any children.

Any child which satisfies supply > 0 or demand > 0 is considered active and contributes to the FactoryPool supply, demand, allocation, and utilisation. The FactoryPool 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 its supply further, it should scale its reported allocation 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

async run()[source]

Service entry point

property supply

The volume of resources that is provided by this pool

property utilisation

Fraction of the provided resources which are actively used