8000 update readme · elastic/elasticsearch-py-async@fc3b961 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit fc3b961

Browse files
committed
update readme
1 parent 78d2ad3 commit fc3b961

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,34 @@ Example::
2424
loop.close()
2525
client.transport.close()
2626

27+
28+
Example with SSL Context::
29+
30+
import asyncio
31+
from elasticsearch_async import AsyncElasticsearch
32+
from elasticsearch.connection.http_urllib3 import create_ssl_context
33+
34+
context = create_ssl_context(cafile="/certs/ca/ca.crt")
35+
36+
37+
client = AsyncElasticsearch(
38+
hosts=['elasticsearch-xpack'],
39+
ssl_context=context,
40+
http_auth=('elastic', 'changeme')
41+
)
42+
43+
@asyncio.coroutine
44+
def print_info():
45+
info = yield from client.info()
46+
print(info)
47+
48+
loop = asyncio.get_event_loop()
49+
loop.run_until_complete(print_info())
50+
loop.close()
51+
client.transport.close()
52+
53+
54+
2755
``AsyncElasticsearch`` introduces one extra parameter ``loop`` which can be
2856
used to pass in an event loop you wish the client to use. By default
2957
``asyncio.get_event_loop()`` will be used.

0 commit comments

Comments
 (0)
0