-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #718 from FgForrest/717-client-and-server-timeouts…
…-are-not-aligned fix(#717): Client and server timeouts are not aligned
- Loading branch information
Showing
14 changed files
with
694 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...engine/src/main/java/io/evitadb/core/async/ObservableExecutorServiceWithHardDeadline.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* | ||
* _ _ ____ ____ | ||
* _____ _(_) |_ __ _| _ \| __ ) | ||
* / _ \ \ / / | __/ _` | | | | _ \ | ||
* | __/\ V /| | || (_| | |_| | |_) | | ||
* \___| \_/ |_|\__\__,_|____/|____/ | ||
* | ||
* Copyright (c) 2024 | ||
* | ||
* Licensed under the Business Source License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/FgForrest/evitaDB/blob/master/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.evitadb.core.async; | ||
|
||
|
||
import javax.annotation.Nonnull; | ||
import java.util.concurrent.Callable; | ||
|
||
/** | ||
* This interface extends {@link ObservableExecutorService} and marks a service that actively cancels tasks that exceed | ||
* their specified timeout duration. The default timeout duration for tasks submitted without an explicit timeout is | ||
* specified by {@link #getDefaultTimeoutInMilliseconds()}. | ||
* | ||
* @author Jan Novotný (novotny@fg.cz), FG Forrest a.s. (c) 2024 | ||
*/ | ||
public interface ObservableExecutorServiceWithHardDeadline extends ObservableExecutorService { | ||
|
||
/** | ||
* Retrieves the default timeout value in milliseconds for all tasks submitted without explicit timeout. | ||
* | ||
* @return the default timeout duration in milliseconds | ||
*/ | ||
long getDefaultTimeoutInMilliseconds(); | ||
|
||
/** | ||
* Creates a task with the given name and lambda function to be executed. | ||
* | ||
* @param name the name of the task | ||
* @param lambda the task to be executed | ||
* @return a Runnable representing the task | ||
*/ | ||
@Nonnull | ||
Runnable createTask(@Nonnull String name, @Nonnull Runnable lambda); | ||
|
||
/** | ||
* Creates a task to be executed from the given lambda. | ||
* | ||
* @param lambda the task to be executed | ||
* @return a Runnable representing the task | ||
*/ | ||
@Nonnull | ||
Runnable createTask(@Nonnull Runnable lambda); | ||
|
||
/** | ||
* Creates a task with the given name and lambda function, to be executed with a specified timeout. | ||
* | ||
* @param name the name of the task | ||
* @param lambda the task to be executed | ||
* @param timeoutInMilliseconds the timeout duration in milliseconds | ||
* @return a Runnable representing the task | ||
*/ | ||
@Nonnull | ||
Runnable createTask(@Nonnull String name, @Nonnull Runnable lambda, long timeoutInMilliseconds); | ||
|
||
/** | ||
* Creates a task with the given lambda function, to be executed with a specified timeout. | ||
* | ||
* @param lambda the task to be executed | ||
* @param timeoutInMilliseconds the timeout duration in milliseconds | ||
* @return a Runnable representing the task | ||
*/ | ||
@Nonnull | ||
Runnable createTask(@Nonnull Runnable lambda, long timeoutInMilliseconds); | ||
|
||
/** | ||
* Creates a task with the given name and lambda function to be executed. | ||
* | ||
* @param name the name of the task | ||
* @param lambda the task to be executed | ||
* @param <V> the result type of method call | ||
* @return a Callable representing the task | ||
*/ | ||
@Nonnull | ||
<V> Callable<V> createTask(@Nonnull String name, @Nonnull Callable<V> lambda); | ||
|
||
/** | ||
* Creates a task to be executed from the given lambda. | ||
* | ||
* @param lambda the task to be executed | ||
* @param <V> the result type of method call | ||
* @return a Callable representing the task | ||
*/ | ||
@Nonnull | ||
<V> Callable<V> createTask(@Nonnull Callable<V> lambda); | ||
|
||
/** | ||
* Creates a task with the given name and lambda function, to be executed with a specified timeout. | ||
* | ||
* @param name the name of the task | ||
* @param lambda the task to be executed | ||
* @param timeoutInMilliseconds the timeout duration in milliseconds | ||
* @param <V> the result type of method call | ||
* @return a Callable representing the task | ||
*/ | ||
@Nonnull | ||
<V> Callable<V> createTask(@Nonnull String name, @Nonnull Callable<V> lambda, long timeoutInMilliseconds); | ||
|
||
/** | ||
* Creates a task from the given lambda function, to be executed with a specified timeout. | ||
* | ||
* @param lambda the task to be executed | ||
* @param timeoutInMilliseconds the timeout duration in milliseconds | ||
* @param <V> the result type of method call | ||
* @return a Callable representing the task | ||
*/ | ||
@Nonnull | ||
<V> Callable<V> createTask(@Nonnull Callable<V> lambda, long timeoutInMilliseconds); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.