eventbus for sending events from backend to frontend. stubbing out a block controller and blockservice

This commit is contained in:
sawka
2024-05-14 13:34:41 -07:00
parent 91a3394602
commit 50ccd66d49
5 changed files with 254 additions and 8 deletions
+25
View File
@@ -0,0 +1,25 @@
// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
package blockservice
import (
"fmt"
"github.com/wavetermdev/thenextwave/pkg/blockcontroller"
)
type BlockService struct{}
func (bs *BlockService) SendCommand(blockId string, cmdMap map[string]any) error {
bc := blockcontroller.GetBlockController(blockId)
if bc == nil {
return fmt.Errorf("block controller not found for block %q", blockId)
}
cmd, err := blockcontroller.ParseCmdMap(cmdMap)
if err != nil {
return fmt.Errorf("error parsing command map: %w", err)
}
bc.InputCh <- cmd
return nil
}