Source

callchain / callchain / root / activeauto.py

# -*- coding: utf-8 -*-
'''active auto-balancing root chains'''

from appspace import key
from twoq.active import AutoResultMixin

from callchain.config import Defaults
from callchain.keys.mixin import KEvent
from callchain.route import Chains, Events
from callchain.mixins import ChainMixin, PriorityMixin, EventMixin

from callchain.root.core import RootMixin, EventRootMixin
from callchain.root.keys import KRootResults, KRootThings
from callchain.root.apps import thingchain, thingevent, chain, events

thingchain = Chains(thingchain).defaults(Defaults)
thingevent = Events(thingevent).events(events).defaults(Defaults)


@key(KRootThings)
@thingchain
class callchain(RootMixin, ChainMixin, AutoResultMixin):

    '''active queued auto-balancing lite call chain'''


@key(KRootThings)
@thingchain
class prioritychain(RootMixin, PriorityMixin, AutoResultMixin):

    '''active priority queued auto-balancing lite call chain'''


@key(KEvent)
@thingevent
class eventchain(EventRootMixin, EventMixin, AutoResultMixin):

    '''active queued auto-balancing lite event chain'''


class chainqueue(chain):
    prefix = 'callchain.chainlet.activeauto.chainlet'


class eventqueue(chain):
    prefix = 'callchain.chainlet.activeauto.eventlet'
    chain = 'callchain.chainlet.activeauto.chainlet.chainlink'


chain = Chains(chainqueue).defaults(Defaults)
event = Events(eventqueue).events(events).defaults(Defaults)


@key(KRootResults)
@chain
class chainq(RootMixin, ChainMixin, AutoResultMixin):

    '''active queued auto-balancing call chain'''


@key(KRootResults)
@chain
class priorityq(RootMixin, PriorityMixin, AutoResultMixin):

    '''active priority queued auto-balancing lite call chain'''


@key(KEvent)
@event
class eventq(EventRootMixin, EventMixin, AutoResultMixin):

    '''active priority queued auto-balancing lite call chain'''