ets-berkeley-edu/calcentral — pull request #484 by ctweney (2013-01-15 17:28:41+00:00)
Title: CLC-955 Speed up GoogleProxy interactions by re-using client

JIRA: https://jira.media.berkeley.edu/jira/browse/CLC-955

This involved some gnashing of teeth due to peculiarities in the Google Ruby API client library and how it maintains its state. A client instance won't work until it's been initialized by calling discovered_api and preferred_version. This is done at the GoogleProxy class level and stored as a class instance variable (@discovered_api, @discovered_version, @discovered_resource_method, and @client) for re-use by all the subclasses of GoogleProxy.

It turned out the only way to re-use an initialized client was to dup it and its authorization. That's done at the instance level right when a request is being processed.

Prior to this change a typical tasks-list request was taking 1.5-2.0sec. The same request now runs in about 0.3sec if the access token is fresh. If the access token needs updating the request takes 0.8-1.1sec.

Squashed commit of the following:

commit 9a59540b87acd0e2ba438313b03755cbbe9cdb49
Author: Chris Tweney
Date: Tue Jan 15 09:18:50 2013 -0800

CLC-955 Adjust log levels; bring back updating/deleting of access token

commit 6186a8a3c5fc2099cc62d4171fd48793462852a1
Author: Chris Tweney
Date: Mon Jan 14 16:55:09 2013 -0800

CLC-955 Make Google token refreshing work

commit a52c7aacbd3cd4eaf617cc69822d0b86137d6cb3
Author: Chris Tweney
Date: Fri Jan 11 16:43:00 2013 -0800

CLC-955 Use class instance vars to reuse Google service objects; refresh of expired tokens still does not work properly.

commit 1791d654a29b7af88326d48d1568ab31a4a141b1
Author: Chris Tweney
Date: Fri Jan 11 10:02:10 2013 -0800

CLC-955 Make the GoogleProxy re-use the google client

commit bf388febcaca9727a18a03adacd22090820e4d2c
Author: Chris Tweney
Date: Thu Jan 10 14:34:10 2013 -0800

CLC-955 Revert google_proxy.rb changes that broke tests

commit 3e67fc4bba7e77bf90e4dcf95c5c740049f643a1
Author: Chris Tweney
Date: Thu Jan 10 13:45:50 2013 -0800

CLC-955 Add GoogleClientProvider to re-use the expensive Google API lookups

commit d29839b001ce16a4156f6e1b53d10414f81c1972
Author: Chris Tweney
Date: Thu Jan 10 10:34:47 2013 -0800

CLC-955 Add some log statements to time Google API interactions