All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.streamnative.pulsar.handlers.kop.schemaregistry.model.LookupCache Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2019 - 2024 StreamNative, Inc.. All Rights Reserved.
 */
/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.streamnative.pulsar.handlers.kop.schemaregistry.model;

import io.streamnative.pulsar.handlers.kop.schemaregistry.model.impl.SchemaIdAndSubjects;
import java.util.Set;

public interface LookupCache extends Store {

    /**
     * Provides SchemaIdAndSubjects associated with the schema.
     *
     * @param schema schema object; never {@code null}
     * @return the schema id and subjects associated with the schema, null otherwise.
     */
    SchemaIdAndSubjects schemaIdAndSubjects(Schema schema);

    /**
     * Returns schemas that reference the given schema.
     *
     * @param schema schema object
     * @return the ids of schemas that reference the given schema
     */
    Set referencesSchema(SchemaKey schema);

    /**
     * Provides the {@link SchemaKey} for the provided schema id.
     *
     * @param id the schema id; never {@code null}
     * @param subject the qualified context or subject
     * @return the {@link SchemaKey} if found, otherwise null.
     */
    SchemaKey schemaKeyById(Integer id, String subject);

    /**
     * Callback that is invoked when a schema is registered.
     * This can be used to update any internal data structure.
     * This is invoked synchronously during register.
     *
     * @param schemaKey   the registered SchemaKey; never {@code null}
     * @param schemaValue the registered SchemaValue; never {@code null}
     */
    void schemaRegistered(SchemaKey schemaKey, SchemaValue schemaValue);

    /**
     * Callback that is invoked when a schema is deleted.
     * This can be used to update any internal data structure.
     * This is invoked synchronously during delete.
     *
     * @param schemaKey   the deleted SchemaKey; never {@code null}
     * @param schemaValue the deleted SchemaValue; never {@code null}
     */
    void schemaDeleted(SchemaKey schemaKey, SchemaValue schemaValue);

    /**
     * Callback that is invoked when a schema is tombstoned.
     *
     * @param schemaKey   the tombstoned SchemaKey; never {@code null}
     * @param schemaValue the tombstoned SchemaValue
     */
    void schemaTombstoned(SchemaKey schemaKey, SchemaValue schemaValue);

    /**
     * Returns subjects that have schemas (that are not deleted) that match the given subject.
     *
     * @param subject the subject, or null for all subjects
     * @return the subjects with matching schemas
     */
    Set subjects(String subject, boolean lookupDeletedSubjects);

    /**
     * Returns whether there exist schemas (that are not deleted) that match the given subject.
     *
     * @param subject the subject, or null for all subjects
     * @return whether there exist matching schemas
     */
    boolean hasSubjects(String subject, boolean lookupDeletedSubjects);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy