(ctx context.Context, payload *extractionContext, runID uint64)
| 144 | if len(messages) >= limit { |
| 145 | break |
| 146 | } |
| 147 | } |
| 148 | return messages, messageIDs, start, end, sessionID, consumerID |
| 149 | } |
| 150 | |
| 151 | func (c *ExtractionController) HasPendingResult() bool { |
| 152 | c.mu.Lock() |
| 153 | defer c.mu.Unlock() |
| 154 | return c.lastResult != nil |
| 155 | } |
| 156 | |
| 157 | func (c *ExtractionController) ConsumeResult() string { |
| 158 | c.mu.Lock() |
| 159 | defer c.mu.Unlock() |
| 160 | if c.lastResult == nil { |
| 161 | return "" |
| 162 | } |
| 163 | result := *c.lastResult |
| 164 | c.lastResult = nil |
| 165 | return result |
| 166 | } |
| 167 | |
| 168 | func (c *ExtractionController) Cancel() { |
| 169 | c.mu.Lock() |
| 170 | cancel := c.currentCancel |
| 171 | c.currentCancel = nil |
| 172 | c.currentRunning = false |
| 173 | c.currentRunID++ |
| 174 | c.pendingContext = nil |
| 175 | c.lastResult = nil |
| 176 | c.mu.Unlock() |
| 177 | if cancel != nil { |
| 178 | cancel() |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | func (c *ExtractionController) runExtraction(ctx context.Context, payload *extractionContext, runID uint64) { |
| 183 | defer func() { |
| 184 | c.mu.Lock() |
| 185 | pending := c.pendingContext |
| 186 | c.pendingContext = nil |
| 187 | if pending != nil { |
| 188 | runCtx, cancel := context.WithCancel(context.Background()) |
| 189 | c.currentCancel = cancel |
| 190 | c.currentRunning = true |
| 191 | c.currentRunID++ |
| 192 | nextRunID := c.currentRunID |
| 193 | c.mu.Unlock() |
| 194 | go c.runExtraction(runCtx, pending, nextRunID) |
| 195 | return |
| 196 | } |
| 197 | if c.currentRunID == runID { |
| 198 | c.currentRunning = false |
| 199 | c.currentCancel = nil |
| 200 | } |
| 201 | c.mu.Unlock() |
| 202 | }() |
| 203 | _, _ = c.runFabricExtraction(ctx, payload) |
no test coverage detected