Skip to content

Commit

Permalink
Ensure the errch is buffered
Browse files Browse the repository at this point in the history
(and also the individual message channels, because i don't actually
understand why this can't be unbuffered and so i'd rather not think
about it)

Signed-off-by: Andrew Mason <amason@slack-corp.com>
  • Loading branch information
ajm188 committed Oct 22, 2021
1 parent c99bbcb commit 07c1fe6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 7 additions & 0 deletions go/vt/vtctl/localvtctldclient/bidi_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ type bidiStream struct {
sendClosed bool
}

func newBidiStream(ctx context.Context) *bidiStream {
return &bidiStream{
ctx: ctx,
errch: make(chan error, 1),
}
}

func (bs *bidiStream) close(err error) {
if err == nil {
err = io.EOF
Expand Down
6 changes: 2 additions & 4 deletions go/vt/vtctl/vtctldclient/codegen/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ func (client *{{ $.Type }}) {{ .Name }}(ctx context.Context, {{ .Param.Name }} {
{{- else -}}
{{- if .IsStreaming -}}
stream := &{{ streamAdapterName .Name }}{
bidiStream: &bidiStream{
ctx: ctx,
},
ch: make(chan {{ .StreamMessage.Type }}),
bidiStream: newBidiStream(ctx),
ch: make(chan {{ .StreamMessage.Type }}, 1),
}
go func() {
err := client.s.{{ .Name }}(in, stream)
Expand Down

0 comments on commit 07c1fe6

Please sign in to comment.