/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2026. 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.
 */

/**
 * Description: Abstract storage client for aggregated persistence backends.
 */

#ifndef DATASYSTEM_COMMON_L2CACHE_STORAGE_CLIENT_H
#define DATASYSTEM_COMMON_L2CACHE_STORAGE_CLIENT_H

#include <iostream>
#include <memory>
#include <sstream>
#include <string>

#include "datasystem/common/l2cache/slot_client/slot_transfer.h"
#include "datasystem/object/object_enum.h"

namespace datasystem {
class StorageClient {
public:
    virtual ~StorageClient() = default;

    virtual Status Init() = 0;

    virtual Status Save(const std::string &objectKey, uint64_t version, int64_t timeoutMs,
                        const std::shared_ptr<std::iostream> &body, uint64_t asyncElapse = 0,
                        WriteMode writeMode = WriteMode::NONE_L2_CACHE, uint32_t ttlSecond = 0) = 0;

    virtual Status Get(const std::string &objectKey, uint64_t version, int64_t timeoutMs,
                       std::shared_ptr<std::stringstream> &content) = 0;

    virtual Status GetWithoutVersion(const std::string &objectKey, int64_t timeoutMs, uint64_t minVersion,
                                     std::shared_ptr<std::stringstream> &content) = 0;

    virtual Status Delete(const std::string &objectKey, uint64_t maxVerToDelete, bool deleteAllVersion,
                          uint64_t asyncElapse = 0) = 0;

    virtual Status PreloadSlot(const std::string &sourceWorkerAddress, uint32_t slotId,
                               const SlotPreloadCallback &callback = SlotPreloadCallback{}) = 0;

    virtual Status MergeSlot(const std::string &sourceWorkerAddress, uint32_t slotId) = 0;

    virtual Status CleanupLocalSlots() = 0;

    virtual std::string GetRequestSuccessRate() const = 0;
};
}  // namespace datasystem

#endif  // DATASYSTEM_COMMON_L2CACHE_STORAGE_CLIENT_H