Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: appengine/config_service/api.py

Issue 2931673003: config_service: fetch repos and metadata concurrently (Closed)
Patch Set: use ctx.memcache_[gs]et Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/config_service/acl_test.py ('k') | appengine/config_service/api_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from google.appengine.api import memcache 7 from google.appengine.api import memcache
8 from google.appengine.ext import ndb 8 from google.appengine.ext import ndb
9 from protorpc import messages 9 from protorpc import messages
10 from protorpc import message_types 10 from protorpc import message_types
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 Does not return projects that have no repo information. It might happen due 394 Does not return projects that have no repo information. It might happen due
395 to eventual consistency. 395 to eventual consistency.
396 396
397 Does not check access. 397 Does not check access.
398 398
399 Caches results in memcache for 1 min. 399 Caches results in memcache for 1 min.
400 """ 400 """
401 result = [] 401 result = []
402 projs = projects.get_projects() 402 projs = projects.get_projects()
403 project_ids = [p.id for p in projs] 403 project_ids = [p.id for p in projs]
404 repos = projects.get_repos(project_ids) 404 repos_fut = projects.get_repos_async(project_ids)
405 metadata = projects.get_metadata(project_ids) 405 metadata_fut = projects.get_metadata_async(project_ids)
406 ndb.Future.wait_all([repos_fut, metadata_fut])
407 repos, metadata = repos_fut.get_result(), metadata_fut.get_result()
406 for p in projs: 408 for p in projs:
407 repo_type, repo_url = repos.get(p.id, (None, None)) 409 repo_type, repo_url = repos.get(p.id, (None, None))
408 if repo_type is None: 410 if repo_type is None:
409 # Not yet consistent. 411 # Not yet consistent.
410 continue 412 continue
411 name = None 413 name = None
412 if metadata.get(p.id) and metadata[p.id].name: 414 if metadata.get(p.id) and metadata[p.id].name:
413 name = metadata[p.id].name 415 name = metadata[p.id].name
414 result.append(Project( 416 result.append(Project(
415 id=p.id, 417 id=p.id,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 495
494 def can_read_config_sets(config_sets): 496 def can_read_config_sets(config_sets):
495 try: 497 try:
496 return acl.can_read_config_sets(config_sets) 498 return acl.can_read_config_sets(config_sets)
497 except ValueError as ex: 499 except ValueError as ex:
498 raise endpoints.BadRequestException(ex.message) 500 raise endpoints.BadRequestException(ex.message)
499 501
500 502
501 def can_read_config_set(config_set): 503 def can_read_config_set(config_set):
502 return can_read_config_sets([config_set]).get(config_set) 504 return can_read_config_sets([config_set]).get(config_set)
OLDNEW
« no previous file with comments | « appengine/config_service/acl_test.py ('k') | appengine/config_service/api_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698