def on_process(self, request, **options): ''' It will be called when a request starts to be processed @param ClientRequest request: client request ''' coordinator_services.record_request(request) logging_services.debug( 'Request [{0}] for service [{1}] recorded.'.format( request.id, request.command_key))
def on_process_failed(self, request, error, **options): ''' It will be called when a request is failed. @param ClientRequest request: client request @param Exception error: error content ''' coordinator_services.set_failed(request, error.message) logging_services.debug( 'Request [{0}] for service [{1}] failed.'.format( request.id, request.command_key))
def on_process_completed(self, request, response, **options): ''' It will be called when a request is completed. @param ClientRequest request: client request @param ServerResponse response: server response ''' coordinator_services.set_completed(request) logging_services.debug( 'Request [{0}] for service [{1}] completed.'.format( request.id, request.command_key))
def before_execute(self, commander, command, *args, **kargs): ''' This method will be called before command execution. @param commander: commander @param command: command ''' if not self._is_required_to_record_request(command): return request = session_services.get_current_session().get_client_request() coordinator_services.record_request( command.get_option('recorder_type'), request) logging_services.debug( 'Request [{0}] for service [{1}] recorded.'.format( request.id, command.get_key()))
def exception(self, commander, command, error, *args, **kargs): ''' This method will be called whenever an exception occurred during executing a command. @param commander: commander @param command: command @param error: exception instance ''' if not self._is_required_to_record_request(command): return request = session_services.get_current_session().get_client_request() coordinator_services.set_failed(command.get_option('recorder_type'), request, error) logging_services.debug( 'Request [{0}] for service [{1}] failed.'.format( request.id, command.get_key()))