github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/tools/autoscaling/concepts/plugins/strategy.mdx (about) 1 --- 2 layout: docs 3 page_title: Strategy Plugins 4 description: Learn how to author a Nomad Autoscaler Strategy plugin. 5 --- 6 7 # Strategy Plugins 8 9 Strategy plugins are used by the autoscaler to implement the logic of scaling strategy. 10 They typically consume metrics from the configured APM plugin and the current scaling value 11 from the target plugin and compute a new desired value for the scaling target. 12 13 For a real-world example of a Nomad strategy plugin implementation, see the 14 [`target-value` plugin][target_value]. 15 16 ## Authoring Strategy Plugins 17 18 Authoring a strategy plugin in Go can be accomplished by implementing the 19 [`strategy.Strategy`][strategy_plugin] interface, alongside a `main` package to launch the plugin. 20 21 The [`no-op` Strategy plugin][noop_plugin] can be used as a starting point for new Strategy 22 plugins. 23 24 ## Strategy Plugin API 25 26 The [base plugin][base_plugin] interface must be implemented in addition to the 27 following functions. 28 29 #### `Run(eval *sdk.ScalingCheckEvaluation, count int64) (*sdk.ScalingCheckEvaluation, error)` 30 31 The `Run` function is called by the agent during policy 32 evaluation. The `eval` argument contains [information](https://github.com/hashicorp/nomad-autoscaler/blob/v0.3.0/sdk/eval_oss.go#L8) 33 about the current policy evaluation, including the policy specification and the metrics from the APM. The `count` 34 argument includes the current value of the scaling target. The returned struct should include the result 35 from applying the strategy. 36 37 [strategy_plugin]: https://github.com/hashicorp/nomad-autoscaler/blob/v0.3.0/plugins/strategy/strategy.go#L11 38 [base_plugin]: /tools/autoscaling/internals/plugins/base 39 [noop_plugin]: https://github.com/hashicorp/nomad-autoscaler/tree/v0.3.0/plugins/test/noop-strategy 40 [target_value]: https://github.com/hashicorp/nomad-autoscaler/tree/v0.3.0/plugins/builtin/strategy/target-value