zerovm / zerocloud

Swift middleware for Zerocloud
Apache License 2.0
53 stars 14 forks source link

implement simple job chaining #108

Closed pkit closed 10 years ago

pkit commented 10 years ago

this patch adds another middleware ChainMiddleware the middleware allows rescheduling of response from previous job as a new job for the chain to work the following statements should be true:

you can see that the application that tries to chain something should be able to set a response header which means that application MUST use message/cgi or message/http as its output channel content type ChainMiddleware MUST be placed anywhere before ProxyQueryMiddleware in the proxy-server pipeline

example job description that can output a chained job is:

[
        {
            'name': 'http',
            'exec': {'path': 'swift://a/c/chainer'},
            'devices': [
                {
                    'name': 'stdout',
                    'content_type': 'message/http'
                }
            ]
        }
]

as you can see, stdout has no path - will be sent to user, and its content_type is message/http

Protection from infinite loops: ChainMiddleware has a config file setting chain_timeout (in seconds), by default chain_timeout = 20. If chain is executing more than chain_timeout the chain will stop and the resulting job description file will be returned to user.