From 510a6a3d09d6fc010fecc0d87e6d838fecc3a6df Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 2 Apr 2026 08:16:04 +0000 Subject: object/store: Add interfaces --- object/store/quarantiner.go | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 object/store/quarantiner.go (limited to 'object/store/quarantiner.go') diff --git a/object/store/quarantiner.go b/object/store/quarantiner.go new file mode 100644 index 00000000..4a2b7e02 --- /dev/null +++ b/object/store/quarantiner.go @@ -0,0 +1,70 @@ +package store + +// QuarantineBase is one quarantined write. +// It is intended to be embedded. +type QuarantineBase interface { + // Reader exposes the objects written into this quarantine. + Reader + + // Promote publishes quarantined writes into their final destination. + // + // Promote invalidates the receiver. + Promote() error + + // Discard abandons quarantined writes. + // + // Discard invalidates the receiver. + Discard() error +} + +// Quarantine represents one quarantined write +// that accepts both object-wise and pack-wise writes. +type Quarantine interface { + QuarantineBase + Writer +} + +// QuarantineOptions controls the options +// for one coordinated quarantine creation. +type QuarantineOptions struct { + Object ObjectQuarantineOptions + Pack PackQuarantineOptions +} + +// Quarantiner creates coordinated quarantines +// that accept both object-wise and pack-wise writes. +type Quarantiner interface { + BeginQuarantine(opts QuarantineOptions) (Quarantine, error) +} + +// ObjectQuarantine represents one quarantined object-wise write. +type ObjectQuarantine interface { + QuarantineBase + ObjectWriter +} + +// ObjectQuarantineOptions controls the options +// for one object quarantine creation. +type ObjectQuarantineOptions struct{} + +// ObjectQuarantiner creates quarantines +// for object-wise writes. +type ObjectQuarantiner interface { + BeginObjectQuarantine(opts ObjectQuarantineOptions) (ObjectQuarantine, error) +} + +// PackQuarantine represents one quarantined pack-wise write. +type PackQuarantine interface { + QuarantineBase + PackWriter +} + +// PackQuarantineOptions controls the options +// for one pack quarantine creation. +type PackQuarantineOptions struct{} + +// PackQuarantiner creates quarantines +// for pack-wise writes. +type PackQuarantiner interface { + BeginPackQuarantine(opts PackQuarantineOptions) (PackQuarantine, error) +} -- cgit v1.3.1-10-gc9f91