Skip to content

Instantly share code, notes, and snippets.

@pmyjavec
Last active June 9, 2016 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmyjavec/e7dcdac39914863fb6a0f024fdeb6b3b to your computer and use it in GitHub Desktop.
Save pmyjavec/e7dcdac39914863fb6a0f024fdeb6b3b to your computer and use it in GitHub Desktop.
def execute(cmd)
response = nil
begin
input = prepare_operation(cmd)
Log.info "received command: #{input[:command]}, args: #{input[:args]}"
semaphore.synchronize { repository.send(input[:command], *input[:args]) }
rescue ClientError => e
Log.error "input error: #{e.message}"
response = 'ERROR'
raise e
rescue RepositoryError => e
Log.error "repository opeartion error: #{e.message}"
response = 'FAIL'
else
Log.info "command OK"
response = 'OK'
end
response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment