forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add addressbook performance tap option
closes CNVS-34528 another option for the address book strategy chosen in the plugin. combines answers from current MessageableUser implementation with traffic directed to the service as if it were in use. but the service is instructed via `ignore_result` parameter to reply to canvas as quickly as possible, so that if the service does have performance issues, actual canvas performance is not affected. test-plan: - set up canvas to be able to talk to the address book service - have a published course with an active teacher and an active student - do _not_ replicate that data into the address book service; i.e. the service answer should be wrong if used - choose the "AddressBook performance tap" as the address book implementation in the plugin setting - logged in as the teacher, query for the student in the inbox. should find the student (backed by the messageableuser implementation) - check the service request logs; even though the service response wasn't used, there should still be a request made against it - take down the service entirely - repeat the query in the inbox. should still get the result from the messageableuser implementation despite the service being unavailable Change-Id: I031b7c397d2e20d74d7699a81ca8040064a8df75 Reviewed-on: https://gerrit.instructure.com/104112 Reviewed-by: Andrew Huff <[email protected]> Tested-by: Jenkins QA-Review: Deepeeca Soundarrajan <[email protected]> Product-Review: Jacob Fugal <[email protected]>
- Loading branch information
Showing
6 changed files
with
136 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module AddressBook | ||
class PerformanceTap < AddressBook::MessageableUser | ||
def initialize(sender) | ||
super sender | ||
@service_tap = AddressBook::Service.new(sender, ignore_result: true) | ||
end | ||
|
||
def known_users(users, options={}) | ||
@service_tap.known_users(users, options) | ||
super | ||
end | ||
|
||
def known_in_context(context, is_admin=false) | ||
@service_tap.known_in_context(context, is_admin) | ||
super | ||
end | ||
|
||
def count_in_context(context) | ||
@service_tap.count_in_context(context) | ||
super | ||
end | ||
|
||
# makes a wrapper around two paginated collections, one for source and one | ||
# for the tap. proxies pagination information and results to and from the | ||
# source collection, but also executes pagination against the tap | ||
# collection for every source page. | ||
class TapProxy < PaginatedCollection::Proxy | ||
def initialize(source_collection:, tap_collection:) | ||
@source_collection = source_collection | ||
super lambda{ |source_pager| | ||
tap_pager = tap_collection.configure_pager( | ||
tap_collection.new_pager, | ||
per_page: source_pager.per_page, | ||
total_entries: nil | ||
) | ||
tap_collection.execute_pager(tap_pager) | ||
source_collection.execute_pager(source_pager) | ||
} | ||
end | ||
|
||
def depth | ||
@source_collection.depth | ||
end | ||
|
||
def new_pager | ||
@source_collection.new_pager | ||
end | ||
|
||
def configure_pager(pager, options) | ||
@source_collection.configure_pager(pager, options) | ||
end | ||
end | ||
|
||
def search_users(options={}) | ||
TapProxy.new( | ||
source_collection: super, | ||
tap_collection: @service_tap.search_users(options) | ||
) | ||
end | ||
|
||
def preload_users(users) | ||
@service_tap.preload_users(users) | ||
super | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters