def setUpClass() -> None: oaas.register_server_provider(OaasGrpcServer()) oaas.register_client_provider(OaasGrpcClient()) oaas.register_server_provider(OaasSimpleServer()) oaas.register_client_provider(OaasSimpleClient()) oaas.serve()
def main(): oaas.register_client_provider(oaas_grpc.OaasGrpcClient()) oaas.register_server_provider(oaas_grpc.OaasGrpcServer(port=port)) oaas.serve() print(f"test server running on {port}") oaas.join()
def main(): signal.signal(signal.SIGUSR1, print_registered_services) logging.basicConfig(level=logging.INFO, stream=sys.stderr) oaas.register_server_provider(OaasGrpcServer()) oaas.register_client_provider(OaasGrpcClient()) oaas.serve() LOG.info("OaaS Registry listening on 8999") oaas.join()
def main(): oaas.register_client_provider(oaas_grpc.OaasGrpcClient()) oaas.register_server_provider(oaas_grpc.OaasGrpcServer(port=port)) oaas.serve() register_dynamic_service() signal.signal(signal.SIGUSR2, unregister_dynamic_service) print(f"test server running on {port}") oaas.join()
def ensure_grpc_client(): """ If we're exposing gRPC services, we also need to register them into the oaas-registry. For this to happen, we need to have the OaasGrpcClient registered. If the user forgot to add it, we'll add it ourselves. """ for client in registrations.clients_middleware: if isinstance(client, OaasGrpcClient): return oaas.register_client_provider(OaasGrpcClient())
import time import oaas import oaas_grpc from features.steps.testsvc.stdreader import read_stderr from features.steps.testsvc.testsvc_pb2_grpc import ProcessNameStub from features.support.model import BaseContext from features.support.process_execution import ProcessExecution oaas.register_client_provider(oaas_grpc.OaasGrpcClient()) oaas.client("process-name")(ProcessNameStub) def before_scenario(context: BaseContext, scenario) -> None: """ Before each scenario we're going to setup the registry, then tear it down. """ context.client = None context.processes = dict() process = ProcessExecution(command=["python", "-m", "oaas_registry"]) context.processes["registry"] = process while not "listening on 8999" in read_stderr(process): time.sleep(0.1) def after_scenario(context: BaseContext, scenario) -> None: for process_name, process_execution in context.processes.items():
def __init__(self) -> None: self._grpc_client: Optional[OaasGrpcClient] = None # FIXME: instantiating a client shouldn't magically add it oaas.register_client_provider(OaasGrpcClient())
import sys from PySide2.QtWidgets import QApplication from adhesive_event_debugger.ui.main_window import MainWindow import oaas_simple import oaas oaas.register_server_provider(oaas_simple.OaasSimpleServer(port=9000)) oaas.register_client_provider(oaas_simple.OaasSimpleClient()) oaas.serve() def main(): app = QApplication(sys.argv) main_window = MainWindow() main_window.show() sys.exit(app.exec_()) if __name__ == '__main__': main()
@oaas.client("datastore") class DataStore: def put_item(self, key: str, value: Any) -> None: ... def get_item(self, key: str) -> Any: ... def remove_item(self, key: str) -> None: ... provider = LocalClientServerMiddleware() oaas.register_server_provider(provider) oaas.register_client_provider(provider) oaas.serve() class TestServiceRegistrar(unittest.TestCase): def test_service_calls(self) -> None: data_store = oaas.get_client(DataStore) self.assertIsNone(data_store.get_item("a")) data_store.put_item("a", "avalue") self.assertEqual("avalue", data_store.get_item("a")) data_store.remove_item("a") self.assertIsNone(data_store.get_item("a"))