Skip to content

Commit

Permalink
feat(core): add outputs and ID to log shippers
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Jan 9, 2025
1 parent e09e216 commit a994120
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
package io.kestra.core.models.tasks.logs;

import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.models.tasks.Output;
import io.kestra.core.models.tasks.runners.TaskRunnerDetailResult;
import io.kestra.core.runners.RunContext;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import reactor.core.publisher.Flux;

@Plugin
public abstract class LogShipper implements io.kestra.core.models.Plugin {
@SuperBuilder(toBuilder = true)
@Getter
@NoArgsConstructor
public abstract class LogShipper<T extends Output> implements io.kestra.core.models.Plugin {
@NotNull
@NotBlank
@Pattern(regexp="^[a-zA-Z0-9][a-zA-Z0-9_-]*")
protected String id;

@NotBlank
@Pattern(regexp="\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*(\\.\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)*")
protected String type;

public abstract void sendLogs(RunContext runContext, Flux<LogRecord> logRecord);
public abstract T sendLogs(RunContext runContext, Flux<LogRecord> logRecord) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,11 @@ public static class BetaTask extends Task {
private String beta;
}

public static class TestLogShipper extends LogShipper {
public static class TestLogShipper extends LogShipper<VoidOutput> {

@Override
public void sendLogs(RunContext runContext, Flux<LogRecord> logRecord) {}
public VoidOutput sendLogs(RunContext runContext, Flux<LogRecord> logRecord) throws Exception {
return null;
}
}
}

0 comments on commit a994120

Please sign in to comment.