Initial project source

这个提交包含在:
apple
2026-11-20 15:32:57 +08:00
当前提交 fb47c07f7c
共修改 8405 个文件,包含 806907 行新增和 0 行删除
+66
查看文件
@@ -0,0 +1,66 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "pathname"
root = Pathname.new(__dir__).join("../..").realpath
module_root = root.join("aixun-common/aixun-common-maintenance")
java_files = module_root.join("src/main/java").glob("**/*.java")
def fail_check(message)
warn "maintenance-job verification failed: #{message}"
exit 1
end
fail_check("maintenance module is missing") unless module_root.directory?
fail_check("Spring scheduled trigger is missing") unless java_files.any? { |path| path.read.include?("@Scheduled") }
forbidden_imports = /import\s+.*(?:quartz|xxl|dolphinscheduler|seatunnel|kafka|rocketmq)/i
forbidden_web = /@(RestController|Controller|RequestMapping)\b/
java_files.each do |path|
source = path.read
fail_check("#{path.basename} imports a forbidden scheduler/data engine/channel") if source.match?(forbidden_imports)
fail_check("#{path.basename} creates a second maintenance console/API") if source.match?(forbidden_web)
end
kinds = module_root.join(
"src/main/java/cn/aixunkeji/datagov/maintenance/MaintenanceJobKind.java"
).read.scan(/^\s+([A-Z][A-Z_]+),?$/).flatten
approved_kinds = %w[
STATUS_RECONCILIATION
CONNECTION_HEALTH
PROJECTION_REFRESH
RETENTION_CLEANUP
IN_APP_ALERT
]
fail_check("maintenance kind allowlist drifted") unless kinds == approved_kinds
jdbc_source = module_root.join(
"src/main/java/cn/aixunkeji/datagov/maintenance/JdbcMaintenanceLeaseRepository.java"
).read
%w[ON\ DUPLICATE\ KEY lease_until\ \<\= last_idempotency_key last_outcome attempt_no version\ \=\ version\ \+\ 1].each do |token|
fail_check("JDBC lease implementation is missing #{token.gsub('\\', '')}") unless jdbc_source.match?(Regexp.new(token))
end
runner_source = module_root.join(
"src/main/java/cn/aixunkeji/datagov/maintenance/MaintenanceJobRunner.java"
).read
fail_check("maximum execution timeout is missing") unless runner_source.include?("maximumExecutionTime().toMillis()")
fail_check("timed-out runs must retain their lease") unless
runner_source.match?(/MaintenanceRunOutcome\.TIMED_OUT, completedAt, false/)
fail_check("manual compensation entry is missing") unless module_root.join(
"src/main/java/cn/aixunkeji/datagov/maintenance/MaintenanceRunRequest.java"
).read.include?("compensation(")
migration = root.join("db/migration/integration/V20260824.003__create_maintenance_lease.sql").read
%w[lease_until last_idempotency_key last_trigger_type last_compensation_reason last_outcome attempt_no].each do |column|
fail_check("lease migration is missing #{column}") unless migration.match?(/\b#{column}\b/i)
end
fail_check("lease migration contains a foreign key") if migration.match?(/FOREIGN\s+KEY/i)
test_source = module_root.join("src/test/java/cn/aixunkeji/datagov/maintenance/MaintenanceJobRunnerTest.java").read
%w[duplicateTrigger expiredLease maximumDuration manualCompensation failedRun scheduledTrigger].each do |scenario|
fail_check("test suite is missing #{scenario}") unless test_source.include?(scenario)
end
puts "Maintenance-job verification passed: Spring trigger, MySQL lease, idempotency, timeout, retry, compensation, and recovery gates present."