TServiceProcessor

Service processor for Interface, which implements TProcessor by synchronously forwarding requests for the service methods to a handler implementing Interface.

The generated class implements TProcessor and additionally allows a TProcessorEventHandler to be specified via the public eventHandler property. The constructor takes a single argument of type Interface, which is the handler to forward the requests to:

this(Interface iface);
TProcessorEventHandler eventHandler;

If Interface is derived from another service BaseInterface, this class is also derived from TServiceProcessor!BaseInterface.

The optional Protocols template tuple parameter can be used to specify one or more TProtocol implementations to specifically generate code for. If the actual types of the protocols passed to process() at runtime match one of the items from the list, the optimized code paths are taken, otherwise, a generic TProtocol version is used as fallback. For cases where the input and output protocols differ, TProtocolPair!(InputProtocol, OutputProtocol) can be used in the Protocols list:

interface FooService { void foo(); }
class FooImpl { override void foo {} }

// Provides fast path if TBinaryProtocol!TBufferedTransport is used for
// both input and output:
alias TServiceProcessor!(FooService, TBinaryProtocol!TBufferedTransport)
  BinaryProcessor;

auto proc = new BinaryProcessor(new FooImpl());

// Low overhead.
proc.process(tBinaryProtocol(tBufferTransport(someSocket)));

// Not in the specialization list – higher overhead.
proc.process(tBinaryProtocol(tFramedTransport(someSocket)));

// Same as above, but optimized for the Compact protocol backed by a
// TPipedTransport for input and a TBufferedTransport for output.
alias TServiceProcessor!(FooService, TProtocolPair!(
  TCompactProtocol!TPipedTransport, TCompactProtocol!TBufferedTransport)
) MixedProcessor;
template TServiceProcessor (
Interface
Protocols...
) if (
isService!Interface &&
allSatisfy!(isTProtocolOrPair, Protocols)
)

Meta