nameko serializer compatible with datetime and namedtuple
Project description
enhenced json serializer for nameko micro-services.
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.
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
Development status
Installation
Install using pip:
pip install nameko-serializers
Alternatively, you can download or clone this repo and install with :
pip install -e ..
Requirements
work with nameko up to 1.12.*
Examples
install: pip install nameko-serializers
configure: add in your config.yaml the folowing line: serializer: nameko-serializer
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.
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.
Thanks
Thanks to Nameko for this amazing framework.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nameko-serializer-1.0.0.tar.gz
.
File metadata
- Download URL: nameko-serializer-1.0.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3cda106792f3706212a3ad119fe75234910aeb9498c11eee1a79bc8802f23f |
|
MD5 | c812139564b7f224fa28066ae8cf63a9 |
|
BLAKE2b-256 | 2f1d12151b2811940c7093f9e222b574c93928491fb2358dd50de5bfaf0cf77c |
File details
Details for the file nameko_serializer-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: nameko_serializer-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97e18c3e810afd27bb8ad171b1384d20f19e3910a8fc5a51f2f26754761869a7 |
|
MD5 | b6e2af949d68a430a28c455d1843a976 |
|
BLAKE2b-256 | 5718011dbf884a85cf4c983c5615889767b484de19439e031f0c99bd95c170db |