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

Query redis #5

Merged
merged 22 commits into from
Apr 20, 2024
Merged

Query redis #5

merged 22 commits into from
Apr 20, 2024

Conversation

EvSedov
Copy link
Owner

@EvSedov EvSedov commented Apr 16, 2024

Добавили возможность работы со storage и заимплементили redis.

err = r.Ping(ctx)
return err
func (r *Storage) Ping(ctx context.Context) error {
result, err := r.Client.Ping().Result() // Использование Ping из библиотеки go-redis
Copy link
Owner Author

Choose a reason for hiding this comment

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

А для чего нам result? Можно же обойтись только ошибкой err := r.Client.Ping().Err() ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Возвращаемое значение result: Это значение обычно содержит строку "Pong", если запрос Ping успешно выполнен. Это стандартный ответ от сервера Redis, подтверждающий, что соединение активно. Хотя для проверки соединения достаточно знать, прошёл ли пинг без ошибок, запись ответа в логи может быть полезна для диагностики и подтверждения того, что сервер Redis функционирует как ожидается.

return err
func (r *Storage) Ping(ctx context.Context) error {
result, err := r.Client.Ping().Result() // Использование Ping из библиотеки go-redis
if err != nil {
Copy link
Owner Author

Choose a reason for hiding this comment

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

А тут нужно залогировать ошибку перед ее возвратом.

Copy link
Collaborator

@MajotraderLucky MajotraderLucky Apr 17, 2024

Choose a reason for hiding this comment

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

if err != nil { // Логирование ошибки с подробным описанием if err != nil { logger.Log.Fatal("Ошибка соединения с Redis", zap.Error(err))

Мы же итак логируем ошибку? Или что ты имеешь в виду?

ryazanovs added 15 commits April 18, 2024 23:57
FindKeysByPattern function
FindKeyByGetRequest function
functions

This commit enhances the HTTP response utility functions with detailed logging at various stages of response handling. The following changes have been implemented:

1. Added informative logging statements before attempting to send HTTP responses in functions: RespondWith400, RespondWith404, RespondWith500, SuccessRespondWith200, and SuccessRespondWith201. These logs provide insights into the intended response status and content.

2. Included error logging to capture and report failures during the response sending process in all the aforementioned functions. This is crucial for diagnosing serialization issues, network problems, or server-side errors that might prevent successful response delivery.

3. Each function now logs successful responses, ensuring that there is a clear trace of successful operations and the exact content delivered in the response.

These additions aim to improve monitoring, facilitate debugging, and enhance the overall reliability of the web service by providing better visibility into its operations and failures.
@MajotraderLucky MajotraderLucky merged commit 4fe53ea into main Apr 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants