Skip to content

Instantly share code, notes, and snippets.

@numberoverzero
Created December 4, 2014 10:25
Show Gist options
  • Select an option

  • Save numberoverzero/a9d4fd50b38b506dd552 to your computer and use it in GitHub Desktop.

Select an option

Save numberoverzero/a9d4fd50b38b506dd552 to your computer and use it in GitHub Desktop.
Python Service Stack
API Scaffolding
Plan: Create a stack for re-use when rapidly building out APIs featuring authentication, authorization, throttling, versioning, structures. API specification should be language agnostic so SDK creation is reasonable in non-python languages.
Server Stack:
-- custom API specification --
API parser
marshmallow
-- application layer --
Falcon
uwsgi
nginx
---
Client Stack:
-- custom API specification --
API parser
marshmallow
requests
---
Stack consumers (devs building services) should only need to implement the API specification and application layer, with throttling/versioning/authN/authZ built-into the Falcon layer. The generated SDK will not require any additional work - native Exceptions will propagate, allowing end-users to use expected language features (try/catch). Throttling and Auth exceptions will be built-in, although they can be customized in the API specification.
---
Implementation Steps:
1. Define API format and constraints. This should allow an obvious extension point for developers to enhance their service, such as streaming support or automatic continuation tokens. The constraints must not force users to rely on specific technologies - it must not require a json or xml wire format or restrict which verbs may be used, for instance. The format should be widely used, readable, and not whitespace sensitive.
2. Write a reference parser for the format, which generates marshmallow schemas with appropriate validation + structure.
3. Write skeleton wiring between nginx/uwsgi/falcon/application layer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment