-
Notifications
You must be signed in to change notification settings - Fork 387
/
list_pending.go
62 lines (49 loc) · 1.58 KB
/
list_pending.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (C) 2024 Storj Labs, Inc.
// See LICENSE for copying information.
package metabase
import (
"context"
"time"
"storj.io/common/storj"
"storj.io/common/uuid"
)
// PendingObjectEntry contains information about an pending object item in a bucket.
type PendingObjectEntry struct {
IsPrefix bool
ObjectKey ObjectKey
StreamID uuid.UUID
CreatedAt time.Time
ExpiresAt *time.Time
EncryptedMetadataNonce []byte
EncryptedMetadata []byte
EncryptedMetadataEncryptedKey []byte
Encryption storj.EncryptionParameters
}
// IteratePendingObjectsByKey contains arguments necessary for listing pending objects by ObjectKey.
type IteratePendingObjectsByKey struct {
ObjectLocation
BatchSize int
Cursor StreamIDCursor
}
// PendingObjectsIterator iterates over a sequence of PendingObjectEntry items.
type PendingObjectsIterator interface {
Next(ctx context.Context, item *PendingObjectEntry) bool
}
// IteratePendingObjectsByKey iterates through all streams of pending objects with the same ObjectKey.
func (db *DB) IteratePendingObjectsByKey(ctx context.Context, opts IteratePendingObjectsByKey, fn func(context.Context, ObjectsIterator) error) (err error) {
defer mon.Task()(&ctx)(&err)
if err := opts.Verify(); err != nil {
return err
}
return iteratePendingObjectsByKey(ctx, db, opts, fn)
}
// Verify verifies get object request fields.
func (opts *IteratePendingObjectsByKey) Verify() error {
if err := opts.ObjectLocation.Verify(); err != nil {
return err
}
if opts.BatchSize < 0 {
return ErrInvalidRequest.New("BatchSize is negative")
}
return nil
}