MCPcopy
hub / github.com/slimtoolkit/slim / SendCommand

Method SendCommand

pkg/test/e2e/sensor/sensor.go:336–358  ·  view source on GitHub ↗
(ctx context.Context, cmd command.Message)

Source from the content-addressed store, hash-verified

334}
335
336func (s *Sensor) SendCommand(ctx context.Context, cmd command.Message) error {
337 msg, err := command.Encode(cmd)
338 if err != nil {
339 return fmt.Errorf("cannot encode command %q: %w", cmd, err)
340 }
341 log.Debugf("Sending command to the test sensor: %s", string(msg))
342
343 if len(s.contID) == 0 {
344 return errNotStarted
345 }
346
347 if s.client == nil {
348 return errors.New("IPC client isn't initialized - is sensor running?")
349 }
350
351 // TODO: Use timeout from ctx.
352 resp, err := s.client.SendCommand(cmd)
353 if err != nil || resp.Status != command.ResponseStatusOk {
354 return fmt.Errorf("IPC client.SendCommand() failed with response %q: %w", resp, err)
355 }
356
357 return nil
358}
359
360func (s *Sensor) SendStartCommand(
361 ctx context.Context,

Callers 3

SendStartCommandMethod · 0.95
SendStopCommandMethod · 0.95
ShutdownMethod · 0.95

Calls 1

EncodeFunction · 0.92

Tested by

no test coverage detected