-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-5205: Add option to configure DEK cache lifetime #1614
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
Conversation
@sanych-sun there are two things I'm not super convinced:
(I also need to add input validation to be sure that the number of milliseconds isn't negative) |
/// <summary> | ||
/// Gets the value of the expiration time for the DEK cache in ms. | ||
/// </summary> | ||
public long? DekCacheLifetimeMs { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a compelling reason to use a long here instead of a TimeSpan? .NET typically prefers TimeSpans for durations as they're easier to configure in terms of code and you don't need suffixes then like "Ms" on the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue here would be that TimeSpan
has a greater granularity (microseconds) than the corresponding input for libmongocrypt (milliseconds).
We could also approximate the value if microseconds are used, but I'm not super convinced. I agree that maybe it would be easier to read with TimeSpan
, even though more verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we should use TimeSpan. And pass TotalMilliseconds portion of it to libmongocrypt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, or we could also throw an exception if there is microseconds.
/// <summary> | ||
/// Gets the value of the expiration time for the DEK cache in ms. | ||
/// </summary> | ||
public long? DekCacheLifetimeMs { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we should use TimeSpan. And pass TotalMilliseconds portion of it to libmongocrypt.
@damieng @sanych-sun I've changed the name to |
Please also rebase to let tests run on latest and rapid variants. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM + minor comments.
Also I do not like SetKeyExpiration
method, but have no better suggestions to it. Please get somebody else opinion/suggestion on it.
|
||
/// <summary> | ||
/// Sets the data encryption key cache expiration time. If not set, it defaults to 60 seconds. | ||
/// If set to 0, the cache never expires. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we mention TimeSpan.Zero
instead of 0
? Here and in AutoEncryptionOptions
class as well.
IMongoClient keyVaultClient = null; | ||
CollectionNamespace keyVaultCollectionNamespace = null; | ||
IReadOnlyDictionary<string, IReadOnlyDictionary<string, object>> kmsProviders = null; | ||
long? keyExpirationMs = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I would use TimeSpan?
here instead. To eliminate that pattern matching in line 760.
No description provided.