store

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 5 Imported by: 100

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackedModel

type BackedModel interface {
	// GetBackingStore returns the store that is backing the model.
	GetBackingStore() BackingStore
}

BackedModel defines methods for models that support a backing store

type BackingStore

type BackingStore interface {

	// Get return a value from the backing store based on its key.
	// Returns null if the value hasn't changed and "ReturnOnlyChangedValues" is true
	Get(key string) (interface{}, error)

	// Set or updates the stored value for the given key.
	// Will trigger subscriptions callbacks.
	Set(key string, value interface{}) error

	// Enumerate returns all the values stored in the backing store. Values will be filtered if "ReturnOnlyChangedValues" is true.
	Enumerate() map[string]interface{}

	// EnumerateKeysForValuesChangedToNil returns the keys for all values that changed to null
	EnumerateKeysForValuesChangedToNil() []string

	// Subscribe registers a listener to any data change happening.
	// returns a subscriptionId which cah be used to reference the current subscription
	Subscribe(callback BackingStoreSubscriber) string

	// SubscribeWithId registers a listener to any data change happening and assigns the given id
	SubscribeWithId(callback BackingStoreSubscriber, subscriptionId string) error

	// Unsubscribe Removes a subscription from the store based on its subscription id.
	Unsubscribe(subscriptionId string) error

	// Clear Removes the data stored in the backing store. Doesn't trigger any subscription.
	Clear()

	// GetInitializationCompleted Track's status of object during serialization and deserialization.
	// this property is used to initialize subscriber notifications
	GetInitializationCompleted() bool

	// SetInitializationCompleted sets whether the initialization of the object and/or
	// the initial deserialization has been completed to track whether objects have changed
	SetInitializationCompleted(val bool)

	// GetReturnOnlyChangedValues is a flag that defines whether subscriber notifications should be sent only when
	// data has been changed
	GetReturnOnlyChangedValues() bool

	// SetReturnOnlyChangedValues Sets whether to return only values that have changed
	// since the initialization of the object when calling the Get and Enumerate method
	SetReturnOnlyChangedValues(val bool)
}

BackingStore Stores model information in a different location than the object properties. Implementations can provide dirty tracking capabilities, caching capabilities or integration with 3rd party stores.

func NewInMemoryBackingStore

func NewInMemoryBackingStore() BackingStore

NewInMemoryBackingStore returns a new instance of an in memory backing store this function also provides an implementation of a BackingStoreFactory

type BackingStoreFactory

type BackingStoreFactory func() BackingStore

BackingStoreFactory represents a factory function for a backing store initializes a new backing store object

var BackingStoreFactoryInstance BackingStoreFactory = NewInMemoryBackingStore

BackingStoreFactoryInstance returns a backing store instance. if none exists an instance of InMemoryBackingStore is initialized and returned

type BackingStoreParseNodeFactory

type BackingStoreParseNodeFactory struct {
	serialization.ParseNodeFactory
}

BackingStoreParseNodeFactory Backing Store implementation for serialization.ParseNodeFactory

func NewBackingStoreParseNodeFactory

func NewBackingStoreParseNodeFactory(factory serialization.ParseNodeFactory) *BackingStoreParseNodeFactory

NewBackingStoreParseNodeFactory Initializes a new instance of BackingStoreParseNodeFactory

type BackingStoreSerializationWriterProxyFactory

type BackingStoreSerializationWriterProxyFactory struct {
	// contains filtered or unexported fields
}

BackingStoreSerializationWriterProxyFactory Backing Store implementation for serialization.SerializationWriterFactory

func NewBackingStoreSerializationWriterProxyFactory

func NewBackingStoreSerializationWriterProxyFactory(factory serialization.SerializationWriterFactory) *BackingStoreSerializationWriterProxyFactory

NewBackingStoreSerializationWriterProxyFactory Initializes a new instance of BackingStoreSerializationWriterProxyFactory

func (*BackingStoreSerializationWriterProxyFactory) GetSerializationWriter

func (*BackingStoreSerializationWriterProxyFactory) GetValidContentType

func (b *BackingStoreSerializationWriterProxyFactory) GetValidContentType() (string, error)

type BackingStoreSubscriber

type BackingStoreSubscriber func(key string, oldVal interface{}, newVal interface{})

BackingStoreSubscriber is a function signature for a listener to any changes to a backing store It takes a `key` that represents the name of the object that's changed, `oldVal` is the previous value `newVal` is the newly assigned value

type InMemoryBackingStore

type InMemoryBackingStore struct {
	// contains filtered or unexported fields
}

func (*InMemoryBackingStore) Clear

func (i *InMemoryBackingStore) Clear()

func (*InMemoryBackingStore) Enumerate

func (i *InMemoryBackingStore) Enumerate() map[string]interface{}

func (*InMemoryBackingStore) EnumerateKeysForValuesChangedToNil

func (i *InMemoryBackingStore) EnumerateKeysForValuesChangedToNil() []string

func (*InMemoryBackingStore) Get

func (i *InMemoryBackingStore) Get(key string) (interface{}, error)

func (*InMemoryBackingStore) GetInitializationCompleted

func (i *InMemoryBackingStore) GetInitializationCompleted() bool

func (*InMemoryBackingStore) GetReturnOnlyChangedValues

func (i *InMemoryBackingStore) GetReturnOnlyChangedValues() bool

func (*InMemoryBackingStore) Set

func (i *InMemoryBackingStore) Set(key string, value interface{}) error

func (*InMemoryBackingStore) SetInitializationCompleted

func (i *InMemoryBackingStore) SetInitializationCompleted(val bool)

func (*InMemoryBackingStore) SetReturnOnlyChangedValues

func (i *InMemoryBackingStore) SetReturnOnlyChangedValues(val bool)

func (*InMemoryBackingStore) Subscribe

func (i *InMemoryBackingStore) Subscribe(callback BackingStoreSubscriber) string

func (*InMemoryBackingStore) SubscribeWithId

func (i *InMemoryBackingStore) SubscribeWithId(callback BackingStoreSubscriber, subscriptionId string) error

func (*InMemoryBackingStore) Unsubscribe

func (i *InMemoryBackingStore) Unsubscribe(subscriptionId string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL