-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add StopOnError enum and refactor public proxy API with it
Closes #419
- Loading branch information
Showing
11 changed files
with
189 additions
and
128 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 2 additions & 11 deletions
13
src/main/java/io/tarantool/driver/api/space/options/InsertManyOptions.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 |
---|---|---|
@@ -1,20 +1,11 @@ | ||
package io.tarantool.driver.api.space.options; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Marker interface for space insert_many operation options | ||
* | ||
* @author Alexey Kuzin | ||
*/ | ||
public interface InsertManyOptions<T extends InsertManyOptions<T>> | ||
extends OperationWithTimeoutOptions<T>, OperationWithFieldsOptions<T>, OperationWithRollbackOnErrorOptions<T> { | ||
|
||
/** | ||
* Return whether the operation should be interrupted if any tuple insertion | ||
* was unsuccesful. | ||
* | ||
* @return true, if the operation should stop on error | ||
*/ | ||
Optional<Boolean> getStopOnError(); | ||
extends OperationWithTimeoutOptions<T>, OperationWithFieldsOptions<T>, OperationWithRollbackOnErrorOptions<T>, | ||
OperationWithStopOnErrorOptions<T> { | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/io/tarantool/driver/api/space/options/OperationWithStopOnErrorOptions.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,36 @@ | ||
package io.tarantool.driver.api.space.options; | ||
|
||
import io.tarantool.driver.api.space.options.enums.crud.StopOnError; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Base interface for all operation options that may have a configurable stop_on_error. | ||
* | ||
* @author Belonogov Nikolay | ||
*/ | ||
public interface OperationWithStopOnErrorOptions<T extends OperationWithStopOnErrorOptions<T>> | ||
extends Options, Self<T> { | ||
|
||
/** | ||
* Specifies whether to not try to insert more tuples into the space if any tuple insert | ||
* operation is unsuccesful. Default value is <code>true</code>. | ||
* | ||
* @param stopOnError should stop batch on error | ||
* @return this options instance | ||
*/ | ||
default T withStopOnError(StopOnError stopOnError) { | ||
addOption(StopOnError.NAME, stopOnError.value()); | ||
return self(); | ||
} | ||
|
||
/** | ||
* Return whether the operation should be interrupted if any tuple replace | ||
* was unsuccesful. | ||
* | ||
* @return true, if the operation should stop on error | ||
*/ | ||
default Optional<Boolean> getStopOnError() { | ||
return getOption(StopOnError.NAME, Boolean.class); | ||
} | ||
} |
13 changes: 2 additions & 11 deletions
13
src/main/java/io/tarantool/driver/api/space/options/ReplaceManyOptions.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 |
---|---|---|
@@ -1,20 +1,11 @@ | ||
package io.tarantool.driver.api.space.options; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Marker interface for space replace_many operation options | ||
* | ||
* @author Alexey Kuzin | ||
*/ | ||
public interface ReplaceManyOptions<T extends ReplaceManyOptions<T>> | ||
extends OperationWithTimeoutOptions<T>, OperationWithFieldsOptions<T>, OperationWithRollbackOnErrorOptions<T> { | ||
|
||
/** | ||
* Return whether the operation should be interrupted if any tuple replace | ||
* was unsuccesful. | ||
* | ||
* @return true, if the operation should stop on error | ||
*/ | ||
Optional<Boolean> getStopOnError(); | ||
extends OperationWithTimeoutOptions<T>, OperationWithFieldsOptions<T>, OperationWithRollbackOnErrorOptions<T>, | ||
OperationWithStopOnErrorOptions<T> { | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/io/tarantool/driver/api/space/options/enums/crud/StopOnError.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,30 @@ | ||
package io.tarantool.driver.api.space.options.enums.crud; | ||
|
||
/** | ||
* Enum represents the CRUD predefined stop_on_error option values. | ||
* | ||
* @author Belonogov Nikolay. | ||
* @see <a href="https://github.com/tarantool/crud">tarantool/crud</a>. | ||
*/ | ||
public enum StopOnError { | ||
|
||
TRUE(true), | ||
|
||
FALSE(false); | ||
|
||
public static final String NAME = "stop_on_error"; | ||
private final boolean value; | ||
|
||
StopOnError(boolean value) { | ||
this.value = value; | ||
} | ||
|
||
public boolean value() { | ||
return this.value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Boolean.toString(this.value); | ||
} | ||
} |
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
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
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