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 DB and docker #2

Merged
merged 20 commits into from
Feb 25, 2024
Merged

Add DB and docker #2

merged 20 commits into from
Feb 25, 2024

Conversation

polshe-v
Copy link
Owner

Added:

  • DB logic in service
  • Deploy service and DB in docker
  • Configuration files for service
  • DB migrations

@polshe-v polshe-v marked this pull request as ready for review February 23, 2024 11:57
@polshe-v polshe-v requested a review from olezhek28 February 23, 2024 11:58
cmd/user/main.go Outdated

query, args, err := builderInsert.ToSql()
if err != nil {
log.Fatalf("failed to build query: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ронять прод не очень хорошее дело))

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила Fatalf на просто печать сообщения и возврат ошибки без завершения работы приложения.

cmd/user/main.go Outdated
// Hashing the password.
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(req.GetPassword()), bcryptCost)
if err != nil {
panic(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

сомнительно конечно панику кидать, лучше ошибку вернуть)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила panic на просто печать сообщения и возврат ошибки без завершения работы приложения.

cmd/user/main.go Outdated
if err != nil {
log.Fatalf("failed to generate ID: %v", err)
log.Fatalf("failed to create user: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила Fatalf на просто печать сообщения и возврат ошибки без завершения работы приложения.

cmd/user/main.go Outdated

query, args, err := builderSelect.ToSql()
if err != nil {
log.Fatalf("failed to build query: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила Fatalf на просто печать сообщения и возврат ошибки без завершения работы приложения.

cmd/user/main.go Outdated
if err == pgx.ErrNoRows {
return nil, err
}
log.Fatalf("failed to select user: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила Fatalf на просто печать сообщения и возврат ошибки без завершения работы приложения.

cmd/user/main.go Outdated

query, args, err := builderUpdate.ToSql()
if err != nil {
log.Fatalf("failed to build query: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила Fatalf на просто печать сообщения и возврат ошибки без завершения работы приложения.

cmd/user/main.go Outdated

s.pool.QueryRow(ctx, query, args...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

а ошибку обработать?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила на Exec с последующей обработкой ошибки.

cmd/user/main.go Outdated
log.Fatalf("failed to build query: %v", err)
}

s.pool.QueryRow(ctx, query, args...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила на Exec с последующей обработкой ошибки.

cmd/user/main.go Outdated

query, args, err := builderDelete.ToSql()
if err != nil {
log.Fatalf("failed to build query: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Заменила Fatalf на просто печать сообщения и возврат ошибки без завершения работы приложения.

@polshe-v polshe-v merged commit 201ffda into master Feb 25, 2024
4 checks passed
@polshe-v polshe-v deleted the dev_2 branch February 25, 2024 15:27
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