microsoft / azure-spring-boot

Spring Boot Starters for Azure services
MIT License
374 stars 460 forks source link

Option to set TTL on Container level using azure spring boot starter cosmos #875

Closed ssrm closed 4 years ago

ssrm commented 4 years ago

Environment

Summary

I am using azure-cosmosdb-spring-boot-starter: 2.2.4 and looking for an option to set TTL on container level. Is there any such thing available currently? At-least I didn't find any documentation.

If we can do that using application.properties, can someone share how we can get that? If not can we get that implemented?

Reproduce steps

Expected Results

Actual Results

saragluna commented 4 years ago

Thanks for reaching out and we'll investigate this.

ssrm commented 4 years ago

Any update?

yiliuTo commented 4 years ago

Hi @ssrm , the cosmosdb sdk we depend on does not provide the feature that sets TTL on container level and destroys items according to it. Besides, we think the TTL parameter is usually maintained by the server not the client.

If you think the feature is necessary then could you share your case and requirement for the reason to set TTL on container level by client?

ssrm commented 4 years ago

Hi @yiliuTo ,

Thanks for your reply.

We create containers/documents from java applications. I think most people do this way. We can set document level TTL, but which is applicable only when there is container level TTL set. As per Azure Docs : https://docs.microsoft.com/en-us/azure/cosmos-db/time-to-live#time-to-live-for-containers-and-items

By saying Azure Cosmos provides Java SDK to create container with TTL, as per the below doc:

https://docs.microsoft.com/en-us/azure/cosmos-db/migrate-java-v4-sdk?tabs=java-v4-async#container-level-time-to-livettl

yiliuTo commented 4 years ago

Hi @ssrm . Please ignore my last comment because I just found that the spring data cosmos repo provides TTL on container level by using the annotation @Document. Sorry for my mistake and for more detailed information you can refer to the PR and issue.

Besides, you mentioned that you'd like to set TTL by application.properties, is it a requirement or only a suggestion?

ssrm commented 4 years ago

I am using 2.2.4, which didnt pull the fix for some reason, by upgrading to 2.3.1 I did see source code with a fix(need to test). Based on the code what I understand, if document level set it just enables the container level ttl.

I thought, it would be nice to have thing if we can set TTL via application properties. Not sure, if its already doing it.

yiliuTo commented 4 years ago

According to the discussion in this pr, I think @Document can help set TTL on container level. However, currently we don't have the plan to provide another implementation of setting TTL via application.properties since this feature has been satisfied via annotation.

If we are going to provide this feature via application.properties, we will update it here. Thanks for your reporting.