基于tornado和redis的全异步docsplit预览服务器
insight_reloaded的Python项目详细描述
简介
我们正在努力寻找我们的预览媒体服务器的最佳解决方案。
这个例子很简单,我们有pdf,我们想预览它们(小, 中、大、页眉)。
我们首先从Insight开始,它允许人们请求同步 异步预览来自带有缓存的url的生成。
系统能够注册引擎以便我们可以操作 流动的文件。
insight reloaded的思想是删除sync模式并委派 用磁盘或s3存储到nginx。
如果文档预览尚未就绪,则需要404错误。
我们将通过回调获取文档预览url。
API
简单示例
curl -X GET "http://localhost:8888/?url=http://my_file_url.com/file.pdf&callback=http://requestb.in/12vsewg" {"insight_reloaded": "Job added to queue.", "number_in_queue": 14} curl -X GET http://localhost:8888/status {"insight_reloaded": "There is 14 job in the queue.", "number_in_queue": 14} curl -X GET http://localhost:8888/ {"version": "1.5", "insight_reloaded": "Bonjour", "name": "insight-reloaded"}
多队列示例
必须在settings.py中配置REDIS_QUEUE_KEYS。
REDIS_QUEUE_KEYS = ['urgent', 'normal'] DEFAULT_REDIS_QUEUE_KEY = 'normal'
然后您可以使用:
curl -X GET "http://localhost:8888/urgent?url=http://my_file_url.com/file.pdf&callback=http://requestb.in/12vsewg" {"insight_reloaded": "Job added to queue 'normal'.", "number_in_queue": 14} curl -X GET http://localhost:8888/urgent/status {"insight_reloaded": "There is 14 job in the 'urgent' queue.", "number_in_queue": 14} curl -X GET http://localhost:8888/ {"version": "1.5", "insight_reloaded": "Bonjour", "name": "insight-reloaded"}
设置散列
默认情况下,insight使用url(sha1(url))计算预览散列。如果需要,也可以在请求中发送,请确保每个预览都有一个uniq散列:
curl -X GET "http://localhost:8888/?url=http://my_file_url.com/file.pdf&callback=http://requestb.in/12vsewg?hash=123456789" {"insight_reloaded": "Job added to queue.", "number_in_queue": 14}
服务架构
服务器配置
您可以在这里找到Insight重新加载的厨师食谱:https://github.com/novapost/insight-installer
这将帮助您安装运行Insight重新加载服务器的所有要求。
运行测试
make test