Skip to content

microrequests is a wrapper over requests module - makes it more efficient to consume microservices in Python

License

Notifications You must be signed in to change notification settings

abhinavs/microrequests

Repository files navigation

microrequests

This module makes consuming microservices in Python more efficient. Python’s requests module is fantastic and highly configurable, microrequests builds a wrapper over requests module and enables connection pooling as part of initialisation. This ensures that you use the same connection instead of creating one with every new request, while still working with requests’ clean APIs and mechanism.

This is first version of microrequests and we intend to add more nifty ways to make consuming microservices easy and efficient.

Installation

The easiest way to install microrequests is using pip

$ pip install microrequests

Usage

To use, simply do:

import microrequests

mr = microrequests.init()
res = mr.get("http://httpbin.org/get") # mr is requests' session object and you can use it in similar manner
print(res.text)

You can also customize max_retries, pool_connections and pool_maxsize - they are by default set to 1, 100 and 50 respectively; pool_connections is the number of urllib3 connection pools to cache and poolmaxsize is the maximum number of connections to save in the pool

import microrequests

mr = microrequests.init(max_retries=2, pool_connections=10, pool_size=5)
res = mr.get("http://httpbin.org/get")
print(res.text)

Tests

To run tests:

$ tox

TODO

  • Write more tests

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/abhinavs/microrequests. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the microrequests project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Copyright

Copyright (c) 2020 Abhinav Saxena. See MIT License for further details.

About

microrequests is a wrapper over requests module - makes it more efficient to consume microservices in Python

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages