@@ -6,10 +6,6 @@ const https = require('https');
6
6
const { EventEmitter } = require ( 'events' ) ;
7
7
const Logger = require ( 'werelogs' ) . Logger ;
8
8
9
- const LifecycleDeleteObjectTask =
10
- require ( '../tasks/LifecycleDeleteObjectTask' ) ;
11
- const LifecycleUpdateTransitionTask =
12
- require ( '../tasks/LifecycleUpdateTransitionTask' ) ;
13
9
const BackbeatConsumer = require ( '../../../lib/BackbeatConsumer' ) ;
14
10
const BackbeatMetadataProxy = require ( '../../../lib/BackbeatMetadataProxy' ) ;
15
11
const ActionQueueEntry = require ( '../../../lib/models/ActionQueueEntry' ) ;
@@ -48,10 +44,7 @@ class LifecycleObjectProcessor extends EventEmitter {
48
44
* @param {Object } lcConfig - lifecycle configuration object
49
45
* @param {String } lcConfig.auth - authentication info
50
46
* @param {String } lcConfig.objectTasksTopic - lifecycle object topic name
51
- * @param {Object } lcConfig.objectProcessor - kafka consumer object
52
- * @param {String } lcConfig.objectProcessor.groupId - kafka
53
47
* consumer group id
54
- * @param {Number } [lcConfig.objectProcessor.concurrency] - number
55
48
* of max allowed concurrent operations
56
49
* @param {Object } s3Config - S3 configuration
57
50
* @param {Object } s3Config.host - s3 endpoint host
@@ -65,7 +58,8 @@ class LifecycleObjectProcessor extends EventEmitter {
65
58
this . _zkConfig = zkConfig ;
66
59
this . _kafkaConfig = kafkaConfig ;
67
60
this . _lcConfig = lcConfig ;
68
- this . _authConfig = lcConfig . objectProcessor . auth || lcConfig . auth ;
61
+ this . _processConfig = this . getProcessConfig ( this . _lcConfig ) ;
62
+ this . _authConfig = this . getAuthConfig ( this . _lcConfig ) ;
69
63
this . _s3Config = s3Config ;
70
64
this . _transport = transport ;
71
65
this . _consumer = null ;
@@ -99,8 +93,8 @@ class LifecycleObjectProcessor extends EventEmitter {
99
93
backlogMetrics : this . _kafkaConfig . backlogMetrics ,
100
94
} ,
101
95
topic : this . _lcConfig . objectTasksTopic ,
102
- groupId : this . _lcConfig . objectProcessor . groupId ,
103
- concurrency : this . _lcConfig . objectProcessor . concurrency ,
96
+ groupId : this . _processConfig . groupId ,
97
+ concurrency : this . _processConfig . concurrency ,
104
98
queueProcessor : this . processKafkaEntry . bind ( this ) ,
105
99
} ) ;
106
100
this . _consumer . on ( 'error' , err => {
@@ -261,6 +255,32 @@ class LifecycleObjectProcessor extends EventEmitter {
261
255
this . _consumer . close ( cb ) ;
262
256
}
263
257
258
+ /**
259
+ * Retrieve object processor config
260
+ * @return {object } - process config
261
+ */
262
+ getProcessConfig ( ) {
263
+ throw new Error ( 'LifecycleObjectProcessor.getProcessConfig not implemented' ) ;
264
+ }
265
+
266
+ /**
267
+ * Retrieve process auth config
268
+ * @return {object } - auth config
269
+ */
270
+ getAuthConfig ( ) {
271
+ throw new Error ( 'LifecycleObjectProcessor.getAuthConfig not implemented' ) ;
272
+ }
273
+
274
+ /**
275
+ * Retrieve object processor task action
276
+ * @param {ActionQueueEntry } actionEntry - lifecycle action entry
277
+ * @return {BackbeatTask|null } - backbeat task object
278
+ */
279
+ // eslint-disable-next-line
280
+ getTask ( actionEntry ) {
281
+ return null ;
282
+ }
283
+
264
284
/**
265
285
* Proceed to the lifecycle action of an object given a kafka
266
286
* object lifecycle queue entry
@@ -279,20 +299,12 @@ class LifecycleObjectProcessor extends EventEmitter {
279
299
}
280
300
this . _log . debug ( 'processing lifecycle object entry' ,
281
301
actionEntry . getLogInfo ( ) ) ;
282
- const actionType = actionEntry . getActionType ( ) ;
283
- let task ;
284
- if ( actionType === 'deleteObject' ||
285
- actionType === 'deleteMPU' ) {
286
- task = new LifecycleDeleteObjectTask ( this ) ;
287
- } else if ( actionType === 'copyLocation' &&
288
- actionEntry . getContextAttribute ( 'ruleType' )
289
- === 'transition' ) {
290
- task = new LifecycleUpdateTransitionTask ( this ) ;
291
- } else {
292
- this . _log . warn ( `skipped unsupported action ${ actionType } ` ,
293
- actionEntry . getLogInfo ( ) ) ;
302
+ const task = this . getTask ( actionEntry ) ;
303
+
304
+ if ( task === null ) {
294
305
return process . nextTick ( done ) ;
295
306
}
307
+
296
308
return this . retryWrapper . retry ( {
297
309
actionDesc : 'process lifecycle object entry' ,
298
310
logFields : actionEntry . getLogInfo ( ) ,
@@ -306,6 +318,7 @@ class LifecycleObjectProcessor extends EventEmitter {
306
318
return {
307
319
s3Config : this . _s3Config ,
308
320
lcConfig : this . _lcConfig ,
321
+ processConfig : this . _processConfig ,
309
322
authConfig : this . _authConfig ,
310
323
getS3Client : this . _getS3Client . bind ( this ) ,
311
324
getBackbeatClient : this . _getBackbeatClient . bind ( this ) ,
@@ -317,7 +330,6 @@ class LifecycleObjectProcessor extends EventEmitter {
317
330
isReady ( ) {
318
331
return this . _consumer && this . _consumer . isReady ( ) ;
319
332
}
320
-
321
333
}
322
334
323
335
module . exports = LifecycleObjectProcessor ;
0 commit comments