All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.qsy7.data.pipe.modules.event.bus.ShellSink Maven / Gradle / Ivy

package io.github.qsy7.data.pipe.modules.event.bus;

import io.github.qsy7.data.pipe.impl.AbstractSink;
import io.github.qsy7.data.pipe.modules.event.bus.api.model.ShellSinkConfiguration;
import io.github.qsy7.shell.api.model.ShellCommand;
import io.github.qsy7.shell.api.service.ShellExecutionService;
import jakarta.inject.Inject;

public class ShellSink extends AbstractSink {
  protected final ShellExecutionService shellExecutionService;

  @Inject
  public ShellSink(ShellExecutionService shellExecutionService) {

    this.shellExecutionService = shellExecutionService;
  }

  @Override
  protected void doConfigure() {}

  @Override
  public void accept(String record) {
    try {
      shellExecutionService.run(new ShellCommand().withCommandLine(record));
    } catch (Exception e) {
      throw new RuntimeException("Error running command", e);
    }
  }

  public void close() {
    // shellExecutionService.kill(shellCommand);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy