Skip to content

Commit

Permalink
feat: Improve code to fix linter warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Zhao <[email protected]>
  • Loading branch information
sczyh30 committed Nov 22, 2022
1 parent a010267 commit d8c0de1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package opensergo

import (
"log"
"os"
"sync"

Expand Down Expand Up @@ -130,6 +131,7 @@ func (c *ControlPlane) handleSubscribeRequest(clientIdentifier model.ClientIdent
err = c.sendMessageToStream(stream, request.Target.Namespace, request.Target.App, kind, nil, status, request.RequestId)
if err != nil {
// TODO: log here
log.Printf("sendMessageToStream failed, err=%s\n", err.Error())
}
continue
}
Expand All @@ -152,6 +154,7 @@ func (c *ControlPlane) handleSubscribeRequest(clientIdentifier model.ClientIdent
err = c.sendMessageToStream(stream, request.Target.Namespace, request.Target.App, kind, dataWithVersion, status, request.RequestId)
if err != nil {
// TODO: log here
log.Printf("sendMessageToStream failed, err=%s\n", err.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/crd_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ func (r *CRDWatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
}

app := ""
hasAppLabel := true
if crd != nil {
// TODO: bugs here: we need to check for namespace-app group, not only for app.
// And we may also need to check for namespace change of a CRD.
var hasAppLabel bool
app, hasAppLabel = crd.GetLabels()["app"]
appSubscribed := r.HasAnySubscribedOfApp(app)
if !hasAppLabel || !appSubscribed {
Expand Down
10 changes: 6 additions & 4 deletions pkg/transport/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ package grpc

import (
"fmt"
"io"
"log"
"net"

"github.com/opensergo/opensergo-control-plane/pkg/model"
trpb "github.com/opensergo/opensergo-control-plane/pkg/proto/transport/v1"
"github.com/opensergo/opensergo-control-plane/pkg/util"
"go.uber.org/atomic"
"google.golang.org/grpc"
"io"
"log"
"net"
)

const (
Expand Down Expand Up @@ -117,8 +118,10 @@ func (s *TransportServer) SubscribeConfig(stream trpb.OpenSergoUniversalTranspor
// This indicates the received data is a response of push-failure.
if recvData.Status.Code == CheckFormatError {
// TODO: handle here (cannot retry)
log.Println("Client response CheckFormatError")
} else {
// TODO: record error here and do something
log.Printf("Client response NACK, code=%d\n", recvData.Status.Code)
}
} else {
// This indicates the received data is a SubscribeRequest.
Expand Down Expand Up @@ -150,7 +153,6 @@ func (s *TransportServer) SubscribeConfig(stream trpb.OpenSergoUniversalTranspor
}

}
return nil
}

func newTransportServer(connectionManager *ConnectionManager, subscribeHandlers []model.SubscribeRequestHandler) *TransportServer {
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/format_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package util

import (
pb "github.com/opensergo/opensergo-control-plane/pkg/proto/fault_tolerance/v1"
"strconv"
"strings"

pb "github.com/opensergo/opensergo-control-plane/pkg/proto/fault_tolerance/v1"
)

func Str2MillSeconds(timeStr string) (int64, error) {
Expand Down

0 comments on commit d8c0de1

Please sign in to comment.