mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-05-07 10:05:54 +00:00
pull all non-request scoped values out of context
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user