@@ -34,21 +34,21 @@ import (
34
34
// Logically this class can be thought of as part of namespaceHandler.
35
35
36
36
type (
37
- // ArchivalState represents the state of archival config
37
+ // ArchivalConfigState represents the state of archival config
38
38
// the only invalid state is {URI="", state=enabled}
39
39
// once URI is set it is immutable
40
- ArchivalState struct {
40
+ ArchivalConfigState struct {
41
41
State enumspb.ArchivalState
42
42
URI string
43
43
}
44
44
45
- // ArchivalEvent represents a change request to archival config state
45
+ // ArchivalConfigEvent represents a change request to archival config state
46
46
// the only restriction placed on events is that defaultURI is not empty
47
47
// state can be nil, enabled, or disabled (nil indicates no update by user is being attempted)
48
- ArchivalEvent struct {
49
- defaultURI string
48
+ ArchivalConfigEvent struct {
49
+ DefaultURI string
50
50
URI string
51
- state enumspb.ArchivalState
51
+ State enumspb.ArchivalState
52
52
}
53
53
)
54
54
@@ -60,31 +60,31 @@ var (
60
60
errURIUpdate = serviceerror .NewInvalidArgument ("Cannot update existing archival URI" )
61
61
)
62
62
63
- func neverEnabledState () * ArchivalState {
64
- return & ArchivalState {
63
+ func NeverEnabledState () * ArchivalConfigState {
64
+ return & ArchivalConfigState {
65
65
URI : "" ,
66
66
State : enumspb .ARCHIVAL_STATE_DISABLED ,
67
67
}
68
68
}
69
69
70
- func (e * ArchivalEvent ) validate () error {
71
- if len (e .defaultURI ) == 0 {
70
+ func (e * ArchivalConfigEvent ) Validate () error {
71
+ if len (e .DefaultURI ) == 0 {
72
72
return errInvalidEvent
73
73
}
74
74
return nil
75
75
}
76
76
77
- func (s * ArchivalState ) validate () error {
77
+ func (s * ArchivalConfigState ) validate () error {
78
78
if s .State == enumspb .ARCHIVAL_STATE_ENABLED && len (s .URI ) == 0 {
79
79
return errInvalidState
80
80
}
81
81
return nil
82
82
}
83
83
84
- func (s * ArchivalState ) getNextState (
85
- e * ArchivalEvent ,
84
+ func (s * ArchivalConfigState ) GetNextState (
85
+ e * ArchivalConfigEvent ,
86
86
URIValidationFunc func (URI string ) error ,
87
- ) (nextState * ArchivalState , changed bool , err error ) {
87
+ ) (nextState * ArchivalConfigState , changed bool , err error ) {
88
88
defer func () {
89
89
// ensure that any existing URI name was not mutated
90
90
if nextState != nil && len (s .URI ) != 0 && s .URI != nextState .URI {
@@ -120,7 +120,7 @@ func (s *ArchivalState) getNextState(
120
120
if err := s .validate (); err != nil {
121
121
return nil , false , err
122
122
}
123
- if err := e .validate (); err != nil {
123
+ if err := e .Validate (); err != nil {
124
124
return nil , false , err
125
125
}
126
126
@@ -151,90 +151,90 @@ func (s *ArchivalState) getNextState(
151
151
152
152
// state 1
153
153
if s .State == enumspb .ARCHIVAL_STATE_ENABLED && stateURISet {
154
- if e .state == enumspb .ARCHIVAL_STATE_ENABLED && eventURISet {
154
+ if e .State == enumspb .ARCHIVAL_STATE_ENABLED && eventURISet {
155
155
return s , false , nil
156
156
}
157
- if e .state == enumspb .ARCHIVAL_STATE_ENABLED && ! eventURISet {
157
+ if e .State == enumspb .ARCHIVAL_STATE_ENABLED && ! eventURISet {
158
158
return s , false , nil
159
159
}
160
- if e .state == enumspb .ARCHIVAL_STATE_DISABLED && eventURISet {
161
- return & ArchivalState {
160
+ if e .State == enumspb .ARCHIVAL_STATE_DISABLED && eventURISet {
161
+ return & ArchivalConfigState {
162
162
State : enumspb .ARCHIVAL_STATE_DISABLED ,
163
163
URI : s .URI ,
164
164
}, true , nil
165
165
}
166
- if e .state == enumspb .ARCHIVAL_STATE_DISABLED && ! eventURISet {
167
- return & ArchivalState {
166
+ if e .State == enumspb .ARCHIVAL_STATE_DISABLED && ! eventURISet {
167
+ return & ArchivalConfigState {
168
168
State : enumspb .ARCHIVAL_STATE_DISABLED ,
169
169
URI : s .URI ,
170
170
}, true , nil
171
171
}
172
- if e .state == enumspb .ARCHIVAL_STATE_UNSPECIFIED && eventURISet {
172
+ if e .State == enumspb .ARCHIVAL_STATE_UNSPECIFIED && eventURISet {
173
173
return s , false , nil
174
174
}
175
- if e .state == enumspb .ARCHIVAL_STATE_UNSPECIFIED && ! eventURISet {
175
+ if e .State == enumspb .ARCHIVAL_STATE_UNSPECIFIED && ! eventURISet {
176
176
return s , false , nil
177
177
}
178
178
}
179
179
180
180
// state 2
181
181
if s .State == enumspb .ARCHIVAL_STATE_DISABLED && stateURISet {
182
- if e .state == enumspb .ARCHIVAL_STATE_ENABLED && eventURISet {
183
- return & ArchivalState {
182
+ if e .State == enumspb .ARCHIVAL_STATE_ENABLED && eventURISet {
183
+ return & ArchivalConfigState {
184
184
URI : s .URI ,
185
185
State : enumspb .ARCHIVAL_STATE_ENABLED ,
186
186
}, true , nil
187
187
}
188
- if e .state == enumspb .ARCHIVAL_STATE_ENABLED && ! eventURISet {
189
- return & ArchivalState {
188
+ if e .State == enumspb .ARCHIVAL_STATE_ENABLED && ! eventURISet {
189
+ return & ArchivalConfigState {
190
190
State : enumspb .ARCHIVAL_STATE_ENABLED ,
191
191
URI : s .URI ,
192
192
}, true , nil
193
193
}
194
- if e .state == enumspb .ARCHIVAL_STATE_DISABLED && eventURISet {
194
+ if e .State == enumspb .ARCHIVAL_STATE_DISABLED && eventURISet {
195
195
return s , false , nil
196
196
}
197
- if e .state == enumspb .ARCHIVAL_STATE_DISABLED && ! eventURISet {
197
+ if e .State == enumspb .ARCHIVAL_STATE_DISABLED && ! eventURISet {
198
198
return s , false , nil
199
199
}
200
- if e .state == enumspb .ARCHIVAL_STATE_UNSPECIFIED && eventURISet {
200
+ if e .State == enumspb .ARCHIVAL_STATE_UNSPECIFIED && eventURISet {
201
201
return s , false , nil
202
202
}
203
- if e .state == enumspb .ARCHIVAL_STATE_UNSPECIFIED && ! eventURISet {
203
+ if e .State == enumspb .ARCHIVAL_STATE_UNSPECIFIED && ! eventURISet {
204
204
return s , false , nil
205
205
}
206
206
}
207
207
208
208
// state 3
209
209
if s .State == enumspb .ARCHIVAL_STATE_DISABLED && ! stateURISet {
210
- if e .state == enumspb .ARCHIVAL_STATE_ENABLED && eventURISet {
211
- return & ArchivalState {
210
+ if e .State == enumspb .ARCHIVAL_STATE_ENABLED && eventURISet {
211
+ return & ArchivalConfigState {
212
212
State : enumspb .ARCHIVAL_STATE_ENABLED ,
213
213
URI : e .URI ,
214
214
}, true , nil
215
215
}
216
- if e .state == enumspb .ARCHIVAL_STATE_ENABLED && ! eventURISet {
217
- return & ArchivalState {
216
+ if e .State == enumspb .ARCHIVAL_STATE_ENABLED && ! eventURISet {
217
+ return & ArchivalConfigState {
218
218
State : enumspb .ARCHIVAL_STATE_ENABLED ,
219
- URI : e .defaultURI ,
219
+ URI : e .DefaultURI ,
220
220
}, true , nil
221
221
}
222
- if e .state == enumspb .ARCHIVAL_STATE_DISABLED && eventURISet {
223
- return & ArchivalState {
222
+ if e .State == enumspb .ARCHIVAL_STATE_DISABLED && eventURISet {
223
+ return & ArchivalConfigState {
224
224
State : enumspb .ARCHIVAL_STATE_DISABLED ,
225
225
URI : e .URI ,
226
226
}, true , nil
227
227
}
228
- if e .state == enumspb .ARCHIVAL_STATE_DISABLED && ! eventURISet {
228
+ if e .State == enumspb .ARCHIVAL_STATE_DISABLED && ! eventURISet {
229
229
return s , false , nil
230
230
}
231
- if e .state == enumspb .ARCHIVAL_STATE_UNSPECIFIED && eventURISet {
232
- return & ArchivalState {
231
+ if e .State == enumspb .ARCHIVAL_STATE_UNSPECIFIED && eventURISet {
232
+ return & ArchivalConfigState {
233
233
State : enumspb .ARCHIVAL_STATE_DISABLED ,
234
234
URI : e .URI ,
235
235
}, true , nil
236
236
}
237
- if e .state == enumspb .ARCHIVAL_STATE_UNSPECIFIED && ! eventURISet {
237
+ if e .State == enumspb .ARCHIVAL_STATE_UNSPECIFIED && ! eventURISet {
238
238
return s , false , nil
239
239
}
240
240
}
0 commit comments