Skip to content
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

Add connection health check #152

Merged
merged 11 commits into from
Jul 4, 2024
Merged

Add connection health check #152

merged 11 commits into from
Jul 4, 2024

Conversation

podliashanyk
Copy link
Contributor

Closes #145

@podliashanyk podliashanyk added bug Something isn't working beta Part of beta release labels Jul 4, 2024
@podliashanyk podliashanyk requested a review from hmpf July 4, 2024 12:01
@podliashanyk podliashanyk self-assigned this Jul 4, 2024
Comment on lines 556 to 572
@main.route('/test_connection')
def test_conn():
is_connection_ok = test_zino_connection()
caller_id = request.headers.get('HX-Target', None)
if not is_connection_ok:
current_app.logger.debug('Connection test failed showing error appbar')
return render_template('components/feedback/connection-status-bar/error-appbar-content.html',
error_message="Connection to Zino server is lost")
if caller_id == 'connection-error-content': # If connection should be restored after error
current_app.logger.debug('Connection test OK, caller ID %s', caller_id)
reconnect_to_zino()
return render_template('components/feedback/connection-status-bar/success-appbar-content.html')
else:
current_app.logger.debug('Connection test OK, caller ID %s', caller_id)
return render_template('components/feedback/connection-status-bar/success-appbar-content.html')


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polish for later: a link zabbix and similar can visit to check health. Need only return http status codes: 200 or 50x.

Comment on lines 115 to 118
is_connection_ok = test_zino_connection()
if is_connection_ok is not False: # Both True or None are OK
reconnect_to_zino()
short_err_msg = 'Temporarily lost connection to Zino server, please retry your action'
Copy link
Contributor

@hmpf hmpf Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uuuh.. reconnect if the connection is ok? Did you mean if is_connection_ok is False:?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deliberate. This code is in handle_lost_connection, so the connection was down when it was called. Here we check if connection is back again. reconnect_to_zino means "ensure a clean reconnect procedure", I will add some comments with explanations

@podliashanyk podliashanyk requested a review from hmpf July 4, 2024 12:45
Copy link
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, will test

@podliashanyk podliashanyk merged commit 815747d into main Jul 4, 2024
5 checks passed
@podliashanyk podliashanyk deleted the add-connection-health-check branch July 4, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Part of beta release bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test connection to Zino server every X seconds
2 participants