public interface DbClientServiceContext
Interceptor context to get (and possibly manipulate) database operations.
This is a mutable object - acts as a builder during the invocation of DbClientService
.
The interceptors are executed sequentially, so there is no need for synchronization.
-
Method Summary
Modifier and TypeMethodDescriptioncontext()
Context with parameters passed from the caller, such asSpanContext
for tracing.Set a new context to be used by other interceptors and when executing the statement.static DbClientServiceContext
Create a new interceptor context for a database provider.dbType()
Type of this database (usually the same string used by theDbClientProvider.name()
).Indexed parameters (if used).boolean
Whether this is a statement with indexed parameters.boolean
isNamed()
Whether this is a statement with named parameters.Named parameters (if used).parameters
(List<Object> indexedParameters) Set new indexed parameters to be used.parameters
(Map<String, Object> namedParameters) Set new named parameters to be used.A stage that is completed once the results were fully read.resultFuture
(CompletionStage<Long> queryFuture) Set a new future to mark completion of the result (e.g.Text of the statement to be executed.Set a new statement with indexed parameters to be used.Set a new statement with named parameters to be used.A stage that is completed once the statement finishes execution.statementFuture
(CompletionStage<Void> statementFuture) Set a new future to mark completion of the statement.Name of a statement to be executed.statementName
(String newName) Set a new statement name to be used.Type of the statement being executed.statementType
(DbStatementType type) Set the type of the statement.
-
Method Details
-
create
Create a new interceptor context for a database provider.- Parameters:
dbType
- a short name of the db type (such as jdbc:mysql)- Returns:
- a new interceptor context ready to be configured
-
dbType
String dbType()Type of this database (usually the same string used by theDbClientProvider.name()
).- Returns:
- type of database
-
context
Context context()Context with parameters passed from the caller, such asSpanContext
for tracing.- Returns:
- context associated with this request
-
statementName
String statementName()Name of a statement to be executed. Ad hoc statements have names generated.- Returns:
- name of the statement
-
statement
String statement()Text of the statement to be executed.- Returns:
- statement text
-
statementFuture
CompletionStage<Void> statementFuture()A stage that is completed once the statement finishes execution.- Returns:
- statement future
-
resultFuture
CompletionStage<Long> resultFuture()A stage that is completed once the results were fully read. The number returns either the number of modified records or the number of records actually read.- Returns:
- stage that completes once all query results were processed.
-
indexedParameters
Indexed parameters (if used).- Returns:
- indexed parameters (empty if this statement parameters are not indexed)
-
namedParameters
Named parameters (if used).- Returns:
- named parameters (empty if this statement parameters are not named)
-
isIndexed
boolean isIndexed()Whether this is a statement with indexed parameters.- Returns:
- Whether this statement has indexed parameters (
true
) or named parametersfalse
.
-
isNamed
boolean isNamed()Whether this is a statement with named parameters.- Returns:
- Whether this statement has named parameters (
true
) or indexed parametersfalse
.
-
statementType
DbStatementType statementType()Type of the statement being executed.- Returns:
- statement type
-
context
Set a new context to be used by other interceptors and when executing the statement.- Parameters:
context
- context to use- Returns:
- updated interceptor context
-
statementName
Set a new statement name to be used.- Parameters:
newName
- statement name to use- Returns:
- updated interceptor context
-
statementFuture
Set a new future to mark completion of the statement.- Parameters:
statementFuture
- future- Returns:
- updated interceptor context
-
resultFuture
Set a new future to mark completion of the result (e.g. query or number of modified records).- Parameters:
queryFuture
- future- Returns:
- updated interceptor context
-
statement
Set a new statement with indexed parameters to be used.- Parameters:
statement
- statement textindexedParams
- indexed parameters- Returns:
- updated interceptor context
-
statement
Set a new statement with named parameters to be used.- Parameters:
statement
- statement textnamedParams
- named parameters- Returns:
- updated interceptor context
-
parameters
Set new indexed parameters to be used.- Parameters:
indexedParameters
- parameters- Returns:
- updated interceptor context
- Throws:
IllegalArgumentException
- in case the statement is using named parameters
-
parameters
Set new named parameters to be used.- Parameters:
namedParameters
- parameters- Returns:
- updated interceptor context
- Throws:
IllegalArgumentException
- in case the statement is using indexed parameters
-
statementType
Set the type of the statement.- Parameters:
type
- statement type- Returns:
- updated interceptor context
-