Dispatcher API
2 min read
2 min read
2 min read
2 min read
Ice::Object Base Class
For historical reasons, the Dispatcher abstraction does not correspond to a Dispatcher abstract base class in C++. We use instead the base class Ice::Object as the dispatcher base class.
Object is a concrete class that implements the pseudo Slice interface Object:
namespace Ice{ class Object { public: virtual void dispatch( IncomingRequest& request, std::function<void(OutgoingResponse)> sendResponse); ... };}The implementation of dispatch on Ice::Object dispatches an incoming request to the 4 operations defined on Object: ice_id, ice_ids, ice_isA, and ice_ping. It throws OperationNotExistException for any other operation.
This implementation is immaterial: in practice, a dispatcher is any C++ class derived from Ice::Object that reimplements dispatch. This dispatcher may (but does not need to) implement the 4 operations defined on Object.
Ice.Object Interface
For historical reasons, the Dispatcher abstraction does not correspond to a Dispatcher interface in C#. We use instead the interface Ice.Object as the base interface for dispatchers.
Object is a interface that provides the default implementation for the pseudo Slice interface Object:
namespace Ice;
[SliceTypeId("::Ice::Object")]public interface Object{ public ValueTask<OutgoingResponse> dispatchAsync(IncomingRequest request) { ... } ...}The implementation of dispatch on Ice.Object dispatches an incoming request to the 4 operations defined on Object: ice_id, ice_ids, ice_isA, and ice_ping. It throws OperationNotExistException for any other operation.
This implementation is immaterial: in practice, a dispatcher is any C# class that implements Ice.Object and reimplements dispatch. This dispatcher may (but does not need to) implement the 4 operations defined on Object.
Object Interface
For historical reasons, the Dispatcher abstraction does not correspond to a Dispatcher interface in Java. We use instead the interface com.zeroc.Ice.Object as the base interface for dispatchers.
com.zeroc.Ice.Object is a interface that provides the default implementation for the pseudo Slice interface Object:
package com.zeroc.Ice;
@SliceTypeId(value = "::Ice::Object")public interface Object { default CompletionStage<OutgoingResponse> dispatch( IncomingRequest request) throws UserException { ... }}The implementation of dispatch on com.zeroc.Ice.Object dispatches an incoming request to the 4 operations defined on Object: ice_id, ice_ids, ice_isA, and ice_ping. It throws OperationNotExistException for any other operation.
This implementation is immaterial: in practice, a dispatcher is any Java class that implements com.zeroc.Ice.Object and reimplements dispatch. This dispatcher may (but does not need to) implement the 4 operations defined on Object.
Ice.Object Base Class
For historical reasons, the Dispatcher abstraction does not correspond to a Dispatcher base class in JavaScript. We use instead the base class Ice.Object as the dispatcher base class.
Object is a concrete class that implements the pseudo Slice interface Object:
export class Object { dispatch(request) { ... }}declare module "@zeroc/ice" { namespace Ice { class Object { dispatch(request: IncomingRequest): OutgoingResponse | PromiseLike<OutgoingResponse>; } }}The implementation of dispatch on Ice.Object dispatches an incoming request to the 4 operations defined on Object: ice_id, ice_ids, ice_isA, and ice_ping. It throws OperationNotExistException for any other operation.
This implementation is immaterial: in practice, a dispatcher is any JavaScript class derived from Ice.Object that reimplements dispatch. This dispatcher may (but does not need to) implement the 4 operations defined on Object.
The Dispatcher abstraction was not mapped to Python yet. The only kind of dispatchers you can create in Python are servants.
The Dispatcher abstraction corresponds to the Swift Dispatcher protocol
public protocol Dispatcher: Sendable { func dispatch(_ request: sending IncomingRequest) async throws -> OutgoingResponse}A dispatcher is any type that implements this protocol.
Servants
In C++, a servant is a concrete class that implements the Dispatcher abstraction by itself, without delegating to some other object. In other words, a servant is a “terminal dispatcher”. The base class for all C++ servants is Ice::Object. A servant should generally handle the 4 operations defined on the pseudo-Slice interface Object.
The most common type of C++ servants are classes that implement skeleton classes generated by the Slice compiler. These generated skeleton classes reimplement dispatch by:
- unmarshaling input parameters
- calling the pure virtual member function whose name matches the operation name carried by the request (you implement this pure virtual function in the servant class)
- creating a response from the return value and out parameters returned by this function
They also implement or reimplement the 4 operations defined on Object.
In C#, a servant is a concrete class that implements the Dispatcher abstraction by itself, without delegating to some other object. In other words, a servant is a “terminal dispatcher”. A servant should generally handle the 4 operations defined on the pseudo-Slice interface Object.
The most common type of C# servants are classes that implement skeleton classes generated by the Slice compiler. These generated skeleton classes reimplement dispatch by:
- unmarshaling input parameters
- calling the pure virtual member function whose name matches the operation name carried by the request (you implement this pure virtual function in the servant class)
- creating a response from the return value and out parameters returned by this function
They also implement or reimplement the 4 operations defined on Object.
In Java, a servant is a concrete class that implements the Dispatcher abstraction by itself, without delegating to some other object. In other words, a servant is a “terminal dispatcher”. A servant should generally handle the 4 operations defined on the pseudo-Slice interface Object.
The most common type of Java servants are classes that implement skeleton classes generated by the Slice compiler. These generated skeleton classes reimplement dispatch by:
- unmarshaling input parameters
- calling the pure virtual member function whose name matches the operation name carried by the request (you implement this pure virtual function in the servant class)
- creating a response from the return value and out parameters returned by this function
They also implement or reimplement the 4 operations defined on Object.
In JavaScript, a servant is a concrete class that implements the Dispatcher abstraction by itself, without delegating to some other object. In other words, a servant is a “terminal dispatcher”. A servant should generally handle the 4 operations defined on the pseudo-Slice interface Object.
The most common type of JavaScript servants are classes that implement skeleton classes generated by the Slice compiler. These generated skeleton classes reimplement dispatch by:
- unmarshaling input parameters
- calling the pure virtual member function whose name matches the operation name carried by the request (you implement this pure virtual function in the servant class)
- creating a response from the return value and out parameters returned by this function
They also implement or reimplement the 4 operations defined on Object.
In Python, a servant is a concrete class derived from class Ice.Object.
The most common type of Python servants are classes derived from skeleton classes generated by the Slice compiler.
In Swift, a servant is a “terminal dispatcher”: a type that implements the Dispatcher abstraction by itself, without delegating to another object.
The most common Swift servants adopt a skeleton protocol generated by the Slice compiler, along with an extension that implements dispatch by:
- unmarshaling input parameters
- calling the protocol method for the operation named by the request (you implement this method in your servant)
- creating a response from the return value and out parameters returned by this method
This dispatch also implements the 4 operations defined on Object: it calls your servant's own implementation when your servant adopts Ice.Object, and a default implementation otherwise.