-
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.
Added "mode" option for crud select operation
Needed for #107
- Loading branch information
Showing
7 changed files
with
94 additions
and
38 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
38 changes: 38 additions & 0 deletions
38
src/main/java/io/tarantool/driver/api/space/options/OperationWithModeOptions.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,38 @@ | ||
package io.tarantool.driver.api.space.options; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Base interface for all operation options that may have a configurable mode. | ||
* | ||
* @author Belonogov Nikolay | ||
*/ | ||
public interface OperationWithModeOptions<T extends OperationWithModeOptions<T>> extends Options, Self<T> { | ||
String MODE = "mode"; | ||
|
||
/** | ||
* Specifies the mode for operations (select, count, get) on a specific node type (mode == "write" - master, mode | ||
* == "read" - replica). By default, mode is "read". | ||
* | ||
* @param mode mode for operations (select, get, count). | ||
* @return this options instance. | ||
*/ | ||
default T withMode(String mode) { | ||
if (!mode.equals("read") && !mode.equals("write")) { | ||
throw new IllegalArgumentException("Mode should be \"read\" or \"write\""); | ||
} | ||
|
||
addOption(MODE, mode); | ||
return self(); | ||
} | ||
|
||
/** | ||
* Return operation mode. | ||
* | ||
* @return mode. | ||
*/ | ||
default Optional<String> getMode() { | ||
return getOption(MODE, String.class); | ||
} | ||
|
||
} |
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