Skip to main content

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

Metadata

Release files for servey-stub 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for servey-stub 0.0.10
File Size Uploaded
servey-stub-0.0.10.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for servey-stub 0.0.10
File Interpreter ABI Platform
servey_stub-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 35.9 kB

Release files / servey-stub-0.0.10.tar.gz

Download URL servey-stub-0.0.10.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
96aabebdb0c1e1b02b110d2d4b5635683c78ba341bfc62c7dfcf42fd8a21a683
BLAKE2b-256 checksum
How to use checksums
666e5d65b0b00882dcfc8e7aa1cee207e9820bdc3e97b05e012e69f5671fd019
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / servey_stub-0.0.10-py3-none-any.whl

Download URL servey_stub-0.0.10-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3ced85daca5ff54d45fcd772ba4f88edb62efb8351623943cbe3ade10b900c0
BLAKE2b-256 checksum
How to use checksums
be3460b3b5272703489d2c2e7f8442ccf78e720582642a570cf17bd558408ade
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page