package etcdb import ( "context" ) type SingletonSpec[T any] struct { Spec Spec Key string } func (p SingletonSpec[T]) In(ctx context.Context) Singleton[T] { return Singleton[T]{TypedDB[T]{p.Spec.In(ctx), JSONCodec}, p.Key} } type Singleton[T any] struct { db TypedDB[T] key string } func (s Singleton[T]) Get() (v T, ok bool, err error) { return s.db.Get(s.key) } func (s Singleton[T]) Set(value T) error { return s.db.Put(s.key, value) }