对龙卷风使用 elasticsearch_async

Use elasticsearch_async with tornado

我正在尝试将 elasticsearch_async (repo) 与 tornado 6.0.3 一起使用。

根据我对代码的理解,如果我使用 AsyncElasticSearch 并传递当前龙卷风 ioloop,它将起作用。有人可以确认或指出一个例子吗?

我的第二个问题是 - 我看到 AsyncElasticSearch 在内部使用 AIOHttpConnection (code) 作为默认值 connection_class。我是否需要创建一个新的 connection_class 适配器以传递给使用 tornado 的 AsyncHttpClientconnection_class,或者 tornado 是否可以与 AIOHttpConnection 无缝工作?

From what I understood going through the code, if I use AsyncElasticSearch and pass the current tornado ioloop, it will work. Can someone confirm or point to an example?

AsyncElasticSearch 想要一个 asyncio 事件循环,而不是 Tornado IOLoop。但在 Tornado 6 中,Tornado IOLoop 只是 asyncio 事件循环的包装器,所以如果你忽略所有这些并使用默认值,一切都应该正常工作。

Do I need to create a new connection_class adapter to pass to the connection_class which uses tornado's AsyncHttpClient or will the tornado work seamlessly with AIOHttpConnection?

没有。即使应用程序的其他部分正在使用 AsyncHTTPClient,也只需让 AsyncElasticSearch 使用 aiohttp。它应该一起工作(虽然我还没有真正尝试过这种组合)。