ProcessLogLine handles the incoming lines by running a fetch-execute cycle on the VM bytecode with the line as input to the program, until termination.
(_ context.Context, line *logline.LogLine)
| 960 | // ProcessLogLine handles the incoming lines by running a fetch-execute cycle |
| 961 | // on the VM bytecode with the line as input to the program, until termination. |
| 962 | func (v *VM) ProcessLogLine(_ context.Context, line *logline.LogLine) { |
| 963 | start := time.Now() |
| 964 | defer func() { |
| 965 | LineProcessingDurations.WithLabelValues(v.name).Observe(time.Since(start).Seconds()) |
| 966 | }() |
| 967 | t := new(thread) |
| 968 | t.matched = false |
| 969 | v.t = t |
| 970 | v.input = line |
| 971 | t.stack = make([]interface{}, 0) |
| 972 | t.matches = make(map[int][]string, len(v.re)) |
| 973 | for { |
| 974 | if t.pc >= len(v.prog) { |
| 975 | return |
| 976 | } |
| 977 | if v.trace != nil { |
| 978 | v.trace = append(v.trace, t.pc) |
| 979 | } |
| 980 | i := v.prog[t.pc] |
| 981 | t.pc++ |
| 982 | v.execute(t, i) |
| 983 | if v.terminate { |
| 984 | // Terminate only stops this invocation on this line of input; reset the terminate flag. |
| 985 | v.terminate = false |
| 986 | return |
| 987 | } |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | // New creates a new virtual machine with the given name, and compiler |
| 992 | // artifacts for executable and data segments. |