# FlowAction

@Incubating
interface FlowAction<P : FlowParameters?>

A dataflow action.

A parameterized and isolated piece of work that becomes eligible for execution within a dataflow scope as soon as all of its input parameters become available.

Implementations can benefit from constructor injection of services using the @Inject annotation. Currently, only a small subset of services is supported:

- ArchiveOperations provides means to operate on archives such as ZIP or TAR files.
- ExecOperations provides means to execute external processes.
- FileSystemOperations provides means to operate on the file system.

    /**
     * Plays a given {@link Parameters#getMediaFile() media file} using {@code ffplay}.
     */
    class FFPlay implements FlowAction<FFPlay.Parameters> {

        interface Parameters extends FlowParameters {
            @Input
            Property<File> getMediaFile();
        }

        private final ExecOperations execOperations;

        @Inject
        FFPlay(ExecOperations execOperations) {
            this.execOperations = execOperations;
        }

        @Override
        public void execute(Parameters parameters) throws Exception {
            execOperations.exec(spec -> {
                spec.commandLine(
                    "ffplay", "-nodisp", "-autoexit", "-hide_banner", "-loglevel", "quiet",
                    parameters.getMediaFile().get().getAbsolutePath()
                );
                spec.setIgnoreExitValue(true);
            });
        }
    }

Content copied to clipboard

#### Since

8.1

#### Parameters

<P>

Parameter type for the dataflow action. Should be FlowParameters.None if the action does not have parameters.

#### See also

FlowScope
FlowProviders

## Functions

execute
Link copied to clipboard
abstract fun execute(parameters: P)