Skip to content

Commit

Permalink
feat: Caching of roles moved from specific method to generic one. (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniotarricone authored Jun 14, 2024
1 parent 1421886 commit 2bd7647
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ private Role response2Role(Response r) {
* @param terminalId
* @return
*/
@CacheResult(cacheName = "client-role")
public Uni<Role> getRoles(String acquirerId, String channel, String clientId, String merchantId, String terminalId) {
return blobService.getBlob("roles", acquirerId, channel, clientId, merchantId, terminalId, "roles.json")
.map(this::response2Role);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package it.pagopa.swclient.mil.auth.service;

import io.quarkus.cache.CacheResult;
import io.quarkus.logging.Log;
import io.smallrye.mutiny.Uni;
import it.pagopa.swclient.mil.auth.AuthErrorCode;
Expand Down Expand Up @@ -91,6 +92,7 @@ private Uni<Role> find(String acquirerId, String channel, String clientId, Strin
* @param terminalId
* @return
*/
@CacheResult(cacheName = "client-role")
public Uni<Role> findRoles(String acquirerId, String channel, String clientId, String merchantId, String terminalId) {
Log.tracef("Search (main) for the roles for acquirerId=%s, channel=%s, clientId=%s, merchantId=%s, terminalId=%s", acquirerId, channel, clientId, merchantId, terminalId);
return find(acquirerId, channel, clientId, merchantId, terminalId)
Expand Down
37 changes: 37 additions & 0 deletions src/test/k6/script-fixed-rate--50-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import http from 'k6/http';
import { sleep, check } from 'k6';

export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'constant-arrival-rate',
duration: '5m',
rate: 50,
timeUnit: '1s',
preAllocatedVUs: 400,
},
},
};

export default function() {
http.post(
"https://mil-d-auth-ca.agreeablestone-406ca858.westeurope.azurecontainerapps.io/token",
{
client_secret: "5ceef788-4115-43a7-a704-b1bcc9a47c86",
client_id: "3965df56-ca9a-49e5-97e8-061433d4a25b",
grant_type: "client_credentials"
},
{

headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'RequestId': "00000000-0000-0000-0000-100000000001",
'AcquirerId': "4585625",
'Channel': "POS",
'MerchantId': "28405fHfk73x88D",
'TerminalId': "01234567"
}
}
);
}
37 changes: 37 additions & 0 deletions src/test/k6/script-fixed-rate--60-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import http from 'k6/http';
import { sleep, check } from 'k6';

export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'constant-arrival-rate',
duration: '5m',
rate: 60,
timeUnit: '1s',
preAllocatedVUs: 1000,
},
},
};

export default function() {
http.post(
"https://mil-d-auth-ca.agreeablestone-406ca858.westeurope.azurecontainerapps.io/token",
{
client_secret: "5ceef788-4115-43a7-a704-b1bcc9a47c86",
client_id: "3965df56-ca9a-49e5-97e8-061433d4a25b",
grant_type: "client_credentials"
},
{

headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'RequestId': "00000000-0000-0000-0000-100000000001",
'AcquirerId': "4585625",
'Channel': "POS",
'MerchantId': "28405fHfk73x88D",
'TerminalId': "01234567"
}
}
);
}
37 changes: 37 additions & 0 deletions src/test/k6/script-fixed-rate--75-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import http from 'k6/http';
import { sleep, check } from 'k6';

export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'constant-arrival-rate',
duration: '5m',
rate: 75,
timeUnit: '1s',
preAllocatedVUs: 1000,
},
},
};

export default function() {
http.post(
"https://mil-d-auth-ca.agreeablestone-406ca858.westeurope.azurecontainerapps.io/token",
{
client_secret: "5ceef788-4115-43a7-a704-b1bcc9a47c86",
client_id: "3965df56-ca9a-49e5-97e8-061433d4a25b",
grant_type: "client_credentials"
},
{

headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'RequestId': "00000000-0000-0000-0000-100000000001",
'AcquirerId': "4585625",
'Channel': "POS",
'MerchantId': "28405fHfk73x88D",
'TerminalId': "01234567"
}
}
);
}

0 comments on commit 2bd7647

Please sign in to comment.