-
Notifications
You must be signed in to change notification settings - Fork 675
[DB-2019] Add persistent subscriptions support for secondary indexes #5580
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
Open
alexeyzimarev
wants to merge
17
commits into
master
Choose a base branch
from
feat/persistent-subscriptions-secondary-indexes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
51fbf19
feat(persistent-subs): add PersistentSubscriptionIndexService and wir…
alexeyzimarev 7cf11bb
feat(persistent-subs): add gRPC filter hijack for index subscriptions
alexeyzimarev f0951a7
test(persistent-subs): add integration tests for index persistent sub…
alexeyzimarev 99a0608
fix(persistent-subs): add else branches to translating envelopes
alexeyzimarev 2720841
fix(persistent-subs): add type-check before cast in index read callback
alexeyzimarev 26c7409
fix(persistent-subs): call Delete() on index deletion to clean up str…
alexeyzimarev 43bb41b
fix(persistent-subs): add _started lifecycle guard to index service
alexeyzimarev d0fe754
fix(persistent-subs): call continueWith on save-path errors
alexeyzimarev 5426088
fix(persistent-subs): remove dead LoadConfiguration/HandleLoadCompleted
alexeyzimarev 9ad4a96
fix(persistent-subs): remove $index- prefix to fix SecondaryIndexDele…
alexeyzimarev 9a1deab
fix(persistent-subs): fix stale-config forwarding and save clobbering
alexeyzimarev 46407ef
fix(persistent-subs): detect ambiguous group names in forwarding
alexeyzimarev 13ca4cf
refactor(persistent-subs): replace boolean tristate with EventSourceK…
alexeyzimarev 30848c4
refactor(persistent-subs): seal PersistentSubscriptionIndexService an…
alexeyzimarev a687d09
fix(persistent-subs): use Warning log level for config save timeout
alexeyzimarev 58000d7
test(persistent-subs): add end-to-end integration tests proving event…
alexeyzimarev 513f448
fix(persistent-subs): throw on multi-prefix filter with index name
alexeyzimarev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/KurrentDB.Core/Services/PersistentSubscription/PersistentSubscriptionIndexEventSource.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright (c) Kurrent, Inc and/or licensed to Kurrent, Inc under one or more agreements. | ||
| // Kurrent, Inc licenses this file to you under the Kurrent License v1 (see LICENSE.md). | ||
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using KurrentDB.Core.Data; | ||
| using KurrentDB.Core.Services.Storage.ReaderIndex; | ||
|
|
||
| namespace KurrentDB.Core.Services.PersistentSubscription; | ||
|
|
||
| public sealed class PersistentSubscriptionIndexEventSource : IPersistentSubscriptionEventSource { | ||
| public EventSourceKind Kind => EventSourceKind.Index; | ||
| public string EventStreamId => throw new InvalidOperationException(); | ||
| public string IndexName { get; } | ||
| public IEventFilter EventFilter => null; | ||
|
|
||
| public PersistentSubscriptionIndexEventSource(string indexName) { | ||
| IndexName = indexName ?? throw new ArgumentNullException(nameof(indexName)); | ||
| } | ||
|
|
||
| public override string ToString() => IndexName; | ||
|
|
||
| public IPersistentSubscriptionStreamPosition StreamStartPosition => | ||
| new PersistentSubscriptionAllStreamPosition(0L, 0L); | ||
|
|
||
| public IPersistentSubscriptionStreamPosition GetStreamPositionFor(ResolvedEvent @event) { | ||
| if (@event.OriginalPosition.HasValue) { | ||
| return new PersistentSubscriptionAllStreamPosition( | ||
| @event.OriginalPosition.Value.CommitPosition, | ||
| @event.OriginalPosition.Value.PreparePosition); | ||
| } | ||
| throw new InvalidOperationException(); | ||
| } | ||
|
|
||
| public IPersistentSubscriptionStreamPosition GetStreamPositionFor(string checkpoint) { | ||
| const string C = "C:"; | ||
| const string P = "P:"; | ||
| string[] tokens = checkpoint.Split("/"); | ||
| Debug.Assert(tokens.Length == 2); | ||
| Debug.Assert(tokens[0].StartsWith(C)); | ||
| Debug.Assert(tokens[1].StartsWith(P)); | ||
| long commitPosition = long.Parse(tokens[0].Substring(C.Length)); | ||
| long preparePosition = long.Parse(tokens[1].Substring(P.Length)); | ||
| return new PersistentSubscriptionAllStreamPosition(commitPosition, preparePosition); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
1. ...toindex ctor lacks validation
📘 Rule violation≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools