scanSteeringEntries reads all valid steering proxyEventsEntry records from r. Lines that fail the quick-keyword check or JSON decoding are silently skipped. The caller is responsible for the lifetime of r.
(r io.Reader)
| 831 | // Lines that fail the quick-keyword check or JSON decoding are silently skipped. |
| 832 | // The caller is responsible for the lifetime of r. |
| 833 | func scanSteeringEntries(r io.Reader) ([]proxyEventsEntry, error) { |
| 834 | var entries []proxyEventsEntry |
| 835 | scanner := bufio.NewScanner(r) |
| 836 | buf := make([]byte, maxScannerBufferSize) |
| 837 | scanner.Buffer(buf, maxScannerBufferSize) |
| 838 | for scanner.Scan() { |
| 839 | line := strings.TrimSpace(scanner.Text()) |
| 840 | if line == "" || !containsSteeringKeyword(line) { |
| 841 | continue |
| 842 | } |
| 843 | var entry proxyEventsEntry |
| 844 | if err := json.Unmarshal([]byte(line), &entry); err != nil { |
| 845 | continue |
| 846 | } |
| 847 | if isSteeringEvent(entry.eventName(), strings.TrimSpace(entry.Message)) { |
| 848 | entries = append(entries, entry) |
| 849 | } |
| 850 | } |
| 851 | return entries, scanner.Err() |
| 852 | } |
| 853 | |
| 854 | func parseAPIProxySteeringEvents(filePath string) (int, error) { |
| 855 | file, err := os.Open(filepath.Clean(filePath)) |
no test coverage detected