Class SchemaManager
java.lang.Object
io.stargate.sgv2.api.common.schema.SchemaManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>cacheKeyspace(String keyspaceName, Optional<String> tenantId, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace) protected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>fetchKeyspace(String keyspaceName, Optional<String> tenantId, StargateBridge bridge) io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>getKeyspace(String keyspace) Get the keyspace from the bridge.io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>getKeyspace(String keyspace, boolean validateHash) Get the keyspace from the bridge.io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>getKeyspaceAuthorized(String keyspace) Get the keyspace from the bridge.io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>getKeyspaceAuthorized(String keyspace, boolean validateHash) Get the keyspace from the bridge.io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>Get all keyspace from the bridge.io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>Get all keyspace from the bridge.io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable>getTable(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get the table from the bridge.io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable>getTableAuthorized(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get the table from the bridge.io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable>getTables(String keyspace, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get all tables of a keyspace from the bridge.io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable>getTablesAuthorized(String keyspace, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get all authorized tables from the bridge.protected io.smallrye.mutiny.Uni<Void>invalidateKeyspace(String keyspaceName, Optional<String> tenantId) io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response>queryWithSchema(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable, io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction) Executes the optimistic query, by fetching the keyspace without authorization from the @SchemaManager.io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response>queryWithSchemaAuthorized(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable, io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction) Executes the optimistic query, by fetching the keyspace with authorization from the @SchemaManager.
-
Constructor Details
-
SchemaManager
public SchemaManager()
-
-
Method Details
-
getKeyspace
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspace(String keyspace) Get the keyspace from the bridge. Note that this method is not doing any authorization. The check that the keyspace has correct hash on the bridge will be done.- Parameters:
keyspace- Keyspace name- Returns:
- Uni containing Schema.CqlKeyspaceDescribe or
nullitem in case keyspace does not exist.
-
getKeyspace
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspace(String keyspace, boolean validateHash) Get the keyspace from the bridge. Note that this method is not doing any authorization.- Parameters:
keyspace- Keyspace namevalidateHash- If hash validation should be done for the keyspace. Iffalseand the keyspace is already cached, then no calls to the bridge are executed.- Returns:
- Uni containing Schema.CqlKeyspaceDescribe or
nullitem in case keyspace does not exist.
-
getKeyspaces
public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspaces()Get all keyspace from the bridge. Note that this method is not doing any authorization. The check that each keyspace has correct hash on the bridge will be done.- Returns:
- Multi containing Schema.CqlKeyspaceDescribe
-
getTable
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable> getTable(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get the table from the bridge. Note that this method is not doing any authorization. The check that the keyspace has correct hash on the bridge will be done.- Parameters:
keyspace- Keyspace nametable- Table namemissingKeyspace- Function of the keyspace in case it's not existing. Usually there to provide a failure.- Returns:
- Uni containing Schema.CqlTable or
nullitem in case the table does not exist.
-
getTables
public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable> getTables(String keyspace, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get all tables of a keyspace from the bridge. The check that the keyspace has correct hash on the bridge will be done.- Parameters:
keyspace- Keyspace namemissingKeyspace- Function of the keyspace in case it's not existing. Usually there to provide a failure.- Returns:
- Multi of Schema.CqlTable
-
getKeyspaceAuthorized
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspaceAuthorized(String keyspace) Get the keyspace from the bridge. Prior to getting the keyspace it will execute the schema authorization request. The check that the keyspace has correct hash on the bridge will be done.Emits a failure in case:
- Not authorized, with
UnauthorizedKeyspaceException
- Parameters:
keyspace- Keyspace name- Returns:
- Uni containing Schema.CqlKeyspaceDescribe or
nullitem in case keyspace does not exist.
- Not authorized, with
-
getKeyspaceAuthorized
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspaceAuthorized(String keyspace, boolean validateHash) Get the keyspace from the bridge. Prior to getting the keyspace it will execute the schema authorization request.Emits a failure in case:
- Not authorized, with
UnauthorizedKeyspaceException
- Parameters:
keyspace- Keyspace namevalidateHash- If hash validation should be done for the keyspace. Iffalseand the keyspace is already cached, then no calls to the bridge are executed.- Returns:
- Uni containing Schema.CqlKeyspaceDescribe or
nullitem in case keyspace does not exist.
- Not authorized, with
-
getKeyspacesAuthorized
public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspacesAuthorized()Get all keyspace from the bridge. Prior to getting each keyspace it will execute the schema authorization request (single request for all available keyspace). The check that each keyspace has correct hash on the bridge will be done.- Returns:
- Multi containing Schema.CqlKeyspaceDescribe
-
getTableAuthorized
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable> getTableAuthorized(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get the table from the bridge. Prior to getting the keyspace it will execute the schema authorization request. The check that the keyspace has correct hash on the bridge will be done.Emits a failure in case:
- Not authorized, with
UnauthorizedTableException
- Parameters:
keyspace- Keyspace nametable- Table namemissingKeyspace- Function of the keyspace in case it's not existing. Usually there to provide a failure.- Returns:
- Uni containing Schema.CqlTable or
nullitem in case the table does not exist.
- Not authorized, with
-
getTablesAuthorized
public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable> getTablesAuthorized(String keyspace, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace) Get all authorized tables from the bridge. The check that the keyspace has correct hash on the bridge will be done.Emits a failure in case:
- Not authorized, with
UnauthorizedTableException
- Parameters:
keyspace- Keyspace namemissingKeyspace- Function of the keyspace in case it's not existing. Usually there to provide a failure.- Returns:
- Multi of Schema.CqlTable
- Not authorized, with
-
queryWithSchema
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response> queryWithSchema(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable, io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction) Executes the optimistic query, by fetching the keyspace without authorization from the @SchemaManager.- Parameters:
keyspace- Keyspace name.table- Table name.missingKeyspace- Function in case the keyspace in case it's not existing. Usually there to * provide a failure.queryFunction- Function that creates the query from theSchema.CqlTable. Note that the table can benull.- Returns:
- Response when optimistic query is executed correctly.
-
queryWithSchemaAuthorized
public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response> queryWithSchemaAuthorized(String keyspace, String table, Function<String, io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable, io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction) Executes the optimistic query, by fetching the keyspace with authorization from the @SchemaManager.- Parameters:
keyspace- Keyspace name.table- Table name.missingKeyspace- Function in case the keyspace in case it's not existing. Usually there to provide a failure.queryFunction- Function that creates the query from theSchema.CqlTable. Note that the table can benull.- Returns:
- Response when optimistic query is executed correctly.
-
fetchKeyspace
protected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> fetchKeyspace(String keyspaceName, Optional<String> tenantId, StargateBridge bridge) -
cacheKeyspace
-
invalidateKeyspace
-