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 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: StargateBridgeClient
      Executes a CQL query.

      Authorization is automatically handled by the persistence backend.

      Specified by:
      executeQueryAsync in interface StargateBridgeClient
    • 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: StargateBridgeClient
      Builds a CQL query based on the definition of a table, and executes it.
      Specified by:
      executeQueryAsync in interface StargateBridgeClient
      queryProducer - the function that builds the query. It will receive Optional.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: StargateBridgeClient
      Executes a CQL batch.

      Authorization is automatically handled by the persistence backend.

      Specified by:
      executeBatchAsync in interface StargateBridgeClient
    • getKeyspaceAsync

      public CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> getKeyspaceAsync(String keyspaceName, boolean checkIfAuthorized)
      Description copied from interface: StargateBridgeClient
      Gets the metadata describing the given keyspace.
      Specified by:
      getKeyspaceAsync in interface StargateBridgeClient
      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 since StargateBridgeClient.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: StargateBridgeClient
      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 StargateBridgeClient.authorizeSchemaReads(List).

      Specified by:
      getAllKeyspacesAsync in interface StargateBridgeClient
    • decorateKeyspaceName

      public String decorateKeyspaceName(String keyspaceName)
      Description copied from interface: StargateBridgeClient
      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 compute Schema.CqlKeyspace.getGlobalName() from Schema.CqlKeyspace.getName().
      Specified by:
      decorateKeyspaceName in interface StargateBridgeClient
    • getTableAsync

      public CompletionStage<Optional<io.stargate.bridge.proto.Schema.CqlTable>> getTableAsync(String keyspaceName, String tableName, boolean checkIfAuthorized)
      Description copied from interface: StargateBridgeClient
      Gets the metadata describing the given table.
      Specified by:
      getTableAsync in interface StargateBridgeClient
      checkIfAuthorized - see explanations in StargateBridgeClient.getKeyspaceAsync(String, boolean).
    • getTablesAsync

      public CompletionStage<List<io.stargate.bridge.proto.Schema.CqlTable>> getTablesAsync(String keyspaceName)
      Description copied from interface: StargateBridgeClient
      Gets 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:
      getTablesAsync in interface StargateBridgeClient
    • authorizeSchemaReadsAsync

      public CompletionStage<List<Boolean>> authorizeSchemaReadsAsync(List<io.stargate.bridge.proto.Schema.SchemaRead> schemaReads)
      Description copied from interface: StargateBridgeClient
      Checks whether this client is authorized to describe a set of schema elements.
      Specified by:
      authorizeSchemaReadsAsync in interface StargateBridgeClient
      See Also:
    • getSupportedFeaturesAsync

      public CompletionStage<io.stargate.bridge.proto.Schema.SupportedFeaturesResponse> getSupportedFeaturesAsync()
      Description copied from interface: StargateBridgeClient
      Checks which features are supported by the persistence backend.
      Specified by:
      getSupportedFeaturesAsync in interface StargateBridgeClient