-
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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Context
context()
Context with parameters passed from the caller, such asSpanContext
for tracing.DbClientServiceContext
context(Context context)
Set a new context to be used by other interceptors and when executing the statement.static DbClientServiceContext
create(String dbType)
Create a new interceptor context for a database provider.String
dbType()
Type of this database (usually the same string used by theDbClientProvider.name()
).Optional<List<Object>>
indexedParameters()
Indexed parameters (if used).boolean
isIndexed()
Whether this is a statement with indexed parameters.boolean
isNamed()
Whether this is a statement with named parameters.Optional<Map<String,Object>>
namedParameters()
Named parameters (if used).DbClientServiceContext
parameters(List<Object> indexedParameters)
Set new indexed parameters to be used.DbClientServiceContext
parameters(Map<String,Object> namedParameters)
Set new named parameters to be used.CompletionStage<Long>
resultFuture()
A stage that is completed once the results were fully read.DbClientServiceContext
resultFuture(CompletionStage<Long> queryFuture)
Set a new future to mark completion of the result (e.g.String
statement()
Text of the statement to be executed.DbClientServiceContext
statement(String statement, List<Object> indexedParams)
Set a new statement with indexed parameters to be used.DbClientServiceContext
statement(String statement, Map<String,Object> namedParams)
Set a new statement with named parameters to be used.CompletionStage<Void>
statementFuture()
A stage that is completed once the statement finishes execution.DbClientServiceContext
statementFuture(CompletionStage<Void> statementFuture)
Set a new future to mark completion of the statement.String
statementName()
Name of a statement to be executed.DbClientServiceContext
statementName(String newName)
Set a new statement name to be used.DbStatementType
statementType()
Type of the statement being executed.DbClientServiceContext
statementType(DbStatementType type)
Set the type of the statement.
-
-
-
Method Detail
-
create
static DbClientServiceContext create(String dbType)
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
Optional<List<Object>> indexedParameters()
Indexed parameters (if used).- Returns:
- indexed parameters (empty if this statement parameters are not indexed)
-
namedParameters
Optional<Map<String,Object>> 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
DbClientServiceContext context(Context 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
DbClientServiceContext statementName(String newName)
Set a new statement name to be used.- Parameters:
newName
- statement name to use- Returns:
- updated interceptor context
-
statementFuture
DbClientServiceContext statementFuture(CompletionStage<Void> statementFuture)
Set a new future to mark completion of the statement.- Parameters:
statementFuture
- future- Returns:
- updated interceptor context
-
resultFuture
DbClientServiceContext resultFuture(CompletionStage<Long> queryFuture)
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
DbClientServiceContext statement(String statement, List<Object> indexedParams)
Set a new statement with indexed parameters to be used.- Parameters:
statement
- statement textindexedParams
- indexed parameters- Returns:
- updated interceptor context
-
statement
DbClientServiceContext statement(String statement, Map<String,Object> namedParams)
Set a new statement with named parameters to be used.- Parameters:
statement
- statement textnamedParams
- named parameters- Returns:
- updated interceptor context
-
parameters
DbClientServiceContext parameters(List<Object> indexedParameters)
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
DbClientServiceContext parameters(Map<String,Object> namedParameters)
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
DbClientServiceContext statementType(DbStatementType type)
Set the type of the statement.- Parameters:
type
- statement type- Returns:
- updated interceptor context
-
-