-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat(subscriptions): Use RPC in subscriptions pipeline #6499
base: master
Are you sure you want to change the base?
feat(subscriptions): Use RPC in subscriptions pipeline #6499
Conversation
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
snuba/subscriptions/data.py
Outdated
rounded_ts = ( | ||
int(timestamp.replace(tzinfo=UTC).timestamp() / self.time_window_sec) | ||
* self.time_window_sec | ||
) |
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.
hack for now, we want to round this to the lowest available granularity (15s) more context here
snuba/subscriptions/data.py
Outdated
if (self.request_name, self.request_version) not in REQUEST_TYPE_ALLOWLIST: | ||
raise InvalidSubscriptionError( | ||
f"{self.request_name} {self.request_version} not supported." | ||
) | ||
|
||
# TODO: Validate no group by, having, order by etc |
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'll add more validation in a follow up so it's easier to review
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.
Why can the create subscription RPC call not be its own PR?
@volokluev Creating a subscription requires validation, so I needed to build and run the request before storing it. That introduces the RPCSubscriptionData class. And basically once I introduced it in one place, I kinda had to follow all the typing issues and handle it everywhere. |
@@ -95,7 +104,7 @@ def from_string(cls, value: str) -> SubscriptionIdentifier: | |||
|
|||
|
|||
@dataclass(frozen=True, kw_only=True) | |||
class SubscriptionData(ABC): | |||
class _SubscriptionData(ABC, Generic[TRequest]): |
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.
build_request
returns generic type TRequest
and run_query
accepts TRequest
.
So for SnQLSubscriptionData, build_request
returns Request
and run_query
accepts Request
and for RPCSubscriptionData, build_request
returns TimeSeriesRequest
and run_query
accepts TimeSeriesRequest
Updates the subscription pipeline to support RPCSubscriptionData.