pull all non-request scoped values out of context

This commit is contained in:
Joel Wetzell
2026-05-06 21:33:16 -05:00
parent eb25c73f3a
commit 833bd529d6
98 changed files with 328 additions and 584 deletions

View File

@@ -1,27 +0,0 @@
package test
import (
"context"
"github.com/jwetzell/showbridge-go/internal/common"
)
func GetContextWithModules(ctx context.Context, modules map[string]common.Module) context.Context {
ctx = context.WithValue(ctx, common.ModulesContextKey, modules)
return ctx
}
func GetContextWithRouter(ctx context.Context) context.Context {
ctx = context.WithValue(ctx, common.RouterContextKey, GetNewTestRouter())
return ctx
}
func GetContextWithSender(ctx context.Context, sender any) context.Context {
ctx = context.WithValue(ctx, common.SenderContextKey, sender)
return ctx
}
func GetContextWithSource(ctx context.Context, source string) context.Context {
ctx = context.WithValue(ctx, common.SourceContextKey, source)
return ctx
}

View File

@@ -4,13 +4,14 @@ import (
"context"
"database/sql"
"github.com/jwetzell/showbridge-go/internal/common"
_ "modernc.org/sqlite"
)
type TestModule struct {
}
func (m *TestModule) Start(ctx context.Context) error {
func (m *TestModule) Start(ctx context.Context, router common.RouteIO) error {
<-ctx.Done()
return nil
}
@@ -36,7 +37,7 @@ type TestKVModule struct {
kvData map[string]any
}
func (m *TestKVModule) Start(ctx context.Context) error {
func (m *TestKVModule) Start(ctx context.Context, router common.RouteIO) error {
<-ctx.Done()
return nil
}
@@ -73,7 +74,7 @@ type TestDBModule struct {
db *sql.DB
}
func (m *TestDBModule) Start(ctx context.Context) error {
func (m *TestDBModule) Start(ctx context.Context, router common.RouteIO) error {
<-ctx.Done()
return nil
}