package customer_clients import ( "context" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/customer" ) type CustomersClientDeps struct { Logger *zap.Logger CustomerServiceHost string } type CustomersClient struct { logger *zap.Logger customerServiceHost string } func NewCustomersClient(deps CustomersClientDeps) *CustomersClient { return &CustomersClient{ logger: deps.Logger, customerServiceHost: deps.CustomerServiceHost, } } func (receiver *CustomersClient) SetVerifyAccount(ctx context.Context, req *customer.SetVerificationReq) (*customer.Account, error) { connection, err := grpc.Dial(receiver.customerServiceHost, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { receiver.logger.Error("failed to connect on of ", zap.Error(err), zap.String("customer host", receiver.customerServiceHost)) return nil, err } defer func() { if closeErr := connection.Close(); closeErr != nil { receiver.logger.Error("failed to close connection on of ", zap.Error(closeErr)) } }() client := customer.NewCustomerServiceClient(connection) account, err := client.SetAccountVerificationStatus(ctx, req) if err != nil { receiver.logger.Error("failed Set Account Verification Status on of ", zap.Error(err)) return nil, err } return account, nil }