You've already forked agentic-coding-workflow
SSE 调整
This commit is contained in:
@@ -66,14 +66,14 @@ type subscription struct {
|
||||
st *streamer
|
||||
}
|
||||
|
||||
// Next blocks until at least one event with ID >= lastEventID is available,
|
||||
// Next blocks until at least one event with ID >= nextEventID is available,
|
||||
// the stream closes, or ctx is cancelled.
|
||||
// It returns all events from lastEventID to the current tail.
|
||||
func (sub *subscription) Next(ctx context.Context, lastEventID int64) ([]SSEEvent, bool, error) {
|
||||
// It returns all events from nextEventID to the current tail.
|
||||
func (sub *subscription) Next(ctx context.Context, nextEventID int64) ([]SSEEvent, bool, error) {
|
||||
sub.st.mu.Lock()
|
||||
defer sub.st.mu.Unlock()
|
||||
|
||||
for int64(len(sub.st.events)) <= lastEventID && !sub.st.closed {
|
||||
for int64(len(sub.st.events)) <= nextEventID && !sub.st.closed {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
select {
|
||||
@@ -88,7 +88,7 @@ func (sub *subscription) Next(ctx context.Context, lastEventID int64) ([]SSEEven
|
||||
return nil, false, ctx.Err()
|
||||
}
|
||||
}
|
||||
out := append([]SSEEvent(nil), sub.st.events[lastEventID:]...)
|
||||
out := append([]SSEEvent(nil), sub.st.events[nextEventID:]...)
|
||||
return out, sub.st.closed, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user