Documentation ¶
Index ¶
- Constants
- func EncodeKVEntryReaderToJsonl(reader KVEntryReader, bytesWriter io.Writer) (err error)
- func NewStateChangeEvent(storeName string, subkey, value []byte) sdk.Event
- type KVEntry
- func (entry KVEntry) HasValue() bool
- func (entry KVEntry) IsValidKey() bool
- func (entry KVEntry) Key() string
- func (entry KVEntry) MarshalJSON() ([]byte, error)
- func (entry KVEntry) StringValue() string
- func (entry *KVEntry) UnmarshalJSON(input []byte) (err error)
- func (entry KVEntry) Value() *string
- type KVEntryReader
- func NewJsonRawMessageKVEntriesReader(jsonEntries []json.RawMessage) KVEntryReader
- func NewJsonlKVEntryDecoderReader(byteReader io.ReadCloser) KVEntryReader
- func NewKVIteratorReader(iter sdk.Iterator) KVEntryReader
- func NewSwingStoreExportDataEntriesReader(exportDataEntries []*swingsettypes.SwingStoreExportDataEntry) KVEntryReader
- func NewVstorageDataEntriesReader(vstorageDataEntries []*vstoragetypes.DataEntry) KVEntryReader
Constants ¶
const ( EventTypeStateChange = "state_change" AttributeKeyStoreName = "store" AttributeKeyStoreSubkey = "key" AttributeKeyAnchoredKey = "anckey" AttributeKeyUnprovedValue = "value" // We chose \1 so that it is not a valid character in a vstorage path. AnchoredKeyStart = "\x01" AnchoredKeyEnd = AnchoredKeyStart )
Variables ¶
This section is empty.
Functions ¶
func EncodeKVEntryReaderToJsonl ¶
func EncodeKVEntryReaderToJsonl(reader KVEntryReader, bytesWriter io.Writer) (err error)
EncodeKVEntryReaderToJsonl consumes a KVEntryReader and JSON encodes each KVEntry, terminating by new lines. It will not Close the Reader when done
Types ¶
type KVEntry ¶
type KVEntry struct {
// contains filtered or unexported fields
}
KVEntry represents a string key / string value pair, where the value may be missing, which is different from an empty value. The semantics of a missing value are purpose-dependent rather than specified here, but frequently correspond with deletion/incompleteness/etc. A KVEntry with an empty key is considered invalid.
func NewKVEntry ¶
NewKVEntry creates a KVEntry with the provided key and value
func NewKVEntryWithNoValue ¶
NewKVEntryWithNoValue creates a KVEntry with the provided key and no value
func (KVEntry) IsValidKey ¶
IsValidKey returns whether the KVEntry has a non-empty key.
func (KVEntry) MarshalJSON ¶
MarshalJSON encodes the KVEntry into a JSON array of [key: string, value?: string], with the value missing (array length of 1) if the entry has no value.
Implements json.Marshaler
func (KVEntry) StringValue ¶
StringValue returns the string value, or the empty string if the entry has no value. Note that the result therefore does not differentiate an empty string value from no value.
func (*KVEntry) UnmarshalJSON ¶
UnmarshalJSON updates a KVEntry from JSON text corresponding with a [key: string, value?: string | null] shape, or returns an error indicating invalid input. The key must be a non-empty string, and the value (if present) must be a string or null.
Implements json.Unmarshaler Note: unlike other methods, this accepts a pointer to satisfy the Unmarshaler semantics.
type KVEntryReader ¶
type KVEntryReader interface { // Read returns the next KVEntry, or an error. // An `io.EOF` error indicates that the previous Read() returned the final KVEntry. Read() (KVEntry, error) // Close frees the underlying resource (such as a slice or file descriptor). Close() error }
KVEntryReader is an abstraction for iteratively reading KVEntry data.
func NewJsonRawMessageKVEntriesReader ¶
func NewJsonRawMessageKVEntriesReader(jsonEntries []json.RawMessage) KVEntryReader
NewJsonRawMessageKVEntriesReader creates a KVEntryReader backed by a json.RawMessage slice
func NewJsonlKVEntryDecoderReader ¶
func NewJsonlKVEntryDecoderReader(byteReader io.ReadCloser) KVEntryReader
NewJsonlKVEntryDecoderReader creates a KVEntryReader over a byte stream reader that decodes each line as a json encoded KVEntry. The entries are yielded in order they're present in the stream.
func NewKVIteratorReader ¶
func NewKVIteratorReader(iter sdk.Iterator) KVEntryReader
NewKVIteratorReader returns a KVEntryReader backed by an sdk.Iterator.
func NewSwingStoreExportDataEntriesReader ¶
func NewSwingStoreExportDataEntriesReader(exportDataEntries []*swingsettypes.SwingStoreExportDataEntry) KVEntryReader
NewSwingStoreExportDataEntriesReader creates a KVEntryReader backed by a SwingStoreExportDataEntry slice
func NewVstorageDataEntriesReader ¶
func NewVstorageDataEntriesReader(vstorageDataEntries []*vstoragetypes.DataEntry) KVEntryReader
NewVstorageDataEntriesReader creates a KVEntryReader backed by a vstorage DataEntry slice