fixup! wip: refactor: API
This commit is contained in:
parent
f006187894
commit
7d6798b0f7
@ -63,9 +63,9 @@ func (a *App) Run(ctx context.Context) error {
|
|||||||
ui, err := terminal.NewUI(ctx, terminal.Params{
|
ui, err := terminal.NewUI(ctx, terminal.Params{
|
||||||
EventBus: a.bus,
|
EventBus: a.bus,
|
||||||
Dispatcher: func(cmd event.Command) {
|
Dispatcher: func(cmd event.Command) {
|
||||||
a.logger.Info("Command dispatched", "cmd", cmd.Name())
|
a.logger.Debug("Command dispatched to gRPC stream", "cmd", cmd.Name())
|
||||||
if sendErr := stream.Send(&pb.Envelope{Payload: &pb.Envelope_Command{Command: protocol.CommandToProto(cmd)}}); sendErr != nil {
|
if sendErr := stream.Send(&pb.Envelope{Payload: &pb.Envelope_Command{Command: protocol.CommandToProto(cmd)}}); sendErr != nil {
|
||||||
a.logger.Error("Error sending command to gRPC API", "err", sendErr)
|
a.logger.Error("Error dispatching command to gRPC stream", "err", sendErr)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ClipboardAvailable: a.clipboardAvailable,
|
ClipboardAvailable: a.clipboardAvailable,
|
||||||
|
@ -109,7 +109,7 @@ func (s *Server) Communicate(stream pb.InternalAPI_CommunicateServer) error {
|
|||||||
switch pbCmd := in.Payload.(type) {
|
switch pbCmd := in.Payload.(type) {
|
||||||
case *pb.Envelope_Command:
|
case *pb.Envelope_Command:
|
||||||
cmd := protocol.CommandFromProto(pbCmd.Command)
|
cmd := protocol.CommandFromProto(pbCmd.Command)
|
||||||
s.logger.Info("Received command", "command", cmd.Name())
|
s.logger.Debug("Received command from gRPC stream", "command", cmd.Name())
|
||||||
s.dispatcher(cmd)
|
s.dispatcher(cmd)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("expected command but got: %T", pbCmd)
|
return fmt.Errorf("expected command but got: %T", pbCmd)
|
||||||
|
@ -265,7 +265,7 @@ func (a *App) handleCommand(
|
|||||||
containerClient *container.Client,
|
containerClient *container.Client,
|
||||||
startMediaServerC chan struct{},
|
startMediaServerC chan struct{},
|
||||||
) (evt event.Event, _ error) {
|
) (evt event.Event, _ error) {
|
||||||
a.logger.Debug("Command received", "cmd", cmd.Name())
|
a.logger.Debug("Command received in handler", "cmd", cmd.Name())
|
||||||
defer func() {
|
defer func() {
|
||||||
if evt != nil {
|
if evt != nil {
|
||||||
a.eventBus.Send(evt)
|
a.eventBus.Send(evt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user