-
Notifications
You must be signed in to change notification settings - Fork 820
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
RavenDB-22176 Exposing notifications via GET endpoint #18318
Conversation
|
||
namespace Raven.Server.NotificationCenter.Handlers | ||
{ | ||
public class DatabaseNotificationCenterHandler : DatabaseRequestHandler | ||
{ | ||
[RavenAction("/databases/*/notification-center/get", "GET", AuthorizationStatus.ValidUser, EndpointType.Read, SkipUsagesCount = true)] |
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'd change the path to /databases/*/notification-center/notifications
or something similar
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 don't like 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.
On the other hand /get
matches other paths in this handler, so maybe it should stay like this
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.
GET /databases/notifications
public class RavenDB_22176 : RavenDB_17068 | ||
{ | ||
[RavenFact(RavenTestCategory.Indexes)] | ||
public async Task GetCurrentNotificationsAsJson() |
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.
Maybe something like TestGetNotificationsEndpoint
would be more descriptive
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
42eba9e
to
d36797d
Compare
|
||
namespace Raven.Server.NotificationCenter.Handlers | ||
{ | ||
public class DatabaseNotificationCenterHandler : DatabaseRequestHandler | ||
{ | ||
[RavenAction("/databases/*/notification-center/get", "GET", AuthorizationStatus.ValidUser, EndpointType.Read, SkipUsagesCount = true)] | ||
public async Task GetNotifications() | ||
{ |
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.
Please provide parameter to determine type of notifications to get (alerts, performance hints)
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
{ | ||
var postponed = GetBoolValueQueryString("postponed", required: false) ?? true; | ||
var type = GetStringQueryString("type", false); | ||
var shouldFilter = type != null && Enum.TryParse(typeof(NotificationType), type, out _); |
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.
If we cannot parse we should throw instead of silently ignoring that
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
e41f394
to
cf019a0
Compare
|
||
namespace Raven.Server.NotificationCenter.Handlers | ||
{ | ||
public class DatabaseNotificationCenterHandler : DatabaseRequestHandler | ||
{ | ||
[RavenAction("/databases/*/notification-center/get", "GET", AuthorizationStatus.ValidUser, EndpointType.Read, SkipUsagesCount = true)] |
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.
GET /databases/notifications
src/Raven.Server/NotificationCenter/Handlers/DatabaseNotificationCenterHandler.cs
Outdated
Show resolved
Hide resolved
{ | ||
public RavenDB_17068(ITestOutputHelper output) : base(output) | ||
public RavenDb17068(ITestOutputHelper output) : base(output) |
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.
:(
@@ -18,9 +18,9 @@ | |||
|
|||
namespace SlowTests.Issues; | |||
|
|||
public class RavenDB_17068: RavenTestBase | |||
public sealed class RavenDb17068: RavenDB_17068_Base |
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.
can you fix the name, revert 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.
this will mess up with test history on CI
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.
Unintentional, sorry!
isFirst = false; | ||
} | ||
|
||
writer.WriteEndArray(); |
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'm missing paging, would love to have sth like TotalCount or TotalResults and even in-memory paging here with optimization that pageSize=0 will just return count, like we have for regular queries
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 :)
var pageSize = GetIntValueQueryString("pageSize", required: false) ?? int.MaxValue; | ||
|
||
var shouldFilter = type != null; | ||
if (shouldFilter && Enum.TryParse(typeof(NotificationType), type, out _) == false) |
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.
NotificationType
enum is quite big:
ravendb/src/Raven.Server/NotificationCenter/Notifications/NotificationType.cs
Lines 3 to 13 in 3bd416c
public enum NotificationType | |
{ | |
None, | |
AlertRaised, | |
OperationChanged, | |
DatabaseChanged, | |
NotificationUpdated, | |
RecentError, // used in studio | |
PerformanceHint, | |
DatabaseStatsChanged, | |
ClusterTopologyChanged |
And the only relevant values here are AlertRaised
and PerformanceHint
, right? (because only those are persisted). I wonder if we should use this enum. Maybe better to have support for type=[alert|performance-hint]
? @ppekrol?
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 prefer to go with enum, but you are correct, this one is not good. Can we introduce a new one? Maybe even with [Flags] attribute, so we can pick multiple ones?
…s for `RavenDB_17068` and `RavenDB_22176` tests to avoid repeating tests.
…persist test history in CI | Added the ability to retrieve notifications in a paging fashion.
01a5851
to
4852b50
Compare
4852b50
to
4802944
Compare
Issue link
https://issues.hibernatingrhinos.com/issue/RavenDB-22176
Additional description
Type of change
How risky is the change?
Backward compatibility
Is it platform specific issue?
Documentation update
Documentation Required
tag.Testing by Contributor
private
)Testing by RavenDB QA team
QA Required
tag.Is there any existing behavior change of other features due to this change?
UI work
Studio Required
tag.