Beispiel #1
0
        /// <summary>
        /// Create a proxy, this method is also sued by ACtorReference also to create proxy.
        /// </summary>
        /// <param name="actorId">Actor Id.</param>
        /// <param name="actorInterfaceType">Actor Interface Type.</param>
        /// <param name="actorType">Actor implementation Type.</param>
        /// <returns>Returns Actor Proxy.</returns>
        internal object CreateActorProxy(ActorId actorId, Type actorInterfaceType, string actorType)
        {
            var remotingClient = new ActorRemotingClient(this.daprInteractor);
            var proxyGenerator = ActorCodeBuilder.GetOrCreateProxyGenerator(actorInterfaceType);
            var actorProxy     = proxyGenerator.CreateActorProxy();

            actorProxy.Initialize(remotingClient, actorId, actorType);

            return(actorProxy);
        }
        /// <summary>
        /// Creates a proxy to the actor object that implements an actor interface.
        /// </summary>
        /// <typeparam name="TActorInterface">
        /// The actor interface implemented by the remote actor object.
        /// The returned proxy object will implement this interface.
        /// </typeparam>
        /// <param name="serviceUri">Uri of the actor service.</param>
        /// <param name="actorId">Actor Id of the proxy actor object. Methods called on this proxy will result in requests
        /// being sent to the actor with this id.</param>
        /// <param name="listenerName">
        /// By default an actor service has only one listener for clients to connect to and communicate with.
        /// However it is possible to configure an actor service with more than one listeners, the listenerName parameter specifies the name of the listener to connect to.
        /// </param>
        /// <returns>An actor proxy object that implements <see cref="IActorProxy"/> and TActorInterface.</returns>
        public TActorInterface CreateActorProxy <TActorInterface>(
            Uri serviceUri,
            ActorId actorId,
            string listenerName = null) where TActorInterface : IActor
        {
            var actorInterfaceType          = typeof(TActorInterface);
            var proxyGenerator              = ActorCodeBuilder.GetOrCreateProxyGenerator(actorInterfaceType);
            var actorServicePartitionClient = new ActorServicePartitionClient(
                this.GetOrCreateServiceRemotingClientFactory(actorInterfaceType),
                serviceUri,
                actorId,
                listenerName,
                this.retrySettings);

            return((TActorInterface)(object)proxyGenerator.CreateActorProxy(actorServicePartitionClient));
        }
        internal object CreateActorProxy(
            Type actorInterfaceType,
            Uri serviceUri,
            ActorId actorId,
            string listenerName = null)
        {
            var proxyGenerator = ActorCodeBuilder.GetOrCreateProxyGenerator(actorInterfaceType);
            var actorServicePartitionClient = new ActorServicePartitionClient(
                this.GetOrCreateServiceRemotingClientFactory(actorInterfaceType),
                serviceUri,
                actorId,
                listenerName,
                this.retrySettings);

            return(proxyGenerator.CreateActorProxy(actorServicePartitionClient));
        }
Beispiel #4
0
 public void TestBuildActorProxyGenerator()
 {
     ActorProxyGenerator proxyGenerator = ActorCodeBuilder.GetOrCreateProxyGenerator(typeof(ITestActor));
 }