stuff values into context

This commit is contained in:
Joel Wetzell
2025-12-27 22:59:30 -06:00
parent 3458b52206
commit 8ffc7d02a5
21 changed files with 167 additions and 53 deletions

View File

@@ -26,7 +26,7 @@ type MIDIOutput struct {
func init() {
RegisterModule(ModuleRegistration{
Type: "midi.output",
New: func(ctx context.Context, config config.ModuleConfig, router route.RouteIO) (Module, error) {
New: func(ctx context.Context, config config.ModuleConfig) (Module, error) {
params := config.Params
port, ok := params["port"]
@@ -41,6 +41,12 @@ func init() {
return nil, errors.New("midi.output port must be a string")
}
router, ok := ctx.Value(route.RouterContextKey).(route.RouteIO)
if !ok {
return nil, errors.New("midi.output unable to get router from context")
}
return &MIDIOutput{config: config, Port: portString, ctx: ctx, router: router, logger: CreateLogger(config)}, nil
},
})
@@ -75,7 +81,7 @@ func (mo *MIDIOutput) Run() error {
return nil
}
func (mo *MIDIOutput) Output(payload any) error {
func (mo *MIDIOutput) Output(ctx context.Context, payload any) error {
if mo.SendFunc == nil {
return errors.New("midi.output output is not setup")
}