Add context

This commit adds and passes context around to (almost) every function.
This allows cancelling (almost) every function call globally.
This commit is contained in:
Tom Wiesing 2022-11-28 13:30:08 +01:00
parent 996ecb9f80
commit 3455f491ca
No known key found for this signature in database
104 changed files with 836 additions and 511 deletions

View file

@ -1,6 +1,8 @@
package mstore
import (
"context"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/meta"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
)
@ -14,26 +16,26 @@ type MStore struct {
// For is a Store for the provided value
type For[Value any] meta.TypedKey[Value]
func (f For[Value]) Get(m *MStore) (value Value, err error) {
return meta.TypedKey[Value](f).Get(m.Storage)
func (f For[Value]) Get(ctx context.Context, m *MStore) (value Value, err error) {
return meta.TypedKey[Value](f).Get(ctx, m.Storage)
}
func (f For[Value]) GetAll(m *MStore) (values []Value, err error) {
return meta.TypedKey[Value](f).GetAll(m.Storage)
func (f For[Value]) GetAll(ctx context.Context, m *MStore) (values []Value, err error) {
return meta.TypedKey[Value](f).GetAll(ctx, m.Storage)
}
func (f For[Value]) GetOrSet(m *MStore, dflt Value) (value Value, err error) {
return meta.TypedKey[Value](f).GetOrSet(m.Storage, dflt)
func (f For[Value]) GetOrSet(ctx context.Context, m *MStore, dflt Value) (value Value, err error) {
return meta.TypedKey[Value](f).GetOrSet(ctx, m.Storage, dflt)
}
func (f For[Value]) Set(m *MStore, value Value) error {
return meta.TypedKey[Value](f).Set(m.Storage, value)
func (f For[Value]) Set(ctx context.Context, m *MStore, value Value) error {
return meta.TypedKey[Value](f).Set(ctx, m.Storage, value)
}
func (f For[Value]) SetAll(m *MStore, values ...Value) error {
return meta.TypedKey[Value](f).SetAll(m.Storage, values...)
func (f For[Value]) SetAll(ctx context.Context, m *MStore, values ...Value) error {
return meta.TypedKey[Value](f).SetAll(ctx, m.Storage, values...)
}
func (f For[Value]) Delete(m *MStore) error {
return m.Storage.Delete(meta.Key(f))
func (f For[Value]) Delete(ctx context.Context, m *MStore) error {
return m.Storage.Delete(ctx, meta.Key(f))
}