(ctx context.Context, ch <-chan cliproxyexecutor.StreamChunk)
| 1707 | } |
| 1708 | |
| 1709 | func readStreamBootstrap(ctx context.Context, ch <-chan cliproxyexecutor.StreamChunk) ([]cliproxyexecutor.StreamChunk, bool, error) { |
| 1710 | if ch == nil { |
| 1711 | return nil, true, nil |
| 1712 | } |
| 1713 | buffered := make([]cliproxyexecutor.StreamChunk, 0, 1) |
| 1714 | for { |
| 1715 | var ( |
| 1716 | chunk cliproxyexecutor.StreamChunk |
| 1717 | ok bool |
| 1718 | ) |
| 1719 | if ctx != nil { |
| 1720 | select { |
| 1721 | case <-ctx.Done(): |
| 1722 | return nil, false, ctx.Err() |
| 1723 | case chunk, ok = <-ch: |
| 1724 | } |
| 1725 | } else { |
| 1726 | chunk, ok = <-ch |
| 1727 | } |
| 1728 | if !ok { |
| 1729 | return buffered, true, nil |
| 1730 | } |
| 1731 | if chunk.Err != nil { |
| 1732 | return nil, false, chunk.Err |
| 1733 | } |
| 1734 | buffered = append(buffered, chunk) |
| 1735 | if len(chunk.Payload) > 0 { |
| 1736 | return buffered, false, nil |
| 1737 | } |
| 1738 | } |
| 1739 | } |
| 1740 | |
| 1741 | func (m *Manager) wrapStreamResult(ctx context.Context, auth *Auth, provider, resultModel string, headers http.Header, buffered []cliproxyexecutor.StreamChunk, remaining <-chan cliproxyexecutor.StreamChunk, aliasResult OAuthModelAliasResult) *cliproxyexecutor.StreamResult { |
| 1742 | out := make(chan cliproxyexecutor.StreamChunk) |
no outgoing calls
no test coverage detected