pub struct RepositoryCache { /* private fields */ }Expand description
The per-organization repository list, refreshed far more slowly than demand.
§Why this is not just “call the directory each poll”
An organization demand poll already costs one request per repository. Adding
the installation listing to every poll makes the scoping of a poll cost
requests on the same schedule as the poll itself, which is how a
ten-repository organization at the 30-second floor stops fitting inside the
half-of-5,000 allowance f2 admits targets against. The repository list is
also the one input that changes on a human timescale, so refreshing it
REPOSITORY_LIST_REFRESH_MULTIPLE times more slowly costs nothing real.
§A repository target never consults the directory at all
Its scope is itself. That is not an optimisation; asking an installation listing which repositories a single named repository covers would be asking a question whose answer is already in the target.
Implementations§
Source§impl RepositoryCache
impl RepositoryCache
Sourcepub fn new(
directory: Arc<dyn RepositoryDirectory>,
clock: Arc<dyn Clock>,
poll: RefreshInterval,
) -> Self
pub fn new( directory: Arc<dyn RepositoryDirectory>, clock: Arc<dyn Clock>, poll: RefreshInterval, ) -> Self
Build a cache whose refresh interval is poll slowed by
REPOSITORY_LIST_REFRESH_MULTIPLE.
Sourcepub fn lookups(&self) -> u64
pub fn lookups(&self) -> u64
How many times the underlying directory was actually asked.
Measured rather than assumed, for the reason c4 measures its own
request count: a budget nothing counts is a table in a document.
Sourcepub async fn scope_for(
&self,
target: &ScaleTarget,
) -> Result<ActivityScope, InventoryError>
pub async fn scope_for( &self, target: &ScaleTarget, ) -> Result<ActivityScope, InventoryError>
The scope one demand poll of target covers.
§Errors
Whatever the directory reported, for an organization target whose list is stale or absent. A repository target cannot fail.