-
Notifications
You must be signed in to change notification settings - Fork 8
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
[DMS-92] Basic eTag creation #381
Conversation
@@ -20,6 +21,10 @@ public async Task Execute(PipelineContext context, Func<Task> next) | |||
DateTimeOffset utcNow = DateTimeOffset.UtcNow; | |||
string formattedUtcDateTime = utcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); | |||
context.ParsedBody["_lastModifiedDate"] = formattedUtcDateTime; | |||
context.ParsedBody["_etag"] = DateTime |
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 mimic'd the way ODS API generates etag.
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 do wonder if it would be better to generate etags from a hash of the document. Since DMS could be running on multiple servers, there's a teeny-tiny chance the clocks are out of sync in just the right way for different documents to have the same timestamp. Just something to think about.
using EdFi.DataManagementService.Core.Pipeline; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace EdFi.DataManagementService.Core.Middleware | ||
{ | ||
internal class InjectLastModifiedDateToEdFiDocumentMiddleware(ILogger _logger) : IPipelineStep | ||
internal class InjectVersionMetadataToEdFiDocumentMiddleware(ILogger _logger) : IPipelineStep |
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.
Good name change 😎
namespace EdFi.DataManagementService.Core.External.Model; | ||
|
||
// A string type branded as an Etag which uniquely identifies a specific version of a document | ||
public record struct Etag(string Value); |
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.
Nice
IUpsertRequest; | ||
IUpsertRequest | ||
{ | ||
} |
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.
Do we need this change?
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.
oops
@@ -16,7 +16,8 @@ public record UpsertResult | |||
/// A successful upsert request that took the form of an insert | |||
/// </summary> | |||
/// <param name="NewDocumentUuid">The DocumentUuid of the new document</param> | |||
public record InsertSuccess(DocumentUuid NewDocumentUuid) : UpsertResult(); | |||
/// <param name="Etag">The Etag of the new document</param> | |||
public record InsertSuccess(DocumentUuid NewDocumentUuid, Etag Etag) : UpsertResult(); |
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.
Does a backend really need to return it? Doesn't core set it?
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.
Good point.
5fb2e75
to
aa177b2
Compare
Definitely could be done. Couple thoughts
|
Good points. Let's just keep it in the back of our minds. |
No description provided.