A service stub generator for servey
Project description
Servey Stub
This project uses code generation to build python libraries containing service stubs for servey services. The objective is to allow multiple services to coordinate without having details of whether the code for other services...
- Is in the same python container
- Is based on AWS lambda
- Is accessed via http
Rationale
A lot of people have strong opinions on the Microservice vs Monolith debate, and the technologies involved mean we frequently end up with the downsides of both and the benefits of neither. This project is an attempt to reign in the chaos, at least in the context of servey projects.
Ideally, I want to be in a position where I can host and test with minimal configuration and external dependencies, while still being able to take advantage of a microservice architecture in a production environment. It would be nice to not have to run a server for each microservice when in a local development environment, but instead to be able to rely on pre-built stubs.
I generally dislike code generation as a practice, but in this case using code generation means we can take advantage of code completion available in most modern IDEs.
I think the best practice is still to layer projects, with higher layers have stubs only for the projects in layers below them. (rather than a self referencing free for all)
Installation
pip install servey-stub
Usage
All commands should be run in the project directory for your servey project.
--name
parameters specifies the name of the output project / module (Defaults to the current SERVEY_MAIN environment variable).--dir
specifies the output directory in which the generated project directory should be placed (Defaults to ./dist)- Any action which has a web trigger will be stubbed. (Since it indicates that the action can be invoked externally).
Actions can be limited by name with
--only
, or excluded with--exclude
Lambda
Generates / Updates a service stub project directory for invoking actions as AWS lambdas, and places it in the specified output directory.
python -m servey_stub --mode=lambdas
Yields: /servey_stub/my-service-lambdas/...
HTTP
Generates / Updates a service stub project directory for invoking actions over http, and places it in the specified output directory.
python -m servey_stub --mode=http --server_url=https://foo.com/bar
Yields: /servey_stub/my-service-http/...
TODO: We need to support some sort of authentication / authorization here (Probably oauth). These will need to be from the enviroment. e.g.: --headers=val:foo:bar,env:foo:bar
Passing authentication may present an issue - will need to encode - and if we encode, we need a key which the client respects.
Mock
Generates a service stub for invoking actions as mocks, and places it in the output directory. The mocks are based on definitions in the servey actions and the servey_main
python -m servey_stub --mode=mock --outdir=output
Yields: /output/my-service-mock/...
Example
Release Procedure
The typical process here is:
- Create a PR with changes. Merge these to main (The
Quality
workflows make sure that your PR meets the styling, linting, and code coverage standards). - New releases created in github are automatically uploaded to pypi
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
Hashes for servey_stub-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7dd158ee5444c180da7cb7783cd7e1caa8e5e6a5086527368ed9cd0625478a7 |
|
MD5 | cf916ced6b3c8d0766b94ee1140f268e |
|
BLAKE2b-256 | 60c23aef3408944292d24ad8addc2ec5d0e17619eb68f33e00be3a9d4490143f |