Ejemplo n.º 1
0
        private void HandleRequest(Request request)
        {
            while (_handlerService.CanHandle(request.CreateTime) && !_buffer.IsEmpty())
            {
                _repository.Save(_handlerService.Handle(_buffer.Get(), request.CreateTime));
            }

            if (_buffer.IsEmpty())
            {
                if (_handlerService.CanHandle(request.CreateTime))
                {
                    _repository.Save(_handlerService.Handle(request, request.CreateTime));
                }
                else
                {
                    _buffer.Put(request);
                }
            }
            else if (_buffer.HasPlace())
            {
                _buffer.Put(request);
            }
            else
            {
                _repository.Save(new RejectedRequest(request));
            }
        }