001/*
002 * Copyright (c) 2023. The BifroMQ Authors. All Rights Reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *    http://www.apache.org/licenses/LICENSE-2.0
008 * Unless required by applicable law or agreed to in writing,
009 * software distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and limitations under the License.
012 */
013
014package com.baidu.bifromq.plugin.settingprovider;
015
016import org.pf4j.ExtensionPoint;
017
018public interface ISettingProvider extends ExtensionPoint {
019    /**
020     * Provide a value of the setting for given tenant. The method will be called by BifroMQ working thread, so it's
021     * expected to be performant and non-blocking otherwise the overall performance will be greatly impacted. It's
022     * allowed to return null to reuse the current setting value, in case the value could not be determined in timely
023     * manner.
024     *
025     * @param setting  the setting for the client
026     * @param tenantId the id of the calling tenant
027     * @return the setting value for the client or null
028     */
029    <R> R provide(Setting setting, String tenantId);
030
031    /**
032     * This method will be called during broker shutdown
033     */
034    default void close() {
035
036    }
037}