etm.wccoa.msa.vrpc
vRPC — the MSA protocol that carries a WinCC OA value as its payload.
This is the package applications import.
It is deliberately flat and hides the split between MSA and the protocol:
the re-exported names are the very same types as in etm.wccoa.msa.base, so vrpc.Status is base.Status.
These names are re-exported unchanged and documented where they are defined:
AsyncUnaryCall,
Metadata,
PayloadEncryptionMode,
Responder,
RpcError,
ServerContext,
ServiceContainer,
ServiceHostingReplica,
ServiceHostingType,
ServiceOptions,
ServiceStatus,
Status,
StatusCode,
StubOptions,
StubStatus.
Example
>>> from etm.wccoa.msa import vrpc
>>> stub = vrpc.Stub.create_and_initialize(mgr, "Greeter")
>>> stub.call_function("SayHello", "Bob")
Package Contents
Classes
ServiceBase
|
Derive from this to offer a service, and register the methods in __init__. |
|---|---|
Stub
|
Calls methods of a service that another manager offers. |
Data
UnaryHandler
|
Form S1 — the return value is the response. |
|---|---|
UnaryResponderHandler
|
Form S3 — the response is sent later, from any thread. |
API
class etm.wccoa.msa.vrpc.ServiceBase(service_name: str)
Bases: etm.wccoa.msa.base.ServiceBase
Derive from this to offer a service, and register the methods in __init__.
Handlers run on the service’s own thread, one after another, so they need not be thread safe. Returning a value answers the call (S1); taking a third parameter defers the answer (S3).
Example
>>> class GreeterService(ServiceBase):
... def __init__(self) -> None:
... super().__init__("Greeter")
... self.register_function("SayHello", self._say_hello)
...
... def _say_hello(self, ctx: ServerContext, request: OaVariant) -> OaValueLike:
... return f"Hello {request}"
Initialization
Build the native service; the protocol layer supplies its identity.
register_function(method: str, handler: etm.wccoa.msa.vrpc._server._service.UnaryHandler | etm.wccoa.msa.vrpc._server._service.UnaryResponderHandler) → None
Bind a wire name to a handler.
The name is always given explicitly; nothing is derived from the Python method name and no case conversion takes place.
-
Raises:
- ValueError – if the name is already registered, or if the handler is neither of the two forms.
property service_name : str
class etm.wccoa.msa.vrpc.Stub(manager: etm.wccoa.manager.Manager, service_base_name: str, options: etm.wccoa.msa.base.StubOptions | None = None)
Calls methods of a service that another manager offers.
The constructor does not communicate.
Initialization happens explicitly via initialize(), through create_and_initialize(),
or implicitly on the first call.
Example
>>> with Stub(mgr, "Greeter") as stub:
... stub.call_function("SayHello", "Bob")
Initialization
classmethod create_and_initialize(manager: etm.wccoa.manager.Manager, service_base_name: str, options: etm.wccoa.msa.base.StubOptions | None = None) → etm.wccoa.msa.vrpc._client._stub.Stub
Construct and initialize in one step.
- Returns: The initialized stub.
initialize() → None
Look the service up and prepare the connection.
The call is idempotent.
-
Raises:
- RpcError – if the service cannot be reached.
property status : etm.wccoa.msa.base.StubStatus
Where this stub stands in its lifecycle.
This can be found at: etm.wccoa.msa.base.StubStatus
property is_initialized : bool
call_function(method: str, request: etm.wccoa.datatypes.OaValueLike, *, deadline: datetime.datetime | None = None, headers: etm.wccoa.datatypes.Metadata | None = None) → etm.wccoa.datatypes.OaVariant
Call method and wait for the response.
method is the wire name and is compared ignoring case only
— say_hello is a different method than sayHello.
A naive deadline is read as local time.
Only the response value is returned.
Use call_function_async() when the status or the response and trailing headers are needed as well.
- Returns: The response value.
-
Raises:
- RpcError – if the call failed.
call_function_async(method: str, request: etm.wccoa.datatypes.OaValueLike, *, deadline: datetime.datetime | None = None, headers: etm.wccoa.datatypes.Metadata | None = None) → etm.wccoa.msa.base.AsyncUnaryCall
Start method and return the handle at once.
- Returns: The handle of the running call.
close() → None
Release the native invoker. Idempotent.
etm.wccoa.msa.vrpc.UnaryHandler : TypeAlias
None
Form S1 — the return value is the response.
etm.wccoa.msa.vrpc.UnaryResponderHandler : TypeAlias
None
Form S3 — the response is sent later, from any thread.
