SAP / SAP/btp-environment-variable-access
Feat: Implement Listener for Cache Renewals
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 24
- Forks
- 13
- Avg merge
- 4h 35m
- Merged PRs (30d)
- 5
Description
Context
Some applications / libraries perform (heavy) calculations on the service bindings returned from the ServiceBindingAccessor.
For example, service bindings should be transformed into an application internal representation.
To safe computational overhead, applications may want to cache their internal objects instead of doing the transformation each and every time when they access ServiceBindingAccess#getBindings.
Unfortunately, by doing so, application might be out of sync with the actual service bindings.
Request
It would be great if applications would get notified whenever a new set of service bindings is created / returned by a ServiceBindingAccessor instance.
Suggestions
Workaround proposal:
@RequiredArgsConstructor
class ServiceBindingTransformer {
@Nonnull
private final ServiceBindingAccessor delegate;
@Nullable
private List<ServiceBinding> lastServiceBindings;
@Nullable
private List<MyTransformedServiceBinding> transformedBindings;
@Nonnull
public List<MyTransformedServiceBinding> getTransformedBindings()
{
final List<ServiceBinding> currentServiceBindings = delegate.getServiceBindings();
if (currentServiceBindings != lastServiceBindings || transformedBindings == null)
{
// this will only be done in case the bindings were not served from a cache
transformedBindings = transformBindings(currentServiceBindings);
lastServiceBindings = currentServiceBindings;
}
return transformedBindings;
}
private List<MyTransformedServiceBinding> transformBindings(@Nonnull final List<ServiceBinding> bindings)
{
// TODO: implement me
}
}
private static class MyTransformedServiceBinding {
}
Questions
- How do we solve the multi-level caching? (e.g. K8s file system cache and simple cache)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ServiceBindingAccessor#getServiceBindings and trace how service bindings are created, returned, and cached. Define how applications are notified when a new set is returned, including the multi-level caching question described in the issue. Done means the listener behavior and cache-renewal semantics are specified and implemented with coverage for the relevant cache paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100