Swift的HTTP请求到WSGI Application

Proxy Server的入口是bin/swift-proxy-server文件
import sys
from swift.common.utils import parse_options
from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
    conf_file, options = parse_options()
sys.exit(run_wsgi(conf_file, 'proxy-server', **options))
run_wsgi()函数会启动Proxy Server去监听用户的HTTP请求,Paste Deploy会在这个WSGI Server创建时参与进来,基于/etc/swift/proxy-server.conf去加载WSGI Application。
在随后swift-proxy-server的运行过程中,Paste Deploy会将监听到的HTTP请求根据Paste配置文件准确路由到特定的WSGI Application。
[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk tempurl ratelimit tempauth container-quotas account-quotas slo dlo proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
[filter:slo]
use = egg:swift#slo
在pipeline里除了最后一个proxy-server,其他app都是作为filter的角色。“egg:swift#proxy “表示使用swift包中的proxy模块,slo(Static Large Object)filter定义中的”egg:swift#slo “表示使用swift包中的slo模块,这些模块都在setup.cfg文件的”entry_points“中进行了配置,使用setuptools加载。
[entry_points]
paste.app_factory =
    proxy = swift.proxy.server:app_factory
    object = swift.obj.server:app_factory
    mem_object = swift.obj.mem_server:app_factory
    container = swift.container.server:app_factory
    account = swift.account.server:app_factory
paste.filter_factory =
    healthcheck = swift.common.middleware.healthcheck:filter_factory
    crossdomain = swift.common.middleware.crossdomain:filter_factory
    memcache = swift.common.middleware.memcache:filter_factory
    ratelimit = swift.common.middleware.ratelimit:filter_factory
根据setup.cfg的配置,Paste Deploy最终将使用swift.proxy.server模块的app_factory()函数构建proxy-server这个WSGI app。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值