Fix interceptor access via QGrpcInterceptorChain
The previous non-owning design allowed users to attach or remove
interceptors at runtime. While this may appear flexible, it diverges
from the established industry standard across the gRPC ecosystem (C++,
Java, Go, Python, and C#). In these implementations, the interceptor
pipeline is treated as an immutable graph of execution, established at
channel/stub construction.
We, as the QtGrpc client-side library, will inevitably interact with
those implementations, which all follow this different interception
style and logic.
gRPC interceptors are conceptually per-channel execution units that must
remain valid for the entire lifetime of the channel and for all RPCs
initiated through it. Major gRPC implementations attach interceptors
during channel construction and treat them as channel-scoped resources
rather than dynamically attachable objects.
Ref: https://grpc.io/docs/guides/interceptors/
In alignment with gRPC best practices, users should not interact with
interceptor objects directly after channel creation. Instead, a clear
separation between interceptor execution units and shared state should
be maintained, where runtime behavioral changes are handled through
thread-safe shared resources rather than modifying the pipeline itself.
This patch introduces the QGrpcInterceptorChain class, which allows
users to construct their interceptor chain, validate it, and access it
safely. The class is deliberately designed as a move-only type.
We add a constructor overload as well as a getter to
QAbstractGrpcChannel to support this new mechanism in favor of the old
non-owning API.
InterceptorCapability is now made public, as functionality such as
querying the capabilities of a chain, checking for individual
capabilities, or inspecting the capabilities of individual interceptors
is expected to be beneficial for users.
A new test case for QGrpcInterceptorChain is also added.
This patch comes without documentation. Those will be provided when the
implementation is considered to be stable and ready to be shipped in a
separate commit.
Found during the Qt 6.11 API review.
Fixes: QTBUG-142670
Pick-to: 6.11
Change-Id: Ia3dd42dd57e677ab70f233ea01f8ab7dc3aed5c4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>