In Combadge a definition of a service protocol (also known as interface) is de-coupled from a service implementation. That allows a developer to define a service's interface and later bind it to a backend which in turn is directly responsible for handling requests and responses.
To define a service protocol one makes use of the PEP 544 aka «structural subtyping». Combadge inspects the protocol during «binding».
Combadge can inspect any Protocol or ABC.
But it might be a little easier to inherit from SupportsService
since it provides the bind(to_backend) method as a shorthand for bind(from_protocol,to_backend).
classSupportsService(Protocol):""" Convenience base for service protocols. Tip: Combadge can inspect any `Protocol` or `ABC`. But it might be a little easier to inherit from `#!python SupportsService` since it provides the `bind(to_backend)` method as a shorthand for `#!python bind(from_protocol, to_backend)`. """@classmethoddefbind(cls,to_backend:ProvidesBinder,/)->Self:"""Bind the current protocol to the specified backend."""returnbind(cls,to_backend)def__enter__(self)->Self:returnselfasyncdef__aenter__(self)->Self:returnselfdef__exit__(self,exc_type:type[BaseException]|None,exc_value:BaseException|None,traceback:TracebackType|None,)->Any:returnNoneasyncdef__aexit__(self,exc_type:type[BaseException]|None,exc_value:BaseException|None,traceback:TracebackType|None,)->Any:returnNone