Skip to main content

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

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)

Source distribution for schism 0.1.3
File Size Uploaded
schism-0.1.3.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for schism 0.1.3
File Interpreter ABI Platform
schism-0.1.3-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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