-
Notifications
You must be signed in to change notification settings - Fork 0
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
Query redis #5
Conversation
FindKeysByPattern function for finding date in to the redis
from main.go to README.md file in the storage package
FindKeyByGetRequest functions, made changes to the README file
internal/storage/redis/storage.go
Outdated
err = r.Ping(ctx) | ||
return err | ||
func (r *Storage) Ping(ctx context.Context) error { | ||
result, err := r.Client.Ping().Result() // Использование Ping из библиотеки go-redis |
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.
А для чего нам result
? Можно же обойтись только ошибкой err := r.Client.Ping().Err()
?
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.
Возвращаемое значение 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 { |
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.
А тут нужно залогировать ошибку перед ее возвратом.
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 err != nil { // Логирование ошибки с подробным описанием if err != nil { logger.Log.Fatal("Ошибка соединения с Redis", zap.Error(err))
Мы же итак логируем ошибку? Или что ты имеешь в виду?
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.
internal/app package
Добавили возможность работы со
storage
и заимплементилиredis
.