Skip to content

Commit

Permalink
fix(sdk): http sse client (#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin authored and bnjjj committed Oct 11, 2018
1 parent 45c3c5f commit 9b93888
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sdk/cdsclient/client_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ func (c *client) QueuePolling(ctx context.Context, jobs chan<- sdk.WorkflowNodeJ
sdk.GoRoutine(ctx, "RequestSSEGet", func(ctx context.Context) {
for ctx.Err() == nil {
if err := c.RequestSSEGet(ctx, "/events", chanSSEvt); err != nil {
log.Println(err)
log.Println("QueuePolling", err)
}
time.Sleep(2 * time.Second)
time.Sleep(1 * time.Second)
}
})

Expand Down
12 changes: 7 additions & 5 deletions sdk/cdsclient/http_sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ func (c *client) RequestSSEGet(ctx context.Context, path string, evCh chan<- SSE
}

bs, err := br.ReadBytes('\n')
if err != nil && err != io.EOF {
return err
}

if err == io.EOF {
EOF = true
if err != nil {
switch err {
case io.EOF, io.ErrUnexpectedEOF, io.ErrClosedPipe:
EOF = true
default:
return err
}
}

if len(bs) < 2 {
Expand Down

0 comments on commit 9b93888

Please sign in to comment.