Schism
Schism is a service framework designed to simplify the process of splitting a single application into multiple services. It provides autowiring capabilities that make modularity straightforward in monolithic applications and facilitates code sharing in microservices architectures.
Installation
pip install schism
Usage
Schism is designed to have the smallest possible API surface area. You just need to create a service type that inherits from schism.Service. You can use Bevy's dependency injection to inject services into any function.
Creating a schism.config.yaml file in the root of your project will allow you to define the services that should be available in your application and how they should be exposed. Bevy then handles injecting the correct client facades into your functions so you can interact with the services as if they are still part of the same application.
To launch a service either set the SCHISM_ACTIVE_SERVICE environment variable to the name of the service to run using the schism run command. Alternatively pass the name to the schism run service command. Schism then starts the appropriate bridge servers using the configuration in the schism.config.yaml.
To run a client application that understands the running services use the schism run command. Pass it the desired module and callback (ex. module.path:callback) that you want to run (alternatively set up a launch config). Schism handles injecting the appropriate service client facades into the runtime before running the callback.
Example
Here's a basic example of a service that provides a simple greeting.
# greetings.py
from bevy import inject, dependency
from schism import Service, start_app
class GreetingService(Service):
async def greet(self, name: str) -> str:
print("Handling request...")
return f"Hello, {name}!"
@inject
async def greet(greeting_service: GreetingService = dependency()):
print(await greeting_service.greet("World"))
async def main():
await greet()
if __name__ == "__main__":
start_app(main()) # Activate a Schism controller and launch the app
Here is the corresponding schism.config.yaml file:
launch:
app: greetings:main
services:
- name: greeting
service: greetings:GreetingService
bridge:
type: schism.ext.bridges.simple_tcp:SimpleTCP
serve_on: localhost:1234
To run you must first start the greetings service with this command:
schism run service greeting
Then you can run the script and that accesses the service by passing schism.run the entry point coroutine:
schism run
Alternatively you can run it as a normal Python script with no client facades where everything runs in a single process.
python greetings.py
or
python -m greetings
Metadata
Release files for schism 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| schism-0.1.3.tar.gz | 13.4 kB | Without provenance | Details for schism-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schism-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for schism-0.1.3-py3-none-any.whl |
Total release size: 29.5 kB
Release files / schism-0.1.3.tar.gz
| Download URL | schism-0.1.3.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc63648e74928f87fac74a2d6a20acf403fa9135ddfea5c71120db3c1ed53b4e
|
|
BLAKE2b-256 checksum How to use checksums |
dcd417f848969c39e9a6f89fffeecedc0ff7911e0a225541be56a417e920f667
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Release files / schism-0.1.3-py3-none-any.whl
| Download URL | schism-0.1.3-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06943c1d78bcca6b6ddd109cc134cb59ff2ffd7e725f01b5537e59e50dd87d48
|
|
BLAKE2b-256 checksum How to use checksums |
788abd6e20f0760876c131940994af5e4aeb3c5b78f6d5fb8bcda5b87ec716ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Security for schism 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.