-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
- Loading branch information
1 parent
fb47a7e
commit cbdfc7d
Showing
6 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package server | ||
|
||
import ( | ||
"io" | ||
"sync" | ||
|
||
envoy_sd "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" | ||
"github.com/envoyproxy/go-control-plane/pkg/server/stream/v3" | ||
) | ||
|
||
// ErrorRecorderStream is a DeltaStream that records an error | ||
// We need this because go-control-plane@v0.11.1/pkg/server/delta/v3/server.go:190 swallows an error on Recv() | ||
type ErrorRecorderStream interface { | ||
stream.DeltaStream | ||
Err() error | ||
} | ||
|
||
type errorRecorderStream struct { | ||
stream.DeltaStream | ||
err error | ||
sync.Mutex | ||
} | ||
|
||
var _ stream.DeltaStream = &errorRecorderStream{} | ||
|
||
func NewErrorRecorderStream(s stream.DeltaStream) ErrorRecorderStream { | ||
return &errorRecorderStream{ | ||
DeltaStream: s, | ||
} | ||
} | ||
|
||
func (e *errorRecorderStream) Recv() (*envoy_sd.DeltaDiscoveryRequest, error) { | ||
res, err := e.DeltaStream.Recv() | ||
if err != nil && err != io.EOF { // do not consider "end of stream" an error | ||
e.Lock() | ||
e.err = err | ||
e.Unlock() | ||
} | ||
return res, err | ||
} | ||
|
||
func (e *errorRecorderStream) Err() error { | ||
e.Lock() | ||
defer e.Unlock() | ||
return e.err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters