cobald.interfaces package

Interfaces for primitives of the cobald model

Each Pool provides a varying number of resources. A Controller adjusts the number of resources that a Pool must provide. Several Pools can be combined in a single CompositePool to appear as one. To modify how a Pool presents or digests data, any number of PoolDecorator may proceed it.

digraph graphname {
    graph [rankdir=LR, splines=lines, bgcolor="transparent"]
    controller [label=Controller]
    composite [label=CompositePool]
    decoa [label=PoolDecorator]
    poola, poolb [label=Pool]
    controller -> decoa -> composite
    composite -> poola
    composite -> poolb
}
class cobald.interfaces.CompositePool[source]

Bases: Pool

Concatenation of multiple providers for a number of indistinguishable resources

abstract property allocation: float

Fraction of the provided resources which are assigned for usage

abstract property children: List[Pool]

The individual resource providers making up this pool

abstract property demand

The volume of resources to be provided by this pool

abstract property supply

The volume of resources that is provided by this pool

abstract property utilisation: float

Fraction of the provided resources which are actively used

class cobald.interfaces.Controller(target: Pool)[source]

Bases: object

Controller adjusting the demand in a Pool

Parameters

target – the resource pool for which demand is adjusted

classmethod s(*args, **kwargs) Partial[C][source]

Create an unbound prototype of this class, partially applying arguments

controller = Controller.s(interval=20)

pipeline = controller(rate=10) >> pool
class cobald.interfaces.Partial(ctor: Type[C_co], *args, __leaf__, **kwargs)[source]

Bases: Generic[C_co]

Partial application and chaining of Pool Controllers and Decorators

This class acts similar to functools.partial, but allows for repeated application (currying) and explicit binding via the >> operator.

# incrementally prepare controller parameters
control = Partial(Controller, rate=10, interval=10)
control = control(low_utilisation=0.5, high_allocation=0.9)

# apply target by chaining
pipeline = control >> Decorator() >> Pool()
Note

The keyword argument __leaf__ is reserved for internal usage.

Note

Binding Controllers and Decorators creates a temporary PartialBind. Only binding to a Pool as the last element creates a concrete binding.

args
ctor
kwargs
leaf
class cobald.interfaces.Pool[source]

Bases: object

Individual provider for a number of indistinguishable resources

abstract property allocation: float

Fraction of the provided resources which are assigned for usage

abstract property demand: float

The volume of resources to be provided by this pool

classmethod s(*args, **kwargs) Partial[C][source]

Create an unbound prototype of this class, partially applying arguments

pool = RemotePool.s(port=1337)

pipeline = controller >> pool(host='localhost')
abstract property supply: float

The volume of resources that is provided by this pool

abstract property utilisation: float

Fraction of the provided resources which are actively used

class cobald.interfaces.PoolDecorator(target: Pool)[source]

Bases: Pool

Decorator modifying how a pool provides resources

Parameters

target – the resource pool for which demand is adjusted

property allocation: float

Fraction of the provided resources which is assigned for usage

property demand

The volume of resources to be provided by this site

classmethod s(*args, **kwargs) Partial[C][source]

Create an unbound prototype of this class, partially applying arguments

decorator = Buffer.s(window=20)

pipeline = controller >> decorator >> pool
property supply

The volume of resources that is provided by this site

property utilisation: float

Fraction of the provided resources which is actively used