| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package chartengine |
| 4 | |
| 5 | import ( |
| 6 | "github.com/netdata/netdata/go/plugins/plugin/framework/chartengine/internal/program" |
| 7 | ) |
| 8 | |
| 9 | // ActionKind defines deterministic action ordering groups. |
| 10 | type ActionKind uint8 |
| 11 | |
| 12 | const ( |
| 13 | ActionCreateChart ActionKind = iota + 1 |
| 14 | ActionCreateDimension |
| 15 | ActionUpdateChart |
| 16 | ActionRemoveDimension |
| 17 | ActionRemoveChart |
| 18 | ) |
| 19 | |
| 20 | // EngineAction is one planner-emitted operation. |
| 21 | type EngineAction interface { |
| 22 | Kind() ActionKind |
| 23 | } |
| 24 | |
| 25 | // CreateChartAction materializes a chart instance before updates. |
| 26 | type CreateChartAction struct { |
| 27 | ChartTemplateID string |
| 28 | ChartID string |
| 29 | Meta program.ChartMeta |
| 30 | Labels map[string]string |
| 31 | } |
| 32 | |
| 33 | func (a CreateChartAction) Kind() ActionKind { return ActionCreateChart } |
| 34 | |
| 35 | // CreateDimensionAction materializes one dimension for a chart instance. |
| 36 | type CreateDimensionAction struct { |
| 37 | ChartID string |
| 38 | ChartMeta program.ChartMeta |
| 39 | Name string |
| 40 | Hidden bool |
| 41 | Float bool |
| 42 | Algorithm program.Algorithm |
| 43 | Multiplier int |
| 44 | Divisor int |
| 45 | } |
| 46 | |
| 47 | func (a CreateDimensionAction) Kind() ActionKind { return ActionCreateDimension } |
| 48 | |
| 49 | // UpdateDimensionValue carries one resolved value for UPDATE emission. |
| 50 | type UpdateDimensionValue struct { |
| 51 | Name string |
| 52 | IsEmpty bool |
| 53 | IsFloat bool |
| 54 | Int64 int64 |
| 55 | Float64 float64 |
| 56 | } |
| 57 | |
| 58 | // UpdateChartAction updates one chart instance values in deterministic order. |
| 59 | type UpdateChartAction struct { |
| 60 | ChartID string |
| 61 | Values []UpdateDimensionValue |
| 62 | } |
| 63 | |
| 64 | func (a UpdateChartAction) Kind() ActionKind { return ActionUpdateChart } |
| 65 | |
| 66 | // RemoveDimensionAction marks one dimension obsolete. |
| 67 | type RemoveDimensionAction struct { |
| 68 | ChartID string |
| 69 | ChartMeta program.ChartMeta |
| 70 | Name string |
| 71 | Hidden bool |
| 72 | Float bool |
| 73 | Algorithm program.Algorithm |
| 74 | Multiplier int |
| 75 | Divisor int |
| 76 | } |
| 77 | |
| 78 | func (a RemoveDimensionAction) Kind() ActionKind { return ActionRemoveDimension } |
| 79 | |
| 80 | // RemoveChartAction marks one chart obsolete. |
| 81 | type RemoveChartAction struct { |
| 82 | ChartID string |
| 83 | Meta program.ChartMeta |
| 84 | } |
| 85 | |
| 86 | func (a RemoveChartAction) Kind() ActionKind { return ActionRemoveChart } |