@@ -21,32 +21,12 @@ const Result = {
2121}
2222
2323const actionHandlers = { }
24- const actions = { }
25- var nextActionId = 1
26-
27- const pruneActionTimeout = 60 * 60 * 1000
28- const pruneInterval = 15 * 60 * 1000
2924
3025module . exports = {
3126 start : function ( app ) {
3227 app . registerActionHandler = registerActionHandler
3328 app . deRegisterActionHandler = deRegisterActionHandler
3429
35- setInterval ( pruneActions , pruneInterval )
36-
37- app . get ( apiPathPrefix + 'actions' , function ( req , res , next ) {
38- res . json ( actions )
39- } )
40-
41- app . get ( apiPathPrefix + 'actions/:id' , function ( req , res , next ) {
42- var action = actions [ req . params . id ]
43- if ( ! action ) {
44- res . status ( 404 ) . send ( )
45- } else {
46- res . json ( action )
47- }
48- } )
49-
5030 app . put ( apiPathPrefix + '*' , function ( req , res , next ) {
5131 var path = String ( req . path ) . replace ( apiPathPrefix , '' )
5232
@@ -225,31 +205,3 @@ function deRegisterActionHandler (context, path, source, callback) {
225205 debug ( `de-registered action handler for ${ context } ${ path } ${ source } ` )
226206 }
227207}
228-
229- function asyncCallback ( actionId , status ) {
230- var action = actions [ actionId ]
231- if ( action ) {
232- action . state = status . state
233- action . result = status . result
234- action [ 'endTime' ] = new Date ( ) . toISOString ( )
235- if ( status . message ) {
236- action . message = status . message
237- }
238- if ( status . percentComplete ) {
239- action . percentComplete = status . percentComplete
240- }
241- }
242- }
243-
244- function pruneActions ( ) {
245- debug ( 'pruning actions' )
246- _ . keys ( actions ) . forEach ( id => {
247- var action = actions [ id ]
248-
249- var diff = new Date ( ) - new Date ( action [ 'end-time' ] )
250- if ( diff > pruneActionTimeout ) {
251- delete actions [ id ]
252- debug ( 'pruned action %d' , id )
253- }
254- } )
255- }
0 commit comments