Exemplo n.º 1
0
    def setUp(self):
        # override the configuration of connection agent
        # we do this here only to demonstrate this is possibility
        # keep in mind that it needs to be done before the setUp of
        # SimulationTest, which creates the simulation driver.
        from featchat.agents.connection import connection_agent
        config = connection_agent.ConnectionAgentConfiguration(
            doc_id = 'test-connection-config',
            connections_limit = 2)
        featchat.initial_data(config)
        self.override_config('connection_agent', config)

        return common.SimulationTest.setUp(self)
Exemplo n.º 2
0
from featchat.application import featchat


DEFAULT_PORT = 8880
DEFAULT_DNS_PREFIX = u'api'


@featchat.register_restorator
class ApiAgentConfiguration(document.Document):

    type_name = 'api_agent_conf'
    document.field('doc_id', u'api_agent_conf', '_id')
    document.field('dns_prefix', DEFAULT_DNS_PREFIX)
    document.field('port', DEFAULT_PORT)

featchat.initial_data(ApiAgentConfiguration)


@featchat.register_agent('api_agent')
class ApiAgent(agent.BaseAgent, alert.AgentMixin):
    implements(IWebAgent)

    restart_strategy = monitor.RestartStrategy.wherever

    dependency.register(IServerFactory,
                        'featchat.agents.api.web.ServerDummy',
                        ExecMode.test)
    dependency.register(IServerFactory,
                        'featchat.agents.api.web.ServerDummy',
                        ExecMode.simulation)
    dependency.register(IServerFactory,
Exemplo n.º 3
0
    @replay.journaled
    def granted(self, state, grant):
        payload = state.agent.generate_join_url(state.allocation_id)
        report = message.FinalReport(payload=payload)
        state.medium.finalize(report)


@featchat.register_restorator
class ConnectionAgentConfiguration(document.Document):

    type_name = 'connection_agent_conf'
    document.field('doc_id', u'connection_agent_conf', '_id')
    document.field('connections_limit', 10)
    document.field('authorization_timeout', 10)

featchat.initial_data(ConnectionAgentConfiguration)


class RoomPoster(poster.BasePoster):

    application = featchat

    @replay.mutable
    def initiate(self, state):
        state.own_key = state.agent.get_own_address().key

    @replay.immutable
    def pack_payload(self, state, body):
        resp = dict()
        resp['key'] = state.own_key
        resp['body'] = body