Documentation
¶
Overview ¶
Package report captures PPDM backup history into a durable store for assurance reporting.
Index ¶
- type Asset
- type CapturedPolicy
- type Capturer
- func (c *Capturer) CaptureServer(ctx context.Context, tenant string, client ppdmclient.Client) error
- func (c *Capturer) ResolveTargets(ctx context.Context, tenant string, cfg config.Compliance) error
- func (c *Capturer) Run(ctx context.Context, servers []ServerClient, interval, timeout time.Duration)
- func (c *Capturer) RunOnce(ctx context.Context, servers []ServerClient, timeout time.Duration)
- type ComplianceRow
- type Copy
- type Job
- type Policy
- type Rule321Row
- type SLATarget
- type ServerClient
- type Store
- func (s *Store) CapturedPolicies(ctx context.Context, tenant string) ([]CapturedPolicy, error)
- func (s *Store) Close()
- func (s *Store) ComplianceRows(ctx context.Context, tenant string) ([]ComplianceRow, error)
- func (s *Store) CopyWatermark(ctx context.Context, server string) (time.Time, error)
- func (s *Store) DeliveryExists(ctx context.Context, tenant, period string) (bool, error)
- func (s *Store) FinishRun(ctx context.Context, id int64, ok bool, errMsg string, counts map[string]int) error
- func (s *Store) JobWatermark(ctx context.Context, server string) (time.Time, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) Prune(ctx context.Context, defaultDays int, overrides map[string]int) error
- func (s *Store) RecordDelivery(ctx context.Context, tenant, period string, ok bool, errMsg string, ...) error
- func (s *Store) ReportSummary(ctx context.Context, tenant string) (Summary, error)
- func (s *Store) Rule321Rows(ctx context.Context, tenant string) ([]Rule321Row, error)
- func (s *Store) StartRun(ctx context.Context, server, version string) (int64, error)
- func (s *Store) UpsertAssets(ctx context.Context, tenant, server string, assets []Asset, ...) error
- func (s *Store) UpsertCopies(ctx context.Context, tenant, server string, copies []Copy, ...) error
- func (s *Store) UpsertJobs(ctx context.Context, tenant, server string, jobs []Job, capturedAt time.Time) error
- func (s *Store) UpsertPolicies(ctx context.Context, tenant, server string, policies []Policy, ...) error
- func (s *Store) UpsertSLATargets(ctx context.Context, targets []SLATarget) error
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
ProtectionStatus string `json:"protectionStatus"`
LastAvailableCopyTime string `json:"lastAvailableCopyTime"`
ProtectionPolicy struct {
Name string `json:"name"`
} `json:"protectionPolicy"`
}
Asset is one /api/v2/assets record (current protection state; 20.1.0 Asset, ADR-0010).
type CapturedPolicy ¶
CapturedPolicy is a stored protection policy: its name plus the raw objectives JSON.
type Capturer ¶
type Capturer struct {
// contains filtered or unexported fields
}
Capturer pulls authoritative PPDM records for one server and persists them.
func NewCapturer ¶
func NewCapturer(store *Store, version string, retention config.Retention, compliance config.Compliance) *Capturer
NewCapturer wires a capturer to a store. retention drives per-tenant prune + backfill; compliance drives post-capture SLA target resolution.
func (*Capturer) CaptureServer ¶
func (c *Capturer) CaptureServer(ctx context.Context, tenant string, client ppdmclient.Client) error
CaptureServer captures jobs/copies (incremental) + assets/policies (full) for one server, upserts them tagged with tenant, and records a capture_runs provenance row.
func (*Capturer) ResolveTargets ¶
ResolveTargets computes the effective SLA targets for a tenant and upserts them into sla_targets. It writes three layers of rows that the compliance view picks the most specific of: the per-tenant default, one per captured protection policy (derived from objectives), and one per matching config override. It never blocks capture — a missing objective just falls back to the configured default.
type ComplianceRow ¶
type ComplianceRow struct {
AssetID, AssetName, AssetType, PolicyName string
RPOOk, RetentionOk, CopiesOk, Compliant bool
Reasons string
}
ComplianceRow is one asset's SLA verdict from the compliance view.
type Copy ¶
type Copy struct {
ID string `json:"id"`
AssetID string `json:"assetId"`
CopyType string `json:"copyType"`
CreateTime string `json:"createTime"`
RetentionTime string `json:"retentionTime"`
RetentionLock string `json:"retentionLock"` // enum ALL_COPIES_UNLOCKED|ALL_COPIES_LOCKED|PARTIAL_COPIES_LOCKED
StorageSystemID string `json:"storageSystemId"`
Location string `json:"location"`
Size float64 `json:"size"`
}
Copy is one /api/v2/latest-copies record (20.1.0 Copy, ADR-0010). policyName and expirationTime have no 20.1.0 source and are not captured (columns remain, NULL).
type Job ¶
type Job struct {
ID string `json:"id"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
State string `json:"state"`
CreateTime string `json:"createTime"`
EndTime string `json:"endTime"`
Result struct {
Status string `json:"status"`
BytesTransferred float64 `json:"bytesTransferred"`
} `json:"result"`
Asset struct {
ID string `json:"id"`
Name string `json:"name"`
} `json:"asset"`
ProtectionPolicy struct {
Name string `json:"name"`
} `json:"protectionPolicy"`
}
Job is one /api/v2/activities record (a backup/restore job — immutable event).
type Policy ¶
type Policy struct {
ID string `json:"id"`
Name string `json:"name"`
Objectives any `json:"objectives"` // stored as jsonb
}
Policy is one /api/v3/protection-policies record. Objectives kept as raw JSON.
type Rule321Row ¶
type Rule321Row struct {
AssetID, AssetName, AssetType string
CopiesOk, MediaOk, OffsiteOk, ImmutableOk, ErrorsOk bool
RulePass bool
CopiesCount, DistinctMedia, DistinctLocations int
}
Rule321Row is one asset's 3-2-1-1-0 evaluation from the rule_321110 view.
type SLATarget ¶
type SLATarget struct {
Tenant string
AssetType string
PolicyName string
RPOSeconds int64
RetentionDays int
MinCopies int
GraceSeconds int64
Source string // policy | override | default
}
SLATarget is a resolved per-asset SLA target row (the only materialized Phase 2 state).
type ServerClient ¶
type ServerClient struct {
Tenant string
Client ppdmclient.Client
}
ServerClient pairs a tenant with its PPDM client (built by main from config).
func NewServerClient ¶
func NewServerClient(tenant string, client ppdmclient.Client) ServerClient
NewServerClient pairs a tenant with a PPDM client for RunOnce/Run.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the PostgreSQL backup-history store.
func (*Store) CapturedPolicies ¶
CapturedPolicies returns a tenant's stored protection policies (across servers) for target resolution. Targets are tenant-scoped (assets join by tenant+policy_name, not server).
func (*Store) ComplianceRows ¶
ComplianceRows returns a tenant's per-asset SLA verdicts (non-compliant first).
func (*Store) CopyWatermark ¶
CopyWatermark returns the newest create_time for a server's copies, or zero time if none.
func (*Store) DeliveryExists ¶ added in v1.1.0
DeliveryExists reports whether a SUCCESSFUL report delivery is already recorded for the (tenant, period) occurrence. Failed attempts return false so the scheduler retries them.
func (*Store) FinishRun ¶
func (s *Store) FinishRun(ctx context.Context, id int64, ok bool, errMsg string, counts map[string]int) error
FinishRun closes a capture_runs row with outcome + per-resource counts.
func (*Store) JobWatermark ¶
JobWatermark returns the newest created_at for a server's jobs, or zero time if none.
func (*Store) Prune ¶
Prune deletes append-only event rows (backup_jobs, copies) older than each tenant's retention window: per-tenant for override tenants, then a default sweep for every other tenant. assets and protection_policies hold current upsert-latest state and are intentionally not pruned.
func (*Store) RecordDelivery ¶ added in v1.1.0
func (s *Store) RecordDelivery(ctx context.Context, tenant, period string, ok bool, errMsg string, recipients []string) error
RecordDelivery idempotently upserts the outcome of a delivery attempt for (tenant, period); a later success overwrites an earlier failure.
func (*Store) ReportSummary ¶
ReportSummary computes the headline counts for a tenant in one round-trip.
func (*Store) Rule321Rows ¶
Rule321Rows returns a tenant's per-asset 3-2-1-1-0 verdicts.
func (*Store) UpsertAssets ¶
func (s *Store) UpsertAssets(ctx context.Context, tenant, server string, assets []Asset, capturedAt time.Time) error
UpsertAssets upserts current asset protection state by id.
func (*Store) UpsertCopies ¶
func (s *Store) UpsertCopies(ctx context.Context, tenant, server string, copies []Copy, capturedAt time.Time) error
UpsertCopies inserts/updates copies by id.
func (*Store) UpsertJobs ¶
func (s *Store) UpsertJobs(ctx context.Context, tenant, server string, jobs []Job, capturedAt time.Time) error
UpsertJobs inserts/updates backup_jobs by id (append-only events; re-capture is a no-op update).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package delivery sends rendered reports to recipients.
|
Package delivery sends rendered reports to recipients. |
|
Package render builds and renders per-tenant backup-assurance reports (HTML + PDF) over the report store's compliance and rule_321110 views.
|
Package render builds and renders per-tenant backup-assurance reports (HTML + PDF) over the report store's compliance and rule_321110 views. |
|
Package reporttest spins up a migrated report.Store backed by a real (throwaway) Postgres via testcontainers, for use by tests in sibling packages (e.g.
|
Package reporttest spins up a migrated report.Store backed by a real (throwaway) Postgres via testcontainers, for use by tests in sibling packages (e.g. |
|
Package schedule computes per-tenant report due-ness (pure cadence functions) and runs the scheduled generate+deliver loop.
|
Package schedule computes per-tenant report due-ness (pure cadence functions) and runs the scheduled generate+deliver loop. |