Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/kv store #4217

Merged
merged 3 commits into from
Jul 5, 2024
Merged

Feat/kv store #4217

merged 3 commits into from
Jul 5, 2024

Conversation

brian-mulier-p
Copy link
Member

@brian-mulier-p brian-mulier-p commented Jul 3, 2024

part of #3609
closes #4232

Copy link

sonarcloud bot commented Jul 5, 2024

@brian-mulier-p brian-mulier-p merged commit 3272e1a into develop Jul 5, 2024
9 checks passed
@brian-mulier-p brian-mulier-p deleted the feat/kv-store branch July 5, 2024 16:32
Copy link
Member

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think creating an INernalKvStore everywhere is not a good idea, the code should use the KvStore interface everywhere and the implementation should be hidden.
Maybe a service can hide this?

@@ -67,7 +71,12 @@ default boolean exists(String tenantId, URI uri) {
FileAttributes getAttributes(String tenantId, URI uri) throws IOException;

@Retryable(includes = {IOException.class})
URI put(String tenantId, URI uri, InputStream data) throws IOException;
default URI put(String tenantId, URI uri, InputStream data) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to deprecate this one an always create the metadata? This can be handy for other functionalities.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk since we never ever used metadata before maybe it's a better approach to leave it as-is and use the metadata one when there is a usecase for it ?

@Parameter(description = "The key") @PathVariable String key,
@Body String value
) throws IOException, URISyntaxException, ResourceExpiredException {
String ttl = httpHeaders.get("ttl");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have add a parameter like for everything else as headers are usually for "technical stuff" and here TTL is a property of a KV.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to include the ttl in the body as it will be a pain to handle all the datatypes (I'll have to get everything as a String, check if that some json value, I'll probably lose some typing if I have a JSON wrapper everytime as in theory I then must have always a MediaType JSON then but then I was basing off that to know if I should convert to object then back to ion.

So a bit of technical constraint but aside of that I honestly don't see a true issue in ttl being in headers. I mean we store it in metadata in storage and I've already seen a lot of soft that are expecting such properties in headers 🤔

if (expirationDate != null && Instant.now().isAfter(expirationDate)) {
this.delete(key);

throw new ResourceExpiredException("The requested value has expired");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought expiration is a natural behavior?
In this case I expect to return an empty optional (and maybe delete the kv).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk I find it handy to know that the resource used to be there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Potential enhancements to KV Store
2 participants