Run consumes the backend's packet stream until ctx is done.
(ctx context.Context)
| 88 | |
| 89 | // Run consumes the backend's packet stream until ctx is done. |
| 90 | func (e *Engine) Run(ctx context.Context) error { |
| 91 | ch := e.backend.Packets() |
| 92 | for { |
| 93 | select { |
| 94 | case <-ctx.Done(): |
| 95 | return nil |
| 96 | case packet, ok := <-ch: |
| 97 | if !ok { |
| 98 | return nil |
| 99 | } |
| 100 | e.dispatch(packet) |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // dispatch classifies the packet, updates flow state, and decides on a |
| 106 | // verdict. It MUST call packet.Verdict exactly once. |