type ErrorUnknownAction struct { GroupVersionKind string Action string }
func NewErrorUnknownAction(GVK string, action string) ErrorUnknownAction
func (it ErrorUnknownAction) Error() string
Multiplexer could combine ChaosImpl implementations into one, and route them by Action in the ChaosSpec. Field impl should be a struct which contains several fields with struct tag "action", each field should be an implementation of ChaosImpl. For example:
type tempStruct struct { Impl1 impltypes.ChaosImpl `action:"action1"` Impl2 impltypes.ChaosImpl `action:"action2"` }
is valid to be the field in Multiplexer.
Because we use reflect fo iterate fields in tempStruct, so fields in tempStruct should be public/exported.
When some Chaos like:
type SomeChaos struct { *** Spec SomeChaosSpec `json:"spec"` *** } type SomeChaosSpec struct { *** // available actions: action1, action2 Action string `json:"action"` *** }
is created, the corresponding ChaosImpl(s) for each action will be invoked by struct tag.
type Multiplexer struct {
// contains filtered or unexported fields
}
▹ Example
func NewMultiplexer(impl interface{}) Multiplexer
NewMultiplexer is a constructor of Multiplexer. For the detail of the parameter "impl", see the comment of type Multiplexer.
func (i *Multiplexer) Apply(ctx context.Context, index int, records []*v1alpha1.Record, obj v1alpha1.InnerObject) (v1alpha1.Phase, error)
func (i *Multiplexer) Recover(ctx context.Context, index int, records []*v1alpha1.Record, obj v1alpha1.InnerObject) (v1alpha1.Phase, error)