Skip to content

Commit ee27c9e

Browse files
committed
flusher without err
1 parent 60599e7 commit ee27c9e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sdks/community/go/pkg/encoding/sse/writer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func (w *SSEWriter) WriteBytes(ctx context.Context, writer io.Writer, event []by
6767
return fmt.Errorf("SSE flush failed: %w", err)
6868
}
6969
}
70+
if flusher, ok := writer.(flusherWithoutError); ok {
71+
flusher.Flush()
72+
}
7073
return nil
7174
}
7275

@@ -116,6 +119,9 @@ func (w *SSEWriter) WriteEventWithType(ctx context.Context, writer io.Writer, ev
116119
return fmt.Errorf("SSE flush failed: %w", err)
117120
}
118121
}
122+
if flusher, ok := writer.(flusherWithoutError); ok {
123+
flusher.Flush()
124+
}
119125

120126
return nil
121127
}
@@ -187,6 +193,11 @@ type flusher interface {
187193
Flush() error
188194
}
189195

196+
// flusherWithoutError interface for writers that support flushing
197+
type flusherWithoutError interface {
198+
Flush()
199+
}
200+
190201
// CustomEvent is a simple implementation of events.Event for error and custom events
191202
type CustomEvent struct {
192203
events.BaseEvent

0 commit comments

Comments
 (0)