Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NullStorage ¶
type NullStorage[T object] struct{}
NullStorage is a dummy object honoring the Storage interface, and can be used in unit tests as a drop-in replacement in the dependencies if the test don't actually care about storage actions.
func (NullStorage[T]) Close ¶
func (s NullStorage[T]) Close() error
func (NullStorage[T]) HealthCheck ¶
func (s NullStorage[T]) HealthCheck(context.Context, func() T) bool
func (NullStorage[T]) Init ¶
func (s NullStorage[T]) Init() error
type Storage ¶
type Storage[T object] interface {
// Init initialises the storage (opens it)
Init() error
// Close gracefully terminates the storage.
Close() error
// Hydrate hydrates the provided object with data coming from the storage
// the provided object should at least be able to return a non-null and unique Identifier (via the GetIdentifier() method)
Hydrate(ctx context.Context, defaultObj T) error
// Save store the provided object in the storage
// the provided object should at least be able to return a non-null and unique Identifier (via the GetIdentifier() method)
Save(ctx context.Context, obj T) error
// HealthCheck verifies if the storage is connected and usable
HealthCheck(ctx context.Context, hydrationSample func() T) bool
}
Click to show internal directories.
Click to hide internal directories.