policy

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePolicyName

func ParsePolicyName(name string) (string, time.Duration, error)

ParsePolicyName extracts policy type and parameters from a policy name. Supported formats:

  • "delete-after-Xmin" - Delete after X minutes
  • "retain-Xdays" - Retain for X days
  • "retain-Xhours" - Retain for X hours

Returns (policyType, duration, error)

Types

type PolicyConfig

type PolicyConfig struct {
	// Name is a unique identifier for this policy (e.g., "delete-after-5min", "retain-30days")
	Name string `json:"name" yaml:"name"`

	// Description provides human-readable documentation for this policy
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Rules contains policy-specific configuration (e.g., retention duration)
	Rules map[string]interface{} `json:"rules,omitempty" yaml:"rules,omitempty"`
}

PolicyConfig defines a retention policy for media storage. Policies control how long media should be retained and when it should be deleted.

func (*PolicyConfig) Validate

func (p *PolicyConfig) Validate() error

Validate checks if a policy configuration is valid.

type PolicyMetadata

type PolicyMetadata struct {
	// PolicyName identifies the policy applied to this media
	PolicyName string `json:"policy_name"`

	// ExpiresAt is when this media should be deleted (nil = never expires)
	ExpiresAt *time.Time `json:"expires_at,omitempty"`

	// CreatedAt is when the policy was applied
	CreatedAt time.Time `json:"created_at"`
}

PolicyMetadata stores policy information in .meta files alongside media. This metadata is used by the enforcement system to determine when to delete files.

type TimeBasedPolicyHandler

type TimeBasedPolicyHandler struct {
	// contains filtered or unexported fields
}

TimeBasedPolicyHandler implements PolicyHandler for time-based retention policies. It applies expiration times to media based on policy names and enforces deletion of expired media through background scanning.

func NewTimeBasedPolicyHandler

func NewTimeBasedPolicyHandler(enforcementInterval time.Duration) *TimeBasedPolicyHandler

NewTimeBasedPolicyHandler creates a new time-based policy handler.

func (*TimeBasedPolicyHandler) ApplyPolicy

func (h *TimeBasedPolicyHandler) ApplyPolicy(ctx context.Context, metadata *storage.MediaMetadata) error

ApplyPolicy implements storage.PolicyHandler.ApplyPolicy

func (*TimeBasedPolicyHandler) EnforcePolicy

func (h *TimeBasedPolicyHandler) EnforcePolicy(ctx context.Context, baseDir string) error

EnforcePolicy implements storage.PolicyHandler.EnforcePolicy

func (*TimeBasedPolicyHandler) RegisterPolicy

func (h *TimeBasedPolicyHandler) RegisterPolicy(policy PolicyConfig) error

RegisterPolicy adds a policy configuration to the handler.

func (*TimeBasedPolicyHandler) StartEnforcement

func (h *TimeBasedPolicyHandler) StartEnforcement(ctx context.Context, baseDir string)

func (*TimeBasedPolicyHandler) Stop

func (h *TimeBasedPolicyHandler) Stop()

Stop signals the enforcement goroutine to stop and waits for it to finish.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL