Package io.stargate.sgv2.api.common.grpc
Class StargateBridgeClientImpl
java.lang.Object
io.stargate.sgv2.api.common.grpc.StargateBridgeClientImpl
- All Implemented Interfaces:
StargateBridgeClient
@ApplicationScoped
public class StargateBridgeClientImpl
extends Object
implements StargateBridgeClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthorizeSchemaReadsAsync(List<io.stargate.bridge.proto.Schema.SchemaRead> schemaReads) Checks whether this client is authorized to describe a set of schema elements.decorateKeyspaceName(String keyspaceName) Converts a keyspace name used by this client to the "global" one actually used by the persistence backend.CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response>executeBatchAsync(io.stargate.bridge.proto.QueryOuterClass.Batch batch) Executes a CQL batch.CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response>executeQueryAsync(io.stargate.bridge.proto.QueryOuterClass.Query query) Executes a CQL query.CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response>executeQueryAsync(String keyspaceName, String tableName, Function<Optional<io.stargate.bridge.proto.Schema.CqlTable>, io.stargate.bridge.proto.QueryOuterClass.Query> queryProducer) Builds a CQL query based on the definition of a table, and executes it.CompletionStage<List<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>>Gets the metadata describing all the keyspaces that are visible to this client.CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>>getKeyspaceAsync(String keyspaceName, boolean checkIfAuthorized) Gets the metadata describing the given keyspace.CompletionStage<io.stargate.bridge.proto.Schema.SupportedFeaturesResponse>Checks which features are supported by the persistence backend.CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlTable>>getTableAsync(String keyspaceName, String tableName, boolean checkIfAuthorized) Gets the metadata describing the given table.CompletionStage<List<io.stargate.bridge.proto.Schema.CqlTable>>getTablesAsync(String keyspaceName) Gets the metadata describing all the tables that are visible to this client in the given keyspace.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.stargate.sgv2.api.common.grpc.StargateBridgeClient
authorizeSchemaRead, authorizeSchemaReadAsync, authorizeSchemaReads, executeBatch, executeQuery, executeQuery, getAllKeyspaces, getKeyspace, getSupportedFeatures, getTable, getTables
-
Constructor Details
-
StargateBridgeClientImpl
public StargateBridgeClientImpl()
-
-
Method Details
-
executeQueryAsync
public CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response> executeQueryAsync(io.stargate.bridge.proto.QueryOuterClass.Query query) Description copied from interface:StargateBridgeClientExecutes a CQL query.Authorization is automatically handled by the persistence backend.
- Specified by:
executeQueryAsyncin interfaceStargateBridgeClient
-
executeQueryAsync
public CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response> executeQueryAsync(String keyspaceName, String tableName, Function<Optional<io.stargate.bridge.proto.Schema.CqlTable>, io.stargate.bridge.proto.QueryOuterClass.Query> queryProducer) Description copied from interface:StargateBridgeClientBuilds a CQL query based on the definition of a table, and executes it.- Specified by:
executeQueryAsyncin interfaceStargateBridgeClientqueryProducer- the function that builds the query. It will receiveOptional.empty()if the table does not exist. Note that it may be invoked more than once (the implementation uses an optimistic approach to avoid systematically pre-fetching the table definition, so it may have to retry).
-
executeBatchAsync
public CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response> executeBatchAsync(io.stargate.bridge.proto.QueryOuterClass.Batch batch) Description copied from interface:StargateBridgeClientExecutes a CQL batch.Authorization is automatically handled by the persistence backend.
- Specified by:
executeBatchAsyncin interfaceStargateBridgeClient
-
getKeyspaceAsync
public CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> getKeyspaceAsync(String keyspaceName, boolean checkIfAuthorized) Description copied from interface:StargateBridgeClientGets the metadata describing the given keyspace.- Specified by:
getKeyspaceAsyncin interfaceStargateBridgeClientcheckIfAuthorized- whether to check if the current user is allowed to describe this keyspace (this requires an additional background call to the bridge). This is an optimization: if you only use the schema metadata to build a DML query that will be executed immediately after, you can skip authorization sinceStargateBridgeClient.executeQueryAsync(Query)does it automatically. However, if there is no other query and you build a client response directly from the metadata, then authorization should be done by this method.
-
getAllKeyspacesAsync
public CompletionStage<List<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> getAllKeyspacesAsync()Description copied from interface:StargateBridgeClientGets the metadata describing all the keyspaces that are visible to this client.This method automatically filters out unauthorized keyspaces. However, this check is shallow: if the caller surfaces keyspace elements (tables, UDTs...) to the end user, it must authorize them individually with
StargateBridgeClient.authorizeSchemaReads(List).- Specified by:
getAllKeyspacesAsyncin interfaceStargateBridgeClient
-
decorateKeyspaceName
Description copied from interface:StargateBridgeClientConverts a keyspace name used by this client to the "global" one actually used by the persistence backend. In other words, this provides a way to computeSchema.CqlKeyspace.getGlobalName()fromSchema.CqlKeyspace.getName().- Specified by:
decorateKeyspaceNamein interfaceStargateBridgeClient
-
getTableAsync
public CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlTable>> getTableAsync(String keyspaceName, String tableName, boolean checkIfAuthorized) Description copied from interface:StargateBridgeClientGets the metadata describing the given table.- Specified by:
getTableAsyncin interfaceStargateBridgeClientcheckIfAuthorized- see explanations inStargateBridgeClient.getKeyspaceAsync(String, boolean).
-
getTablesAsync
public CompletionStage<List<io.stargate.bridge.proto.Schema.CqlTable>> getTablesAsync(String keyspaceName) Description copied from interface:StargateBridgeClientGets the metadata describing all the tables that are visible to this client in the given keyspace.This method automatically filters out unauthorized tables.
- Specified by:
getTablesAsyncin interfaceStargateBridgeClient
-
authorizeSchemaReadsAsync
public CompletionStage<List<Boolean>> authorizeSchemaReadsAsync(List<io.stargate.bridge.proto.Schema.SchemaRead> schemaReads) Description copied from interface:StargateBridgeClientChecks whether this client is authorized to describe a set of schema elements.- Specified by:
authorizeSchemaReadsAsyncin interfaceStargateBridgeClient- See Also:
-
getSupportedFeaturesAsync
public CompletionStage<io.stargate.bridge.proto.Schema.SupportedFeaturesResponse> getSupportedFeaturesAsync()Description copied from interface:StargateBridgeClientChecks which features are supported by the persistence backend.- Specified by:
getSupportedFeaturesAsyncin interfaceStargateBridgeClient
-