-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
state.go
32 lines (27 loc) · 1.04 KB
/
state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package chaos
import (
"fmt"
"io"
)
// State is the state for the chaos actor used by some methods to invoke
// behaviours in the vm or runtime.
type State struct {
// Value can be updated by chaos actor methods to test illegal state
// mutations when the state is in readonly mode for example.
Value string
// Unmarshallable is a sentinel value. If the slice contains no values, the
// State struct will encode as CBOR without issue. If the slice is non-nil,
// CBOR encoding will fail.
Unmarshallable []*UnmarshallableCBOR
}
// UnmarshallableCBOR is a type that cannot be marshalled or unmarshalled to
// CBOR despite implementing the CBORMarshaler and CBORUnmarshaler interface.
type UnmarshallableCBOR struct{}
// UnmarshalCBOR will fail to unmarshal the value from CBOR.
func (t *UnmarshallableCBOR) UnmarshalCBOR(io.Reader) error {
return fmt.Errorf("failed to unmarshal cbor")
}
// MarshalCBOR will fail to marshal the value to CBOR.
func (t *UnmarshallableCBOR) MarshalCBOR(io.Writer) error {
return fmt.Errorf("failed to marshal cbor")
}