-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement extra properties/soft-deleting features #23
base: master
Are you sure you want to change the base?
Implement extra properties/soft-deleting features #23
Conversation
e423582
to
05449a7
Compare
@@ -23,7 +23,8 @@ public async Task InvokeAsync( | |||
if (context.Result is TPayload result) | |||
{ | |||
BewitToken<TPayload> bewit | |||
= await tokenGenerator.GenerateBewitTokenAsync(result, context.RequestAborted); | |||
= await tokenGenerator.GenerateBewitTokenAsync( | |||
result, context.RequestAborted, context.GetBewitTokenExtraProperties()); |
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.
cancellationtoken should be the last parameter
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.
done
@@ -29,7 +29,7 @@ public async Task InvokeAsync( | |||
|
|||
BewitToken<string> bewit = | |||
await tokenGenerator.GenerateBewitTokenAsync( | |||
uri.PathAndQuery, context.RequestAborted); | |||
uri.PathAndQuery, context.RequestAborted, context.GetBewitTokenExtraProperties()); |
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.
cancellationToken should be the last parameter
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.
done
} | ||
|
||
public async ValueTask InsertOneAsync( | ||
Token token, CancellationToken cancellationToken) | ||
{ | ||
if (token.ExtraProperties != 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.
we should not create indexes in CRUD methods, as this doubles our calls to the mongoDB.
If the extra properties can not be prediced on startup, we should skip index creations for them altogether.
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 would leave it as is. The MongoDB.Driver is smart enough:
- it makes a call on GetCollection and caches all index info on the client.
- It doesn't make an additional call if we try to create an already existing index.
- _collection.Indexes.CreateOne doesn't create the index immediately; it will be done on the server side asynchronously.
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 have changed the logic. The indexes can be created for values of primitive types. The complex type values will be sterilized to json string
@@ -38,24 +41,51 @@ public MongoNonceRepository(IMongoDatabase database, MongoNonceOptions options) | |||
|
|||
_collection.Indexes.CreateOne(new CreateIndexModel<Token>( | |||
Builders<Token>.IndexKeys.Ascending(nameof(IdentifiableToken.Identifier)))); | |||
|
|||
_collection.Indexes.CreateOne(new CreateIndexModel<Token>( |
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.
compound index can be removed (nonce being already unique)
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.
removed
9811d7c
to
14ad842
Compare
14ad842
to
2e39409
Compare
ad2428a
to
bb2ec06
Compare
4cfb51a
to
aae8ab7
Compare
Resolves #22