From 2545c4158fd70de1e7323c6b1f4be9ce1444a17b Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Tue, 17 Dec 2024 17:39:03 +0100 Subject: [PATCH] Add comment Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/encoder/MoshiEncodeStrategy.groovy | 6 +++--- .../groovy/io/seqera/wave/tower/client/TowerClient.groovy | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/encoder/MoshiEncodeStrategy.groovy b/src/main/groovy/io/seqera/wave/encoder/MoshiEncodeStrategy.groovy index 3fda40797..97e26fbc6 100644 --- a/src/main/groovy/io/seqera/wave/encoder/MoshiEncodeStrategy.groovy +++ b/src/main/groovy/io/seqera/wave/encoder/MoshiEncodeStrategy.groovy @@ -51,7 +51,7 @@ abstract class MoshiEncodeStrategy implements EncodingStrategy { MoshiEncodeStrategy() { this.type = TypeHelper.getGenericType(this, 0) - init(null) + init() } MoshiEncodeStrategy(JsonAdapter.Factory customFactory) { @@ -61,10 +61,10 @@ abstract class MoshiEncodeStrategy implements EncodingStrategy { MoshiEncodeStrategy(Type type) { this.type = type - init(null) + init() } - private void init(JsonAdapter.Factory customFactory) { + private void init(JsonAdapter.Factory customFactory=null) { final builder = new Moshi.Builder() .add(new ByteArrayAdapter()) .add(new DateTimeAdapter()) diff --git a/src/main/groovy/io/seqera/wave/tower/client/TowerClient.groovy b/src/main/groovy/io/seqera/wave/tower/client/TowerClient.groovy index 2b42291b6..fea72ad6a 100644 --- a/src/main/groovy/io/seqera/wave/tower/client/TowerClient.groovy +++ b/src/main/groovy/io/seqera/wave/tower/client/TowerClient.groovy @@ -69,12 +69,16 @@ class TowerClient { UserInfoResponse userInfo(String towerEndpoint, JwtAuth authorization) { final uri = userInfoEndpoint(towerEndpoint) final k = makeKey(uri, authorization.key, null, null) + // NOTE: it assumes the user info metadata does nor change over time + // and therefore the *long* expiration cached is used get0(uri, towerEndpoint, authorization, UserInfoResponse, k, CacheMode.LONG) as UserInfoResponse } ListCredentialsResponse listCredentials(String towerEndpoint, JwtAuth authorization, Long workspaceId, String workflowId) { final uri = listCredentialsEndpoint(towerEndpoint, workspaceId) final k = makeKey(uri, authorization.key, workspaceId, workflowId) + // NOTE: when the 'workflowId' is provided it assumes credentials will not change during + // the workflow execution and therefore the *long* expiration cached is used final mode = workflowId ? CacheMode.LONG : CacheMode.SHORT return get0(uri, towerEndpoint, authorization, ListCredentialsResponse, k, mode) as ListCredentialsResponse } @@ -82,6 +86,8 @@ class TowerClient { GetCredentialsKeysResponse fetchEncryptedCredentials(String towerEndpoint, JwtAuth authorization, String credentialsId, String pairingId, Long workspaceId, String workflowId) { final uri = fetchCredentialsEndpoint(towerEndpoint, credentialsId, pairingId, workspaceId) final k = makeKey(uri, authorization.key, workspaceId, workflowId) + // NOTE: when the 'workflowId' is provided it assumes credentials will not change during + // the workflow execution and therefore the *long* expiration cached is used final mode = workflowId ? CacheMode.LONG : CacheMode.SHORT return get0(uri, towerEndpoint, authorization, GetCredentialsKeysResponse, k, mode) as GetCredentialsKeysResponse } @@ -124,6 +130,8 @@ class TowerClient { DescribeWorkflowLaunchResponse describeWorkflowLaunch(String towerEndpoint, JwtAuth authorization, String workflowId) { final uri = workflowLaunchEndpoint(towerEndpoint,workflowId) final k = makeKey(uri, authorization.key, null, workflowId) + // NOTE: it assumes the workflow launch definition cannot change for the specified 'workflowId' + // and therefore the *long* expiration cached is used return get0(uri, towerEndpoint, authorization, DescribeWorkflowLaunchResponse.class, k, CacheMode.LONG) as DescribeWorkflowLaunchResponse }