Do not re-instantiate a StateManager for each request in /v2/scope
Change-Id: I692b0fe7676d96e39fb3f569865e3ceaa7e36566
This commit is contained in:
		@@ -28,6 +28,7 @@ class ScopeState(base.BaseResource):
 | 
				
			|||||||
    def __init__(self, *args, **kwargs):
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
        super(ScopeState, self).__init__(*args, **kwargs)
 | 
					        super(ScopeState, self).__init__(*args, **kwargs)
 | 
				
			||||||
        self._client = messaging.get_client()
 | 
					        self._client = messaging.get_client()
 | 
				
			||||||
 | 
					        self._storage_state = storage_state.StateManager()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @api_utils.paginated
 | 
					    @api_utils.paginated
 | 
				
			||||||
    @api_utils.add_input_schema('query', {
 | 
					    @api_utils.add_input_schema('query', {
 | 
				
			||||||
@@ -60,7 +61,7 @@ class ScopeState(base.BaseResource):
 | 
				
			|||||||
            'scope:get_state',
 | 
					            'scope:get_state',
 | 
				
			||||||
            {'tenant_id': scope_id or flask.request.context.project_id}
 | 
					            {'tenant_id': scope_id or flask.request.context.project_id}
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        results = storage_state.StateManager().get_all(
 | 
					        results = self._storage_state.get_all(
 | 
				
			||||||
            identifier=scope_id,
 | 
					            identifier=scope_id,
 | 
				
			||||||
            scope_key=scope_key,
 | 
					            scope_key=scope_key,
 | 
				
			||||||
            fetcher=fetcher,
 | 
					            fetcher=fetcher,
 | 
				
			||||||
@@ -113,7 +114,7 @@ class ScopeState(base.BaseResource):
 | 
				
			|||||||
            raise http_exceptions.BadRequest(
 | 
					            raise http_exceptions.BadRequest(
 | 
				
			||||||
                "Either all_scopes or a scope_id should be specified.")
 | 
					                "Either all_scopes or a scope_id should be specified.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        results = storage_state.StateManager().get_all(
 | 
					        results = self._storage_state.get_all(
 | 
				
			||||||
            identifier=scope_id,
 | 
					            identifier=scope_id,
 | 
				
			||||||
            scope_key=scope_key,
 | 
					            scope_key=scope_key,
 | 
				
			||||||
            fetcher=fetcher,
 | 
					            fetcher=fetcher,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user