sebastienros / yessql

A .NET document database working on any RDBMS
MIT License
1.17k stars 195 forks source link

Open some events for external subscription #547

Open hyzx86 opened 2 months ago

hyzx86 commented 2 months ago

Currently we have some events open in OC, but those are not enough, some events may be an intermediate process,

for example, we get an object and try UpdateAsync first, the object state is then saved to the state manager. Then call some validation function ValidateAsync in OC Then publish it

https://github.com/OrchardCMS/OrchardCore/blob/dcf83bca479ad06eeb41b9a09292a67fa26a2b21/src/OrchardCore.Modules/OrchardCore.Contents/Endpoints/Api/CreateEndpoint.cs#L59-L120

We cannot tell if a Save is the last one to be committed to the database

So my suggestion is to expose some events externally through YesSql's series of IIndexCmmand types Used to notify external programs that the object has been committed to the database, You can perform subsequent operations

For example, update the Lucene index and create a custom index table (this is what I am working on 😅 )

hyzx86 commented 2 months ago

Hi @Skrypt , There's a similar problem here, right? An index action may be performed multiple times on the same document when updating a piece of content.

https://github.com/OrchardCMS/OrchardCore/blob/dcf83bca479ad06eeb41b9a09292a67fa26a2b21/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Handler/LuceneIndexingContentHandler.cs#L29-L33

Skrypt commented 1 day ago

Good question. Normally it should not. I never saw this execute twice yet. Maybe something has changed. If we index multiple times then it is a strong performance issue.