Skip to main content

nameko serializer compatible with datetime and namedtuple

Project description

enhenced json serializer for nameko micro-services.

  1. it allow to pass datetime.date and datetime.datetime to rpc calls and event arguments. get ride of datetime.datetime not JSON serializable errors messages in nameko.

  2. add support for namedtuple in service transmissions. you return a namedtuple instance, you get the same namedtuple in the other side, which is retro-comatible and support either res.attr or res['attr']

Stable branch

https://img.shields.io/travis/Yupeek/nameko-serializer/master.svg https://readthedocs.org/projects/nameko-serializer/badge/?version=latest https://coveralls.io/repos/github/Yupeek/nameko-serializer/badge.svg?branch=master Latest PyPI version Requirements Status

Development status

https://img.shields.io/travis/Yupeek/nameko-serializer/develop.svg https://coveralls.io/repos/github/Yupeek/nameko-serializer/badge.svg?branch=develop Requirements Status

Installation

  1. Install using pip:

    pip install nameko-serializers

  2. Alternatively, you can download or clone this repo and install with :

    pip install -e ..

Requirements

work with nameko up to 1.12.*

Examples

  1. install: pip install nameko-serializers

  2. configure: add in your config.yaml the folowing line: serializer: nameko-serializer

  3. enjoy

datetime support (with timezone)

Documentation

this Readme is currently the full documentation. it’s not a library this big…

features

date and datetime serializing

this serializer will handle datetime and date serializing. if a datetime is timezone naive, it will be made aware using the detected current timezone (via tzlocal.get_localzone())

all received dates will be timezone aware, but the timezone will be fixed to UTC.

NamedTulpe support

this serializer allow to transmit namedtuple as dict, and will deserialize it as special namedtuple, supporting dict index

Requirements

  • Python 2.7, 3.6, 3.7

Contributions and pull requests are welcome.

Bugs and requests

If you found a bug or if you have a request for additional feature, please use the issue tracker on GitHub.

https://github.com/Yupeek/nameko-serializer/issues

known limitations

  • if you pass some objects with keys __type__, it will be converted.

  • all unserialized dates will be tz aware, and tzinfo will be set to UTC. (this is a good practice to change tz at display time)

  • for python < 3.7, the order in the namedtuple is not garanteed, use exclusively kwargs and attrs by names

License

You can use this under GPLv3.

Author

Original author: Darius BERNARD.

Thanks

Thanks to Nameko for this amazing framework.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nameko-serializer-1.0.0.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

nameko_serializer-1.0.0-py2.py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page