Skip to content

Commit 14526a1

Browse files
authored
Add more example of transport
See #26757
1 parent 643bb80 commit 14526a1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md

+14
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ from azure.core.pipeline.transport import RequestsTransport
113113
synchronous_transport = RequestsTransport()
114114
```
115115

116+
For example if you would like to alter connection pool you can initialise `RequestsTransport` with an instance of `requests.Session`.
117+
118+
```Python
119+
from azure.cosmos import CosmosClient
120+
import requests
121+
session = requests.Session()
122+
adapter = requests.adapters.HTTPAdapter(pool_connections=42, pool_maxsize=42)
123+
session.mount('https://', adapter)
124+
cosmos_client = CosmosClient.from_connection_string(
125+
COSMOS_CONNECTION_STRING,
126+
transport=RequestsTransport(session=session)
127+
)
128+
```
129+
116130
For asynchronous pipelines a couple of transport options are available. Each of these transports are interchangable depending on whether the user has installed various 3rd party dependencies (i.e. aiohttp or trio), and the user
117131
should easily be able to specify their chosen transport. SDK developers should use the `aiohttp` transport as the default for asynchronous pipelines where the user has not specified an alternative.
118132

0 commit comments

Comments
 (0)