package com.easyagents.federation.sql.federation;

import com.easyagents.federation.sql.source.SourceId;

/**
 * 编译计划绑定的节点本地物理数据源运行身份。
 *
 * @param bindingName 查询范围 Binding 名称
 * @param sourceId 物理数据源标识
 * @param sourceRevision Definition 版本
 * @param sourceChecksum Definition 校验和
 * @param adapterId Adapter 标识
 * @param runtimeFingerprint 数据库与驱动运行指纹
 */
public record FederationSourceRuntimeIdentity(
    String bindingName,
    SourceId sourceId,
    long sourceRevision,
    String sourceChecksum,
    String adapterId,
    String runtimeFingerprint
) {

    /**
     * 校验运行身份字段。
     */
    public FederationSourceRuntimeIdentity {
        if (bindingName == null || bindingName.isBlank()
            || sourceId == null || sourceRevision < 0
            || sourceChecksum == null || sourceChecksum.isBlank()
            || adapterId == null || adapterId.isBlank()
            || runtimeFingerprint == null || runtimeFingerprint.isBlank()) {
            throw new IllegalArgumentException("source runtime identity is incomplete");
        }
    }
}
