/*
 * Copyright (c) 2025-2026, Michael Yang 杨福海 (fuhai999@gmail.com).
 * Licensed under the GNU Lesser General Public License (LGPL), Version 3.0.
 */
package com.easyagents.flow.core.chain.repository;

import com.easyagents.flow.core.chain.ChainDefinition;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 进程内工作流定义快照仓储。
 */
public class InMemoryChainDefinitionSnapshotRepository
        implements ChainDefinitionSnapshotRepository {

    private final Map<String, ChainDefinition> snapshots = new ConcurrentHashMap<>();

    /**
     * {@inheritDoc}
     */
    @Override
    public void save(String instanceId, ChainDefinition definition) {
        snapshots.put(instanceId, definition);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ChainDefinition load(String instanceId) {
        return snapshots.get(instanceId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void remove(String instanceId) {
        snapshots.remove(instanceId);
    }
}
