Skip to content

Commit

Permalink
Make GoLinter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
wneessen committed Oct 6, 2021
1 parent 0233f13 commit 188ce33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pps.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *Server) Run(ctx context.Context, h Handler) error {
}

connId := xid.New()
conCtx := context.WithValue(ctx, "id", connId.String())
conCtx := context.WithValue(ctx, "id", connId)
go connHandler(conCtx, conn)
}

Expand All @@ -252,8 +252,13 @@ func (s *Server) Run(ctx context.Context, h Handler) error {
// connHandler processes the incoming policy connection request and hands it to the
// Handle function of the Handler interface
func connHandler(ctx context.Context, c *Connection) {
connId := ctx.Value("id").(string)
cl := log.New(os.Stderr, fmt.Sprintf("[%s] ERROR: ", connId), log.Lmsgprefix|log.LstdFlags)
connId, ok := ctx.Value("id").(xid.ID)
if !ok {
log.Print("failed to retrieve connection id from context.")
return
}
cl := log.New(os.Stderr, fmt.Sprintf("[%s] ERROR: ", connId.String()),
log.Lmsgprefix|log.LstdFlags)

// Channel to close connection in case of an error
cc := make(chan bool)
Expand Down
3 changes: 3 additions & 0 deletions pps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func TestRunDial(t *testing.T) {
if err := conn.Close(); err != nil {
t.Errorf("failed to close client connection: %s", err)
}

// Wait a brief moment for the connection to close
time.Sleep(time.Millisecond * 500)
}

// TestRunDialWithRequest starts a new server listening for connections and tries to connect to it
Expand Down

0 comments on commit 188ce33

Please sign in to comment.