Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

1.1 KB
Raw Blame
package s3lifecycle

import "time"

// EventLogHorizon returns the max event age the reader needs to drive the
// (rule, kind) action. Used by the retention mode gate: when
// metaLogRetention < EventLogHorizon + bootstrapLookbackMin, the action is
// promoted to scan_only. EXPIRATION_DATE returns 0 (date kind bypasses);
// count / immediate kinds return SmallDelay.
func EventLogHorizon(rule *Rule, kind ActionKind) time.Duration {
	if rule == nil {
		return 0
	}
	switch kind {
	case ActionKindExpirationDays:
		if rule.ExpirationDays > 0 {
			return DaysToDuration(rule.ExpirationDays)
		}
	case ActionKindNoncurrentDays:
		if rule.NoncurrentVersionExpirationDays > 0 {
			return DaysToDuration(rule.NoncurrentVersionExpirationDays)
		}
	case ActionKindAbortMPU:
		if rule.AbortMPUDaysAfterInitiation > 0 {
			return DaysToDuration(rule.AbortMPUDaysAfterInitiation)
		}
	case ActionKindNewerNoncurrent:
		if rule.NewerNoncurrentVersions > 0 && rule.NoncurrentVersionExpirationDays == 0 {
			return SmallDelay
		}
	case ActionKindExpiredDeleteMarker:
		if rule.ExpiredObjectDeleteMarker {
			return SmallDelay
		}
	}
	return 0
}