api: Expose event_queue_longpoll_timeout_seconds in /register.

Rename poll_timeout to event_queue_longpoll_timeout_seconds
and change its value from 90000 ms to 90 sec. Expose its
value in register api response when realm data is fetched.
Bump API_FEATURE_LEVEL to 74.
This commit is contained in:
Gaurav Pandey 2021-06-04 18:42:37 +05:30 committed by Tim Abbott
parent 18ef0c3bc1
commit 9b696cf212
9 changed files with 35 additions and 7 deletions

View File

@ -211,7 +211,7 @@ function get_events({dont_block = false} = {}) {
url: "/json/events",
data: get_events_params,
idempotent: true,
timeout: page_params.poll_timeout,
timeout: page_params.event_queue_longpoll_timeout_seconds * 1000,
success(data) {
watchdog.set_suspect_offline(false);
try {

View File

@ -11,6 +11,12 @@ below features are supported.
## Changes in Zulip 5.0
**Feature level 74**
* [`POST /register`](/api/register-queue): Added `server_needs_upgrade`
and `event_queue_longpoll_timeout_seconds` field when fetching
realm data.
**Feature level 73**
* [`GET /users`](/api/get-users), [`GET /users/{user_id}`](/api/get-user),

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"
# Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md, as well as
# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.
API_FEATURE_LEVEL = 73
API_FEATURE_LEVEL = 74
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump

View File

@ -277,6 +277,9 @@ def fetch_initial_state_data(
state["giphy_rating_options"] = realm.GIPHY_RATING_OPTIONS
state["server_needs_upgrade"] = is_outdated_server(user_profile)
state[
"event_queue_longpoll_timeout_seconds"
] = settings.EVENT_QUEUE_LONGPOLL_TIMEOUT_SECONDS
# TODO: Should these have the realm prefix replaced with server_?
state["realm_push_notifications_enabled"] = push_notifications_enabled()

View File

@ -183,7 +183,6 @@ def build_page_params_for_home_page_load(
page_params = dict(
## Server settings.
test_suite=settings.TEST_SUITE,
poll_timeout=settings.POLL_TIMEOUT,
insecure_desktop_app=insecure_desktop_app,
login_page=settings.HOME_NOT_LOGGED_IN,
save_stacktraces=settings.SAVE_FRONTEND_STACKTRACES,

View File

@ -141,6 +141,13 @@ paths:
This endpoint allows you to receive new events from
[a registered event queue](/api/register-queue).
Long-lived clients should use the
`event_queue_longpoll_timeout_seconds` property returned by
`POST /register` as the client-side HTTP request timeout for
calls to this endpoint. It is guaranteed to be higher than
heartbeat frequency and should be respected by clients to
avoid breaking when heartbeat frequency increases.
parameters:
- $ref: "#/components/parameters/QueueId"
- name: last_event_id
@ -8986,6 +8993,19 @@ paths:
such that the web app will display to the current user a prominent warning.
**Changes**: New in Zulip 5.0 (feature level 74).
event_queue_longpoll_timeout_seconds:
type: integer
description: |
Present if `realm` is present in `fetch_event_types`.
Recommended client-side HTTP request timeout for [`GET /events`](/api/get-events) calls.
This is guaranteed to be somewhat greater than the heartbeat frequency. It is important
that clients respect this parameter, so that increases in the heartbeat frequency do not
break clients.
**Changes**: New in Zulip 5.0 (feature level 74). Previously,
this was hardcoded to 90 seconds, and clients should use that as a fallback
value when interacting with servers where this field is not present.
realm_notifications_stream_id:
type: integer
description: |

View File

@ -83,6 +83,7 @@ class HomeTest(ZulipTestCase):
"enable_stream_email_notifications",
"enable_stream_push_notifications",
"enter_sends",
"event_queue_longpoll_timeout_seconds",
"first_in_realm",
"fluid_layout_width",
"full_name",
@ -126,7 +127,6 @@ class HomeTest(ZulipTestCase):
"password_min_guesses",
"password_min_length",
"pm_content_in_desktop_notifications",
"poll_timeout",
"presence_enabled",
"presences",
"prompt_for_invites",

View File

@ -988,12 +988,12 @@ else:
LOGIN_REDIRECT_URL = "/"
# Client-side polling timeout for get_events, in milliseconds.
# Client-side polling timeout for get_events, in seconds.
# We configure this here so that the client test suite can override it.
# We already kill the connection server-side with heartbeat events,
# but it's good to have a safety. This value should be greater than
# (HEARTBEAT_MIN_FREQ_SECS + 10)
POLL_TIMEOUT = 90 * 1000
EVENT_QUEUE_LONGPOLL_TIMEOUT_SECONDS = 90
########################################################################
# SSO AND LDAP SETTINGS

View File

@ -63,7 +63,7 @@ if "BAN_CONSOLE_OUTPUT" in os.environ:
# Decrease the get_updates timeout to 1 second.
# This allows frontend tests to proceed quickly to the next test step.
POLL_TIMEOUT = 1000
EVENT_QUEUE_LONGPOLL_TIMEOUT_SECONDS = 1
# Stores the messages in `django.core.mail.outbox` rather than sending them.
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"