Skip to main content

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

status

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


Download files

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

Source Distribution

servey-stub-0.0.10.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

servey_stub-0.0.10-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file servey-stub-0.0.10.tar.gz.

File metadata

  • Download URL: servey-stub-0.0.10.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for servey-stub-0.0.10.tar.gz
Algorithm Hash digest
SHA256 96aabebdb0c1e1b02b110d2d4b5635683c78ba341bfc62c7dfcf42fd8a21a683
MD5 5d736f0822df92ae0e7c8e99126fdec5
BLAKE2b-256 666e5d65b0b00882dcfc8e7aa1cee207e9820bdc3e97b05e012e69f5671fd019

See more details on using hashes here.

File details

Details for the file servey_stub-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: servey_stub-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for servey_stub-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d3ced85daca5ff54d45fcd772ba4f88edb62efb8351623943cbe3ade10b900c0
MD5 6147aeabd1352afa590fec198e95b629
BLAKE2b-256 be3460b3b5272703489d2c2e7f8442ccf78e720582642a570cf17bd558408ade

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