Package io.stargate.sgv2.api.common.grpc
Interface StargateBridgeClient
- All Known Implementing Classes:
StargateBridgeClientImpl
public interface StargateBridgeClient
A future-based/synchronous facade to access the Stargate bridge.
This is intended as a transitional solution to migrate code that was not previously based on
Quarkus. Most new code should prefer the Mutiny-based APIs: StargateBridge and SchemaManager.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanauthorizeSchemaRead(io.stargate.bridge.proto.Schema.SchemaRead schemaRead) Convenience method to callauthorizeSchemaReads(List)with a single element.default CompletionStage<Boolean>authorizeSchemaReadAsync(io.stargate.bridge.proto.Schema.SchemaRead schemaRead) Convenience method to callauthorizeSchemaReadsAsync(List)with a single element.authorizeSchemaReads(List<io.stargate.bridge.proto.Schema.SchemaRead> schemaReads) authorizeSchemaReadsAsync(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.default io.stargate.bridge.proto.QueryOuterClass.ResponseexecuteBatch(io.stargate.bridge.proto.QueryOuterClass.Batch batch) CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response>executeBatchAsync(io.stargate.bridge.proto.QueryOuterClass.Batch batch) Executes a CQL batch.default io.stargate.bridge.proto.QueryOuterClass.ResponseexecuteQuery(io.stargate.bridge.proto.QueryOuterClass.Query query) default io.stargate.bridge.proto.QueryOuterClass.ResponseexecuteQuery(String keyspaceName, String tableName, Function<Optional<io.stargate.bridge.proto.Schema.CqlTable>, io.stargate.bridge.proto.QueryOuterClass.Query> queryProducer) 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.default List<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>CompletionStage<List<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>>Gets the metadata describing all the keyspaces that are visible to this client.default Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>getKeyspace(String keyspaceName, boolean checkIfAuthorized) CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>>getKeyspaceAsync(String keyspaceName, boolean checkIfAuthorized) Gets the metadata describing the given keyspace.default io.stargate.bridge.proto.Schema.SupportedFeaturesResponseCompletionStage<io.stargate.bridge.proto.Schema.SupportedFeaturesResponse>Checks which features are supported by the persistence backend.default Optional<io.stargate.bridge.proto.Schema.CqlTable>CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlTable>>getTableAsync(String keyspaceName, String tableName, boolean checkIfAuthorized) Gets the metadata describing the given table.default List<io.stargate.bridge.proto.Schema.CqlTable>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.
-
Method Details
-
executeQueryAsync
CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response> executeQueryAsync(io.stargate.bridge.proto.QueryOuterClass.Query query) Executes a CQL query.Authorization is automatically handled by the persistence backend.
-
executeQueryAsync
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.- Parameters:
queryProducer- 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).
-
executeQuery
default io.stargate.bridge.proto.QueryOuterClass.Response executeQuery(io.stargate.bridge.proto.QueryOuterClass.Query query) - See Also:
-
executeQuery
-
executeBatchAsync
CompletionStage<io.stargate.bridge.proto.QueryOuterClass.Response> executeBatchAsync(io.stargate.bridge.proto.QueryOuterClass.Batch batch) Executes a CQL batch.Authorization is automatically handled by the persistence backend.
-
executeBatch
default io.stargate.bridge.proto.QueryOuterClass.Response executeBatch(io.stargate.bridge.proto.QueryOuterClass.Batch batch) - See Also:
-
getKeyspaceAsync
CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> getKeyspaceAsync(String keyspaceName, boolean checkIfAuthorized) Gets the metadata describing the given keyspace.- Parameters:
checkIfAuthorized- 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 sinceexecuteQueryAsync(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.- Throws:
UnauthorizedKeyspaceException- (wrapped in the returned future) ifcheckIfAuthorizedis set, and the client is not allowed to access this keyspace. However, this check is shallow: if the caller surfaces keyspace elements (tables, UDTs...) to the end user, it must authorize them individually withauthorizeSchemaReads(List).
-
getKeyspace
default Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspace(String keyspaceName, boolean checkIfAuthorized) throws UnauthorizedKeyspaceException - Throws:
UnauthorizedKeyspaceException- See Also:
-
getAllKeyspacesAsync
CompletionStage<List<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> getAllKeyspacesAsync()Gets 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
authorizeSchemaReads(List). -
getAllKeyspaces
- See Also:
-
decorateKeyspaceName
Converts 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(). -
getTableAsync
CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlTable>> getTableAsync(String keyspaceName, String tableName, boolean checkIfAuthorized) Gets the metadata describing the given table.- Parameters:
checkIfAuthorized- see explanations ingetKeyspaceAsync(String, boolean).- Throws:
UnauthorizedTableException- (wrapped in the returned future) ifcheckIfAuthorizedis set, and the client is not allowed to access this table.
-
getTable
default Optional<io.stargate.bridge.proto.Schema.CqlTable> getTable(String keyspaceName, String tableName, boolean checkIfAuthorized) throws UnauthorizedTableException - Throws:
UnauthorizedTableException- See Also:
-
getTablesAsync
Gets the metadata describing all the tables that are visible to this client in the given keyspace.This method automatically filters out unauthorized tables.
-
getTables
- See Also:
-
authorizeSchemaReadsAsync
CompletionStage<List<Boolean>> authorizeSchemaReadsAsync(List<io.stargate.bridge.proto.Schema.SchemaRead> schemaReads) Checks whether this client is authorized to describe a set of schema elements.- See Also:
-
authorizeSchemaReads
default List<Boolean> authorizeSchemaReads(List<io.stargate.bridge.proto.Schema.SchemaRead> schemaReads) - See Also:
-
authorizeSchemaReadAsync
default CompletionStage<Boolean> authorizeSchemaReadAsync(io.stargate.bridge.proto.Schema.SchemaRead schemaRead) Convenience method to callauthorizeSchemaReadsAsync(List)with a single element.- See Also:
-
authorizeSchemaRead
default boolean authorizeSchemaRead(io.stargate.bridge.proto.Schema.SchemaRead schemaRead) Convenience method to callauthorizeSchemaReads(List)with a single element.- See Also:
-
getSupportedFeaturesAsync
CompletionStage<io.stargate.bridge.proto.Schema.SupportedFeaturesResponse> getSupportedFeaturesAsync()Checks which features are supported by the persistence backend. -
getSupportedFeatures
default io.stargate.bridge.proto.Schema.SupportedFeaturesResponse getSupportedFeatures()- See Also:
-