Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Dec 17, 2024
1 parent 5479e20 commit 2545c41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class MoshiEncodeStrategy<V> implements EncodingStrategy<V> {

MoshiEncodeStrategy() {
this.type = TypeHelper.getGenericType(this, 0)
init(null)
init()
}

MoshiEncodeStrategy(JsonAdapter.Factory customFactory) {
Expand All @@ -61,10 +61,10 @@ abstract class MoshiEncodeStrategy<V> implements EncodingStrategy<V> {

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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,25 @@ 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
}

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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 2545c41

Please sign in to comment.