Пример #1
0
    def startFactory(self):
        '''
        Callback for when the server is started up

        :return: void
        '''
        _logger.debug('Mamba Server Started')
        self.database = QueueCollection(self.path)
        self.statistics = AttributeDict()
        self.statistics.start_time = time.time()
Пример #2
0
class MambaServerFactory(ServerFactory):
    '''
    Builder class for a mamba server that also holds the queue
    collections that are maintained across connections.
    '''

    protocol = MambaProtocol

    def __init__(self, options):
        ''' Overloaded initializer for the server factory

        :param options: The server options to apply
        '''
        self.path = options['path']
        self.timeout = options['timeout']

    def startFactory(self):
        '''
        Callback for when the server is started up

        :return: void
        '''
        _logger.debug('Mamba Server Started')
        self.database = QueueCollection(self.path)
        self.statistics = AttributeDict()
        self.statistics.start_time = time.time()

    def stopFactory(self):
        '''
        Callback for when the server is shut down

        :return: void
        '''
        self.database.close()

    def getHandler(self):
        '''
        Helper method to encapsulate creating a message handler

        :return: A mamba message handler
        '''
        return Handler(self.database, self.statistics)