Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated time duration to 30 seconds #5594

Merged
merged 11 commits into from
Oct 23, 2024
55 changes: 55 additions & 0 deletions core/src/main/java/io/kestra/plugin/core/debug/Wait.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.kestra.plugin.core.debug;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package is not the good one, here is the one asked in the original issue :
io.kestra.plugin.core.flow.Sleep
with io.kestra.plugin.core.flow being the package and Sleep being the class name
and this will form the task type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoyounik Please read this, better take your times to make correct changes once than doing it 10 times

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skraye I apologize for the repeated mistakes. I will take my time to ensure that the changes are correct before submitting them again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Skraye
Thanks for the feedback. You're right, "Sleep" might be a more descriptive name for the class.

I can rename the Wait.java class to Sleep.java and update the code accordingly. This would keep the file in the io.kestra.plugin.core.flow package.

Does that sound like a good approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly what's need to be done 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay then i will rename it and update you @Skraye

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Skraye
changes i made:
Wait.java changed to Sleep.java,
wait-task-flow.yml changed to sleep-task-flow.yml and changes inside it to Sleep.
sleep.yml's type has been changed.

going to update these changes now, please go through this once, and thanks for the patience shown :).
Please update me if any changes required.


import io.kestra.core.models.annotations.Example;
import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.runners.RunContext;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

@SuperBuilder
@ToString
@EqualsAndHashCode
@Getter
@NoArgsConstructor
@Schema(
title = "A task that waits for a specified duration before proceeding."
)
@Plugin(
examples = {
@Example(
code = """
id: wait
type: io.kestra.plugin.core.debug.Wait
yoyounik marked this conversation as resolved.
Show resolved Hide resolved
duration: "PT5S"
"""
)
}
)
public class Wait extends Task {
@Schema(
title = "Duration to wait",
description = "The time duration in ISO-8601 format (e.g., `PT5S` for 5 seconds)."
)
@PluginProperty
@NotNull
private Duration duration;

public Void run(RunContext runContext) throws Exception {
runContext.logger().info("Waiting for {}", duration);

// Wait for the specified duration
TimeUnit.MILLISECONDS.sleep(duration.toMillis());

return null;
}
}
2 changes: 1 addition & 1 deletion core/src/test/resources/flows/valids/sleep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace: io.kestra.tests
tasks:
- id: sleep
type: io.kestra.core.tasks.test.Sleep
duration: 1000
duration: 3000 #30 seconds updated
yoyounik marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 17 additions & 0 deletions core/src/test/resources/flows/valids/wait-task-flow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
id: wait-task-flow
namespace: io.kestra.tests

tasks:
- id: wait
type: io.kestra.plugin.core.debug.Wait
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong type

delay: PT10S # Waits for 10 seconds before proceeding

- id: next-task
type: io.kestra.plugin.core.scripts.Shell
commands:
- echo "Wait task completed"

triggers:
yoyounik marked this conversation as resolved.
Show resolved Hide resolved
- id: schedule
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 * * * *"