(done bool)
| 41 | } |
| 42 | |
| 43 | func (s *scanner) Pull(done bool) (vector.Any, error) { |
| 44 | again: |
| 45 | batch, err := s.scanner.Pull(done) |
| 46 | if err == nil { |
| 47 | if batch != nil { |
| 48 | return &vector.Labeled{Any: sbuf.Dematerialize(s.sctx, batch), Label: s.channel}, nil |
| 49 | } |
| 50 | return nil, s.closer.Close() |
| 51 | } |
| 52 | sctrl, ok := err.(*sbuf.Control) |
| 53 | if !ok { |
| 54 | return nil, err |
| 55 | } |
| 56 | ctrl, err := marshalControl(sctrl) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | switch ctrl := ctrl.(type) { |
| 61 | case *api.QueryChannelSet: |
| 62 | s.channel = ctrl.Channel |
| 63 | goto again |
| 64 | case *api.QueryChannelEnd: |
| 65 | return &vector.Labeled{Label: ctrl.Channel}, nil |
| 66 | case *api.QueryStats: |
| 67 | s.progress.Add(ctrl.Progress) |
| 68 | goto again |
| 69 | case *api.QueryError: |
| 70 | return nil, errors.New(ctrl.Error) |
| 71 | default: |
| 72 | return nil, fmt.Errorf("unsupported control message: %T", ctrl) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func marshalControl(zctrl *sbuf.Control) (any, error) { |
| 77 | ctrl, ok := zctrl.Message.(*bsupio.Control) |
nothing calls this directly
no test coverage detected