Source

callchain / callchain / root / lazyauto.py

Full commit
# -*- coding: utf-8 -*-
'''lazy auto-balancing root chains'''

from appspace import key
from twoq.lazy import AutoResultMixin

from callchain.key.mixin import KEvent
from callchain.route import Chains, Events
from callchain.mixin import ChainMixin, PriorityMixin, EventMixin

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

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


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

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


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

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


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

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


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


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


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


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

    '''lazy queued auto-balancing call chain'''


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

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


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

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