Skip to content

Conversation

@syols
Copy link
Owner

@syols syols commented Dec 14, 2022

No description provided.

Copy link

@bambruysk bambruysk left a comment

Choose a reason for hiding this comment

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

Нужно дорабоать в части возврата ошибок из grpc

config/config.go Outdated

func withGrpcAddress(address string) Option {
return func(s *Config) {
if host, port, err := net.SplitHostPort(address); err == nil {

Choose a reason for hiding this comment

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

Слишком большая вложенность - это не go-way. Лучше классическое if err != nil {return}


message UpdateMetricResponse {
MetricMessage metric = 1;
string error = 2;

Choose a reason for hiding this comment

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

лучше для возвращения ошибки bспользовать библиотеку grpc/status


message MetricMessage {
string name = 1;
string type = 2;

Choose a reason for hiding this comment

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

type лучше задать как enum

message MetricMessage {
string name = 1;
string type = 2;
optional uint64 counter = 3;

Choose a reason for hiding this comment

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

А здесь явно напрашиввается oneof - тогда и type не нужен

log.Fatal(err)
}

defer func(conn *grpc.ClientConn) {

Choose a reason for hiding this comment

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

А зачем его сразу закрывать?

Copy link

@bambruysk bambruysk left a comment

Choose a reason for hiding this comment

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

Принято

var response pb.UpdateMetricResponse

err := metric.Check()
if err, ok := err.(validator.ValidationErrors); ok {

Choose a reason for hiding this comment

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

А если это не ошибка валидации, а еще какая-то? Нет я догадываются тчо другиз там и нет, но тогда зачем это приведение? Подозрительнгео место

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