Skip to content

Commit

Permalink
Prevent unnecessary RBAC users request (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenneg committed Sep 8, 2021
1 parent f27e4bd commit 7953ed1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private Uni<List<User>> getWithPagination(Function<Integer, Uni<Page<RbacUser>>>
AtomicInteger::new,
state -> fetcher.apply(state.getAndIncrement())
)
.until(page -> page.getData().isEmpty())
.whilst(page -> page.getData().size() == rbacElementsPerPage)
.onItem().transform(page -> page.getData().stream().map(rbacUser -> {
User user = new User();
user.setUsername(rbacUser.getUsername());
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ quarkus.log.cloudwatch.access-key-secret=placeholder

# The current status is cached to limit the number of status DB queries
quarkus.cache.caffeine.maintenance.expire-after-write=PT60s
quarkus.cache.caffeine.rbac-recipient-users-provider-get-users.expire-after-write=PT5M
quarkus.cache.caffeine.rbac-recipient-users-provider-get-group-users.expire-after-write=PT5M
quarkus.cache.caffeine.rbac-recipient-users-provider-get-users.expire-after-write=PT10M
quarkus.cache.caffeine.rbac-recipient-users-provider-get-group-users.expire-after-write=PT10M

# Period between two event log cleanings. It must be expressed with the ISO-8601 duration format PnDTnHnMn.nS.
event-log-cleaner.period=PT10M
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void getAllUsersFromDefaultGroup() {

@Test
public void getAllUsersCache() {
int initialSize = 95;
int initialSize = 1095;
mockGetUsers(initialSize, false);

List<User> users = rbacRecipientUsersProvider.getUsers(accountId, false).await().indefinitely();
Expand All @@ -65,7 +65,7 @@ public void getAllUsersCache() {
Assertions.assertEquals(String.format("username-%d", i), users.get(i).getUsername());
}

int updatedSize = 323;
int updatedSize = 1323;
mockGetUsers(updatedSize, false);

// Should still have the initial size because of the cache
Expand Down

0 comments on commit 7953ed1

Please sign in to comment.