-
Notifications
You must be signed in to change notification settings - Fork 104
/
bucket_collectionsmgr.go
154 lines (127 loc) · 5.51 KB
/
bucket_collectionsmgr.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package gocb
import (
"context"
"time"
)
// CollectionHistorySettings specifies settings for whether history retention should be enabled or disabled
// for this collection.
type CollectionHistorySettings struct {
Enabled bool
}
// CollectionSpec describes the specification of a collection.
type CollectionSpec struct {
Name string
ScopeName string
// The maximum expiry all documents in the collection can have. Defaults to the bucket-level setting.
// Value of -1 seconds (time.Duration(-1) * time.Second) denotes 'no expiry'.
MaxExpiry time.Duration
History *CollectionHistorySettings
}
// ScopeSpec describes the specification of a scope.
type ScopeSpec struct {
Name string
Collections []CollectionSpec
}
// CollectionManager provides methods for performing collections management.
// Deprecated: See CollectionsV2 and CollectionManagerV2.
type CollectionManager struct {
managerV2 *CollectionManagerV2
}
// GetAllScopesOptions is the set of options available to the GetAllScopes operation.
type GetAllScopesOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
}
// GetAllScopes gets all scopes from the bucket.
// Will be deprecated in favor of CollectionManagerV2.GetAllScopes in the next minor release.
func (cm *CollectionManager) GetAllScopes(opts *GetAllScopesOptions) ([]ScopeSpec, error) {
return cm.managerV2.GetAllScopes(opts)
}
// CreateCollectionOptions is the set of options available to the CreateCollection operation.
type CreateCollectionOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
}
// CreateCollection creates a new collection on the bucket.
// Will be deprecated in favor of CollectionManagerV2.CreateCollection in the next minor release.
func (cm *CollectionManager) CreateCollection(spec CollectionSpec, opts *CreateCollectionOptions) error {
settings := &CreateCollectionSettings{
MaxExpiry: spec.MaxExpiry,
History: spec.History,
}
return cm.managerV2.CreateCollection(spec.ScopeName, spec.Name, settings, opts)
}
// UpdateCollectionOptions is the set of options available to the UpdateCollection operation.
type UpdateCollectionOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
}
// UpdateCollection updates the settings of an existing collection.
// Will be deprecated in favor of CollectionManagerV2.UpdateCollection in the next minor release.
func (cm *CollectionManager) UpdateCollection(spec CollectionSpec, opts *UpdateCollectionOptions) error {
settings := UpdateCollectionSettings{
MaxExpiry: spec.MaxExpiry,
History: spec.History,
}
return cm.managerV2.UpdateCollection(spec.ScopeName, spec.Name, settings, opts)
}
// DropCollectionOptions is the set of options available to the DropCollection operation.
type DropCollectionOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
}
// DropCollection removes a collection.
// Will be deprecated in favor of CollectionManagerV2.DropCollection in the next minor release.
func (cm *CollectionManager) DropCollection(spec CollectionSpec, opts *DropCollectionOptions) error {
return cm.managerV2.DropCollection(spec.ScopeName, spec.Name, opts)
}
// CreateScopeOptions is the set of options available to the CreateScope operation.
type CreateScopeOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
}
// CreateScope creates a new scope on the bucket.
// Will be deprecated in favor of CollectionManagerV2.CreateScope in the next minor release.
func (cm *CollectionManager) CreateScope(scopeName string, opts *CreateScopeOptions) error {
return cm.managerV2.CreateScope(scopeName, opts)
}
// DropScopeOptions is the set of options available to the DropScope operation.
type DropScopeOptions struct {
Timeout time.Duration
RetryStrategy RetryStrategy
ParentSpan RequestSpan
// Using a deadlined Context alongside a Timeout will cause the shorter of the two to cause cancellation, this
// also applies to global level timeouts.
// UNCOMMITTED: This API may change in the future.
Context context.Context
}
// DropScope removes a scope.
// Will be deprecated in favor of CollectionManagerV2.DropScope in the next minor release.
func (cm *CollectionManager) DropScope(scopeName string, opts *DropScopeOptions) error {
return cm.managerV2.DropScope(scopeName, opts)
}