Skip to main content

Django intergration for nameko microservice framework.

Project description

django-nameko

Travis-CI Coverage Status

Branch Build status
master Build Status
develop Build Status

nameko-django

Django intergration for nameko microservice framework

Custom Kombu Serializer for django Object using msgpack and pickle

This serializer is fully compatible with msgpack so it can be used like this:

serializer: 'django_msgpackpickle'
ACCEPT: ['msgpack', 'django_msgpackpickle']
SERIALIZERS:
  msgpack:
    encoder: 'nameko_django.serializer.dumps'
    decoder: 'nameko_django.serializer.loads'
    content_type: 'application/x-msgpack'
    content_encoding: 'binary'

In order to migrate an existing microservices stack (that use msgpack serializer) to use this new serializer first install and setup all project

serializer: 'msgpack'
ACCEPT: ['msgpack', 'django_msgpackpickle']
SERIALIZERS:
  msgpack:
    encoder: 'nameko_django.serializer.pack'
    decoder: 'nameko_django.serializer.loads'
    content_type: 'application/x-msgpack'
    content_encoding: 'binary'

This will accept both of the msgpack and django_msgpackpickle but only output of result portfolio using msgpack Once all service migrated, then switch to the first configuration

Features

This serializer will automatically encode and decode:

  • DateTime, Date, Time, Duration: object will be converted to string representation compatible with django.utils.dateparse and convert back using django.utils.dateparse()
  • Decimal: object will be converted to byte string and then recover back to Decimal
  • Django ORM instance: object will be pickled using python cPickle/pickle library and depickled back to ORM Model instance
  • Django ORM queryset: object will be deform to Model + Query then pickled to avoid sending a list of instance

String evaluation

This serializer can evaluate string that is compatible with django.utils.dateparse format and auto convert the string to either DateTime, Date, Time, Duration object.

Also it can evaluate string with format like this: "<app_name.model_name.ID>" this will be converted to an ORM instance: using Model.objects.get(pk=ID) For example: <auth.User.1>

"(app_name.model_name: RAW_QUERY_WITHOUT_SELECT_FROM)" this will be converted to an ORM queryset For example: (auth.User: id >= 1 and date_joined > '2018-11-22 00:47:14.263837')

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-django-1.1.0.tar.gz (17.7 kB view details)

Uploaded Source

File details

Details for the file nameko-django-1.1.0.tar.gz.

File metadata

  • Download URL: nameko-django-1.1.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

File hashes

Hashes for nameko-django-1.1.0.tar.gz
Algorithm Hash digest
SHA256 07c8b9d1f98339eda4694b5c2df610b4fafa91df73b9b7ca46de01d2914318a4
MD5 2811b477f4873ef3e8e54545be632320
BLAKE2b-256 61cfd9fb7a170a01d2e6607b5a6ed34e2ef0d32f18008242620a31c12aea28a2

See more details on using hashes here.

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