Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
semyon-dev committed Sep 13, 2024
1 parent 4287445 commit e5281d7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ linters:
- misspell
- unconvert
- typecheck
- errcheck
# - unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- goconst
- noctx
- whitespace
- revive # only certain checks enabled

Expand Down
2 changes: 1 addition & 1 deletion blockchain/orginzationMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func checkMandatoryFields(metaData *OrganizationMetaData) (err error) {
}

if metaData.recipientPaymentAddress == (common.Address{}) {
err = fmt.Errorf("Mandatory field : Recepient Address is missing for the Group %v ", metaData.daemonGroup.GroupName)
err = fmt.Errorf("Mandatory field : Recipient Address is missing for the Group %v ", metaData.daemonGroup.GroupName)
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion config/blockchain_network_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func deriveDatafromJSON(data []byte) (err error) {
networkSelected.RegistryAddressKey = fmt.Sprintf("%v", m[GetNetworkId()].(map[string]any)["address"])

zap.L().Info("Derive data from JSON", zap.String("Network", GetString(BlockChainNetworkSelected)),
zap.String("Netwrok id", GetNetworkId()),
zap.String("Network id", GetNetworkId()),
zap.String("Registry address", GetRegistryAddress()),
zap.String("Blockchain http endpoint", GetBlockChainHTTPEndPoint()),
zap.String("Blockchain ws endpoint", GetBlockChainWSEndPoint()),
Expand Down
2 changes: 1 addition & 1 deletion etcddb/etcddb_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func Reconnect(metadata *blockchain.OrganizationMetaData) (*EtcdClient, error) {
if err != nil {
return nil, err
}
zap.L().Info("Successful reconnet to new etcd endpoints", zap.Strings("New endpoints", metadata.GetPaymentStorageEndPoints()))
zap.L().Info("Successful reconnect to new etcd endpoints", zap.Strings("New endpoints", metadata.GetPaymentStorageEndPoints()))
return etcdClient, nil
}

Expand Down
1 change: 1 addition & 0 deletions handler/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (g grpcHandler) grpcToGRPC(srv any, inStream grpc.ServerStream) error {
}

outCtx, outCancel := context.WithCancel(inCtx)
defer outCancel()
outCtx = metadata.NewOutgoingContext(outCtx, md.Copy())
isModelTraining := g.serviceMetaData.IsModelTraining(method)
outStream, err := g.GrpcConn(isModelTraining).NewStream(outCtx, grpcDesc, method, grpc.CallContentSubtype(g.enc))
Expand Down
8 changes: 6 additions & 2 deletions metrics/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func getTokenFromResponse(response *http.Response) (string, bool) {
zap.L().Warn("Empty response received.")
return "", false
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
zap.L().Warn("Service call failed", zap.Int("StatusCode", response.StatusCode))
return "", false
Expand All @@ -187,9 +188,12 @@ func getTokenFromResponse(response *http.Response) (string, bool) {
return "", false
}
var data TokenGenerated
json.Unmarshal(body, &data)
err = json.Unmarshal(body, &data)
if err != nil {
zap.L().Error("Can't unmarshal TokenGenerated", zap.Error(err))
return "", false
}
//close the body
defer response.Body.Close()
return data.Data.Token, true
}

Expand Down

0 comments on commit e5281d7

Please sign in to comment.