Proxy Types
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
Syntax and Semantics for Proxies
A Slice interface is not a Slice type – you cannot use a Slice interface as the type for a field or for a parameter in an operation.
Nevertheless, when you define an interface (or forward-declare this interface), you automatically create a new Slice type: the proxy type associated with this interface.
The name of this proxy type is InterfaceName*. For example:
interface Widget { ... }
struct S{ Widget badWidget; // syntax error: Widget is not a type Widget* widgetProxy; // ok: the field's type is Widget*}This proxy type can be marshaled/unmarshaled just like any other Slice type. It encapsulates the addressing information for the target object: object identity, endpoint(s), and proxy options.
You use proxies in client applications. A proxy acts as a local "ambassador" for the remote object; invoking an operation on the proxy forwards the invocation to the actual object implementation, in the server.
A proxy can be null. A proxy can also dangle: point to a remote object that no longer exists.
Self-Referential Interfaces
A proxy refers to an object rather than containing it, so an interface can reference a proxy to itself. For example:
interface Link{ idempotent SomeType getValue(); idempotent Link* next();}The Link interface contains a next operation that returns a proxy to a Link interface. Obviously, this can be used to create a chain of interfaces; the final link in the chain returns a null proxy from its next operation.