shithub: furgit

Download patch

ref: 05a193c9e17e006d2df096ebde7b7d3917f6dfec
parent: 85ee911bf6417a0d5bae187f9e8c2d0a4daa2201
author: Runxi Yu <runxiyu@umich.edu>
date: Mon Mar 30 08:35:47 EDT 2026

object/store: Add quarantine and writer interfaces

--- /dev/null
+++ b/object/store/quarantine.go
@@ -1,0 +1,41 @@
+package objectstore
+
+// Quarantine is one quarantined write. It is intended to be embedded.
+type Quarantine interface {
+	// Reader returns the objects written into this quarantine.
+	Reader() Reader
+
+	// Promote publishes quarantined writes into their final destination.
+	Promote() error
+
+	// Discard abandons quarantined writes.
+	Discard() error
+}
+
+// ObjectQuarantine represents one quarantined object-wise write.
+type ObjectQuarantine interface {
+	Quarantine
+	ObjectWriter
+}
+
+// PackQuarantine represents one quarantined pack-wise write.
+type PackQuarantine interface {
+	Quarantine
+	PackWriter
+}
+
+// ObjectQuarantineOptions controls the options for one object quarantine creation.
+type ObjectQuarantineOptions struct{}
+
+// PackQuarantineOptions controls the options for one pack quarantine creation.
+type PackQuarantineOptions struct{}
+
+// ObjectQuarantiner creates quarantines for object-wise writes.
+type ObjectQuarantiner interface {
+	BeginObjectQuarantine(opts ObjectQuarantineOptions) (ObjectQuarantine, error)
+}
+
+// PackQuarantiner creates quarantines for pack-wise writes.
+type PackQuarantiner interface {
+	BeginPackQuarantine(opts PackQuarantineOptions) (PackQuarantine, error)
+}
--- /dev/null
+++ b/object/store/writer.go
@@ -1,0 +1,26 @@
+package objectstore
+
+import (
+	"io"
+
+	objectid "codeberg.org/lindenii/furgit/object/id"
+	objecttype "codeberg.org/lindenii/furgit/object/type"
+)
+
+// ObjectWriter writes individual Git objects.
+type ObjectWriter interface {
+	// WriteContent writes one typed object content stream.
+	WriteContent(ty objecttype.Type, size int64, src io.Reader) (objectid.ObjectID, error)
+
+	// WriteFull writes one full serialized object stream as "type size\0content".
+	WriteFull(src io.Reader) (objectid.ObjectID, error)
+}
+
+// PackWriteOptions controls one pack write operation.
+type PackWriteOptions struct{}
+
+// PackWriter writes Git pack streams.
+type PackWriter interface {
+	// WritePack ingests one pack stream.
+	WritePack(src io.Reader, opts PackWriteOptions) error
+}
--