A transport for OaaS that uses a single grpc function. It should work out of the box for most simple scenarios.
Installation
pip install oaas_simple
Usage
To get a process that does both the client and the server:
oaas.register_server_provider(OaasGrpcTransportServer(port=9000))
oaas.register_client_provider(OaasGrpcTransportClient())
oaas.serve()
Exposing services is done via regular oaas decorators:
@oaas.service("test-service")
class TestCallService:
def echo_data(self, *, data: str) -> str:
return data
Again for consumers:
@oaas.client("test-service")
class TestCallClient:
def echo_data(self, *, data: str) -> str:
...
In order to make the services find each other you need a registry. You can fire up the embedded registry:
python -m oaas_simple.registry
The only requirement is that the registry listens on port 8999
Minimal Client
import oaas
import oaas_simple
@oaas.client("swag")
class Swag:
def print_stuff(message: str) -> str:
...
oaas.register_client_provider(oaas_simple.OaasSimpleClient())
swag = oaas.get_client(Swag)
print(swag.print_stuff("abc"))
Minimal Server
import oaas
import oaas_simple
@oaas.service("swag")
class Swag:
def print_stuff(self, message: str) -> str:
print(message)
return f"from server {message}"
# it needs the client to find the registry, since the registry is also an
# oaas.service("oaas-registry")
oaas.register_client_provider(oaas_simple.OaasSimpleClient())
oaas.register_server_provider(oaas_simple.OaasSimpleServer(port=9000))
oaas.serve()
oaas.join()
Metadata
Release files for oaas_simple 1.3.0
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 |
|---|---|---|---|---|
| oaas_simple-1.3.0.tar.gz | 8.6 kB | Without provenance | Details for oaas_simple-1.3.0.tar.gz |
Release files / oaas_simple-1.3.0.tar.gz
| Download URL | oaas_simple-1.3.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d342f122328fafc4c00df3f100d009f0b37717a3560e02a9eae3a9d5865236c
|
|
BLAKE2b-256 checksum How to use checksums |
458ac2b4e823623ca4a35447b094f154ed72ce860921832ff8a3464bb517d6ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.8
|
Security for oaas_simple 1.3.0
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.