Fast implementation of Git in pure Go codeberg.org/lindenii/furgit
git go
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

object/store: Unify writers and fix naming

Runxi Yu 3ba67c27 3bc59deb

+49 -43
+17
object/store/base_quarantine.go
··· 1 + package objectstore 2 + 3 + // BaseQuarantine is one quarantined write. It is intended to be embedded. 4 + type BaseQuarantine interface { 5 + // Reader exposes the objects written into this quarantine. 6 + Reader 7 + 8 + // Promote publishes quarantined writes into their final destination. 9 + // 10 + // Promote invalidates the receiver. 11 + Promote() error 12 + 13 + // Discard abandons quarantined writes. 14 + // 15 + // Discard invalidates the receiver. 16 + Discard() error 17 + }
+3 -4
object/store/dual/dual.go
··· 27 27 } 28 28 29 29 var ( 30 - _ objectstore.Reader = (*Dual)(nil) 31 - _ objectstore.ObjectWriter = (*Dual)(nil) 32 - _ objectstore.PackWriter = (*Dual)(nil) 33 - _ objectstore.WriterQuarantiner = (*Dual)(nil) 30 + _ objectstore.Reader = (*Dual)(nil) 31 + _ objectstore.Writer = (*Dual)(nil) 32 + _ objectstore.Quarantiner = (*Dual)(nil) 34 33 )
+3 -3
object/store/dual/dual_test.go
··· 117 117 repo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 118 118 store := newDualStore(t, repo, algo) 119 119 120 - quarantiner, ok := any(store).(objectstore.WriterQuarantiner) 120 + quarantiner, ok := any(store).(objectstore.Quarantiner) 121 121 if !ok { 122 - t.Fatal("dual does not implement WriterQuarantiner") 122 + t.Fatal("dual does not implement Quarantiner") 123 123 } 124 124 125 125 quarantine, err := quarantiner.BeginQuarantine(objectstore.QuarantineOptions{}) ··· 219 219 repo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) 220 220 store := newDualStore(t, repo, algo) 221 221 222 - quarantiner := any(store).(objectstore.WriterQuarantiner) 222 + quarantiner := any(store).(objectstore.Quarantiner) 223 223 quarantine, err := quarantiner.BeginQuarantine(objectstore.QuarantineOptions{}) 224 224 if err != nil { 225 225 t.Fatalf("BeginQuarantine: %v", err)
+1 -1
object/store/dual/quarantine.go
··· 19 19 var ( 20 20 _ objectstore.ObjectQuarantine = (*quarantine)(nil) 21 21 _ objectstore.PackQuarantine = (*quarantine)(nil) 22 - _ objectstore.WriterQuarantine = (*quarantine)(nil) 22 + _ objectstore.Quarantine = (*quarantine)(nil) 23 23 ) 24 24 25 25 func newQuarantine(
+1 -1
object/store/dual/quarantine_begin.go
··· 5 5 // BeginQuarantine creates one coordinated dual quarantine spanning both stores. 6 6 // 7 7 // Labels: Deps-Borrowed, Life-Parent, Close-No. 8 - func (dual *Dual) BeginQuarantine(opts objectstore.QuarantineOptions) (objectstore.WriterQuarantine, error) { 8 + func (dual *Dual) BeginQuarantine(opts objectstore.QuarantineOptions) (objectstore.Quarantine, error) { 9 9 objectQ, err := dual.object.BeginObjectQuarantine(opts.Object) 10 10 if err != nil { 11 11 return nil, err
+14 -11
object/store/quarantine.go
··· 1 1 package objectstore 2 2 3 - // Quarantine is one quarantined write. It is intended to be embedded. 3 + // WriterQuarantine represents one quarantined write that accepts both object- 4 + // wise and pack-wise writes. 4 5 type Quarantine interface { 5 - // Reader exposes the objects written into this quarantine. 6 - Reader 6 + BaseQuarantine 7 + Writer 8 + } 7 9 8 - // Promote publishes quarantined writes into their final destination. 9 - // 10 - // Promote invalidates the receiver. 11 - Promote() error 10 + // QuarantineOptions controls the options for one coordinated quarantine creation. 11 + type QuarantineOptions struct { 12 + Object ObjectQuarantineOptions 13 + Pack PackQuarantineOptions 14 + } 12 15 13 - // Discard abandons quarantined writes. 14 - // 15 - // Discard invalidates the receiver. 16 - Discard() error 16 + // WriterQuarantiner creates coordinated quarantines that support both object- 17 + // wise and pack-wise writes. 18 + type Quarantiner interface { 19 + BeginQuarantine(opts QuarantineOptions) (Quarantine, error) 17 20 }
-21
object/store/quarantine_writer.go
··· 1 - package objectstore 2 - 3 - // WriterQuarantine represents one quarantined write that accepts both object- 4 - // wise and pack-wise writes. 5 - type WriterQuarantine interface { 6 - Quarantine 7 - ObjectWriter 8 - PackWriter 9 - } 10 - 11 - // QuarantineOptions controls the options for one coordinated quarantine creation. 12 - type QuarantineOptions struct { 13 - Object ObjectQuarantineOptions 14 - Pack PackQuarantineOptions 15 - } 16 - 17 - // WriterQuarantiner creates coordinated quarantines that support both object- 18 - // wise and pack-wise writes. 19 - type WriterQuarantiner interface { 20 - BeginQuarantine(opts QuarantineOptions) (WriterQuarantine, error) 21 - }
+8
object/store/writer.go
··· 1 + package objectstore 2 + 3 + // Writer represents a store that could perform both pack ingestions 4 + // and individual object writes. 5 + type Writer interface { 6 + PackWriter 7 + ObjectWriter 8 + }
+1 -1
object/store/writer_object.go
··· 24 24 25 25 // ObjectQuarantine represents one quarantined object-wise write. 26 26 type ObjectQuarantine interface { 27 - Quarantine 27 + BaseQuarantine 28 28 ObjectWriter 29 29 } 30 30
+1 -1
object/store/writer_pack.go
··· 45 45 46 46 // PackQuarantine represents one quarantined pack-wise write. 47 47 type PackQuarantine interface { 48 - Quarantine 48 + BaseQuarantine 49 49 PackWriter 50 50 } 51 51