java.lang.Object
io.evitadb.driver.EvitaClient
- All Implemented Interfaces:
EvitaContract,AutoCloseable
The EvitaClient implements
EvitaContract interface and aims to behave identically as if the evitaDB is used
as an embedded engine. The purpose is to switch between the client & server setup and the single server setup
seamlessly. The client & server implementation takes advantage of gRPC API that is best suited for fast communication
between two endpoints if both parties are Java based.
The class is thread-safe and can be used from multiple threads to acquire EvitaClientSession that are not
thread-safe.- Author:
- Jan Novotný (novotny@fg.cz), FG Forrest a.s. (c) 2022
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEvitaClient(EvitaClientConfiguration configuration) EvitaClient(EvitaClientConfiguration configuration, Consumer<com.linecorp.armeria.client.grpc.GrpcClientBuilder> grpcConfigurator) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidVerifies this instance is still active.voidclose()createSession(SessionTraits traits) defineCatalog(String catalogName) booleandeleteCatalogIfExists(String catalogName) voidexecuteWithExtendedTimeout(Runnable lambda, long timeout, TimeUnit unit) Method executes lambda using specified timeout for the call ignoring the defaults specified inEvitaClientConfiguration.timeout().<T> TexecuteWithExtendedTimeout(Supplier<T> lambda, long timeout, TimeUnit unit) Method executes lambda using specified timeout for the call ignoring the defaults specified inEvitaClientConfiguration.timeout().getSessionById(UUID uuid) Retrieves the version number of the evitaDB client.booleanisActive()voidqueryCatalog(String catalogName, Consumer<EvitaSessionContract> queryLogic, SessionTraits.SessionFlags... flags) <T> TqueryCatalog(String catalogName, Function<EvitaSessionContract, T> queryLogic, SessionTraits.SessionFlags... flags) <T> CompletableFuture<T>queryCatalogAsync(String catalogName, Function<EvitaSessionContract, T> queryLogic, SessionTraits.SessionFlags... flags) voidrenameCatalog(String catalogName, String newCatalogName) voidreplaceCatalog(String catalogNameToBeReplacedWith, String catalogNameToBeReplaced) voidterminateSession(EvitaSessionContract session) voidupdate(TopLevelCatalogSchemaMutation... catalogMutations) voidupdateCatalog(String catalogName, Consumer<EvitaSessionContract> updater, TransactionContract.CommitBehavior commitBehaviour, SessionTraits.SessionFlags... flags) <T> TupdateCatalog(String catalogName, Function<EvitaSessionContract, T> updater, TransactionContract.CommitBehavior commitBehaviour, SessionTraits.SessionFlags... flags) updateCatalogAsync(String catalogName, Consumer<EvitaSessionContract> updater, TransactionContract.CommitBehavior commitBehaviour, SessionTraits.SessionFlags... flags) <T> CompletableFuture<T>updateCatalogAsync(String catalogName, Function<EvitaSessionContract, T> updater, TransactionContract.CommitBehavior commitBehaviour, SessionTraits.SessionFlags... flags) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.evitadb.api.EvitaContract
createReadOnlySession, createReadWriteSession, updateCatalog, updateCatalog
-
Constructor Details
-
EvitaClient
-
EvitaClient
public EvitaClient(@Nonnull EvitaClientConfiguration configuration, @Nullable Consumer<com.linecorp.armeria.client.grpc.GrpcClientBuilder> grpcConfigurator)
-
-
Method Details
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceEvitaContract
-
createSession
- Specified by:
createSessionin interfaceEvitaContract
-
getSessionById
- Specified by:
getSessionByIdin interfaceEvitaContract
-
terminateSession
- Specified by:
terminateSessionin interfaceEvitaContract
-
getCatalogNames
- Specified by:
getCatalogNamesin interfaceEvitaContract
-
defineCatalog
- Specified by:
defineCatalogin interfaceEvitaContract
-
renameCatalog
- Specified by:
renameCatalogin interfaceEvitaContract
-
replaceCatalog
public void replaceCatalog(@Nonnull String catalogNameToBeReplacedWith, @Nonnull String catalogNameToBeReplaced) - Specified by:
replaceCatalogin interfaceEvitaContract
-
deleteCatalogIfExists
- Specified by:
deleteCatalogIfExistsin interfaceEvitaContract
-
update
- Specified by:
updatein interfaceEvitaContract
-
queryCatalog
public <T> T queryCatalog(@Nonnull String catalogName, @Nonnull Function<EvitaSessionContract, T> queryLogic, @Nullable SessionTraits.SessionFlags... flags) - Specified by:
queryCatalogin interfaceEvitaContract
-
queryCatalog
public void queryCatalog(@Nonnull String catalogName, @Nonnull Consumer<EvitaSessionContract> queryLogic, @Nullable SessionTraits.SessionFlags... flags) - Specified by:
queryCatalogin interfaceEvitaContract
-
queryCatalogAsync
@Nonnull public <T> CompletableFuture<T> queryCatalogAsync(@Nonnull String catalogName, @Nonnull Function<EvitaSessionContract, T> queryLogic, @Nullable SessionTraits.SessionFlags... flags) - Specified by:
queryCatalogAsyncin interfaceEvitaContract
-
updateCatalog
public <T> T updateCatalog(@Nonnull String catalogName, @Nonnull Function<EvitaSessionContract, T> updater, @Nonnull TransactionContract.CommitBehavior commitBehaviour, @Nullable SessionTraits.SessionFlags... flags) - Specified by:
updateCatalogin interfaceEvitaContract
-
updateCatalogAsync
@Nonnull public <T> CompletableFuture<T> updateCatalogAsync(@Nonnull String catalogName, @Nonnull Function<EvitaSessionContract, T> updater, @Nonnull TransactionContract.CommitBehavior commitBehaviour, @Nullable SessionTraits.SessionFlags... flags) - Specified by:
updateCatalogAsyncin interfaceEvitaContract
-
updateCatalog
public void updateCatalog(@Nonnull String catalogName, @Nonnull Consumer<EvitaSessionContract> updater, @Nonnull TransactionContract.CommitBehavior commitBehaviour, @Nullable SessionTraits.SessionFlags... flags) - Specified by:
updateCatalogin interfaceEvitaContract
-
updateCatalogAsync
@Nonnull public CompletableFuture<Long> updateCatalogAsync(@Nonnull String catalogName, @Nonnull Consumer<EvitaSessionContract> updater, @Nonnull TransactionContract.CommitBehavior commitBehaviour, @Nullable SessionTraits.SessionFlags... flags) throws TransactionException - Specified by:
updateCatalogAsyncin interfaceEvitaContract- Throws:
TransactionException
-
management
- Specified by:
managementin interfaceEvitaContract
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getVersion
Retrieves the version number of the evitaDB client.- Returns:
- The version number as a string.
-
executeWithExtendedTimeout
public void executeWithExtendedTimeout(@Nonnull Runnable lambda, long timeout, @Nonnull TimeUnit unit) Method executes lambda using specified timeout for the call ignoring the defaults specified inEvitaClientConfiguration.timeout().- Parameters:
lambda- logic to be executedtimeout- timeout valueunit- time unit of the timeout
-
executeWithExtendedTimeout
public <T> T executeWithExtendedTimeout(@Nonnull Supplier<T> lambda, long timeout, @Nonnull TimeUnit unit) Method executes lambda using specified timeout for the call ignoring the defaults specified inEvitaClientConfiguration.timeout().- Type Parameters:
T- type of the result- Parameters:
lambda- logic to be executedtimeout- timeout valueunit- time unit of the timeout- Returns:
- result of the lambda
-
assertActive
protected void assertActive()Verifies this instance is still active.
-