mirror of https://github.com/dapr/dotnet-sdk.git
Renaming Dispatch and Invoke method.
This commit is contained in:
parent
dcea4bf40d
commit
d709d067b1
|
|
@ -74,9 +74,9 @@ namespace Microsoft.Actions.Actors
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<object> InvokeActorMethod(string actorId, string actorType, string methodName, string messageHeader, byte[] messageBody, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<object> InvokeActorMethodWithRemotingAsync(string actorId, string actorType, string methodName, string messageHeader, byte[] messageBody, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var relativeUrl = $"{Constants.ActionsVersion}/{Constants.ActorRequestRelativeUrl}/{actorType}/{actorId}/method/{methodName}";
|
||||
var relativeUrl = $"{Constants.ActionsVersion}/{Constants.ActorRequestRelativeUrl}/{actorType}/{actorId}/{Constants.Method}/{methodName}";
|
||||
var requestId = Guid.NewGuid().ToString();
|
||||
|
||||
HttpRequestMessage RequestFunc()
|
||||
|
|
@ -88,8 +88,6 @@ namespace Microsoft.Actions.Actors
|
|||
};
|
||||
|
||||
request.Headers.Add(Constants.RequestHeaderName, messageHeader);
|
||||
|
||||
// Encoding.UTF8.GetString(messageHeader, 0, messageHeader.Length));
|
||||
request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream; charset=utf-8");
|
||||
return request;
|
||||
}
|
||||
|
|
@ -98,9 +96,9 @@ namespace Microsoft.Actions.Actors
|
|||
return response;
|
||||
}
|
||||
|
||||
public Task<string> InvokeActorMethodAsync(string actorType, ActorId actorId, string methodName, string jsonPayload, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public Task<string> InvokeActorMethodWithoutRemotingAsync(string actorType, ActorId actorId, string methodName, string jsonPayload, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var relativeUri = $"{Constants.ActionsVersion}/{Constants.ActorRequestRelativeUrl}/{actorType}/{actorId}/method/{methodName}";
|
||||
var relativeUri = $"{Constants.ActionsVersion}/{Constants.ActorRequestRelativeUrl}/{actorType}/{actorId}/{Constants.Method}/{methodName}";
|
||||
var requestId = Guid.NewGuid().ToString();
|
||||
|
||||
HttpRequestMessage RequestFunc()
|
||||
|
|
|
|||
|
|
@ -70,14 +70,15 @@ namespace Microsoft.Actions.Actors.AspNetCore
|
|||
json = reader.ReadToEnd();
|
||||
} */
|
||||
|
||||
// If Header is present, call is made using Remoting, use Remoting dispatcher.
|
||||
if (request.Headers.ContainsKey("X-ActionsRequestHeader"))
|
||||
{
|
||||
var actionsActorheader = request.Headers["X - ActionsRequestHeader"];
|
||||
return ActorRuntime.DispatchAsync(actorTypeName, actorId, methodName, actionsActorheader, request.Body);
|
||||
return ActorRuntime.DispatchWitRemotingAsync(actorTypeName, actorId, methodName, actionsActorheader, request.Body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ActorRuntime.DispatchForXLangInvocationAsync(actorTypeName, actorId, methodName, request.Body).ContinueWith(t => response.WriteAsync(t.GetAwaiter().GetResult()));
|
||||
return ActorRuntime.DispatchWithoutRemotingAsync(actorTypeName, actorId, methodName, request.Body).ContinueWith(t => response.WriteAsync(t.GetAwaiter().GetResult()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ namespace Microsoft.Actions.Actors.Client
|
|||
public Task<string> InvokeAsync(string method, object data, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var jsonPayload = JsonConvert.SerializeObject(data);
|
||||
return actionsHttpInteractor.InvokeActorMethodAsync(this.actorType, this.actorId, method, jsonPayload, cancellationToken);
|
||||
return actionsHttpInteractor.InvokeActorMethodWithoutRemotingAsync(this.actorType, this.actorId, method, jsonPayload, cancellationToken);
|
||||
}
|
||||
|
||||
internal void Initialize(
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.Actions.Actors.Communication.Client
|
|||
var serializedHeaderJson = JsonConvert.SerializeObject(remotingRequestRequestMessage.GetHeader());
|
||||
|
||||
// Send Request
|
||||
var retval = (HttpResponseMessage)await this.actionsInteractor.InvokeActorMethod(actorId, actorType, method, serializedHeaderJson, serializedMsgBodyBuffers);
|
||||
var retval = (HttpResponseMessage)await this.actionsInteractor.InvokeActorMethodWithRemotingAsync(actorId, actorType, method, serializedHeaderJson, serializedMsgBodyBuffers);
|
||||
|
||||
// TODO finalize on pending on response message format and test
|
||||
// Need to come back once decided on response message
|
||||
|
|
|
|||
|
|
@ -51,5 +51,10 @@ namespace Microsoft.Actions.Actors
|
|||
/// Actions runtime version.
|
||||
/// </summary>
|
||||
public const string ActionsVersion = "v1.0";
|
||||
|
||||
/// <summary>
|
||||
/// String used in constructing method invocation url.
|
||||
/// </summary>
|
||||
public const string Method = "method";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.Actions.Actors
|
|||
internal interface IActionsInteractor
|
||||
{
|
||||
/// <summary>
|
||||
/// Invokes an Actor method on Actions.
|
||||
/// Invokes an Actor method on Actions without remoting.
|
||||
/// </summary>
|
||||
/// <param name="actorType">Type of actor.</param>
|
||||
/// <param name="actorId">ActorId.</param>
|
||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Actions.Actors
|
|||
/// <param name="jsonPayload">State changes.</param>
|
||||
/// <param name="cancellationToken">Cancels the operation.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
Task<string> InvokeActorMethodAsync(string actorType, ActorId actorId, string methodName, string jsonPayload, CancellationToken cancellationToken = default(CancellationToken));
|
||||
Task<string> InvokeActorMethodWithoutRemotingAsync(string actorType, ActorId actorId, string methodName, string jsonPayload, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Saves a state to Actions.
|
||||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.Actions.Actors
|
|||
Task<string> GetStateAsync(Type actorType, ActorId actorId, string keyName, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Invokes Actor method.
|
||||
/// Invokes Actor method with Remoting.
|
||||
/// </summary>
|
||||
/// <param name="actorId">ActorId.</param>
|
||||
/// <param name="actorType">Actor Type.</param>
|
||||
|
|
@ -57,6 +57,6 @@ namespace Microsoft.Actions.Actors
|
|||
/// <param name="messageBody">Message Body.</param>
|
||||
/// <param name="cancellationToken">Cancels the operation.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
||||
Task<object> InvokeActorMethod(string actorId, string actorType, string methodName, byte[] messageHeader, byte[] messageBody, CancellationToken cancellationToken = default(CancellationToken));
|
||||
Task<object> InvokeActorMethodWithRemotingAsync(string actorId, string actorType, string methodName, string messageHeader, byte[] messageBody, CancellationToken cancellationToken = default(CancellationToken));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.Actions.Actors.Runtime
|
|||
|
||||
internal ActorTypeInfo ActorTypeInfo { get; }
|
||||
|
||||
internal Task<T> DispatchAsync<T>(ActorId actorId, string actorMethodName, string actionsActorheader, Stream data, CancellationToken cancellationToken)
|
||||
internal Task<T> DispatchWithRemotingAsync<T>(ActorId actorId, string actorMethodName, string actionsActorheader, Stream data, CancellationToken cancellationToken)
|
||||
{
|
||||
var actorMethodContext = ActorMethodContext.CreateForActor(actorMethodName);
|
||||
var header = JsonConvert.DeserializeObject<ActorRequestMessageHeader>(actionsActorheader);
|
||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.Actions.Actors.Runtime
|
|||
return this.DispatchInternalAsync(actorId, actorMethodContext, RequestFunc, cancellationToken);
|
||||
}
|
||||
|
||||
internal Task<T> DispatchForXLangInvocationAsync<T>(ActorId actorId, string actorMethodName, Stream data, CancellationToken cancellationToken)
|
||||
internal Task<T> DispatchWihtoutRemotingAsync<T>(ActorId actorId, string actorMethodName, Stream data, CancellationToken cancellationToken)
|
||||
{
|
||||
var actorMethodContext = ActorMethodContext.CreateForActor(actorMethodName);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.Actions.Actors.Runtime
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the specified method for the actor when used with strongly typed invocaton from C Sharp clients.
|
||||
/// Invokes the specified method for the actor when used with Remotign from CSharp client.
|
||||
/// </summary>
|
||||
/// <param name="actorTypeName">Actor type name to invokde the method for.</param>
|
||||
/// <param name="actorId">Actor id for the actor for which method will be invoked.</param>
|
||||
|
|
@ -82,13 +82,13 @@ namespace Microsoft.Actions.Actors.Runtime
|
|||
/// <param name="data">Payload for the actor method.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
||||
internal static Task<string> DispatchAsync(string actorTypeName, string actorId, string actorMethodName, string actionsActorheader, Stream data, CancellationToken cancellationToken = default(CancellationToken))
|
||||
internal static Task<string> DispatchWitRemotingAsync(string actorTypeName, string actorId, string actorMethodName, string actionsActorheader, Stream data, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetActorManager(actorTypeName).DispatchAsync<string>(new ActorId(actorId), actorMethodName, actionsActorheader, data, cancellationToken);
|
||||
return GetActorManager(actorTypeName).DispatchWithRemotingAsync<string>(new ActorId(actorId), actorMethodName, actionsActorheader, data, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the specified method for the actor when used for cross language invocation.
|
||||
/// Invokes the specified method for the actor when used without remoting, this is mainly used for cross language invocation.
|
||||
/// </summary>
|
||||
/// <param name="actorTypeName">Actor type name to invokde the method for.</param>
|
||||
/// <param name="actorId">Actor id for the actor for which method will be invoked.</param>
|
||||
|
|
@ -96,9 +96,9 @@ namespace Microsoft.Actions.Actors.Runtime
|
|||
/// <param name="data">Payload for the actor method.</param>
|
||||
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
||||
internal static Task<string> DispatchForXLangInvocationAsync(string actorTypeName, string actorId, string actorMethodName, Stream data, CancellationToken cancellationToken = default(CancellationToken))
|
||||
internal static Task<string> DispatchWithoutRemotingAsync(string actorTypeName, string actorId, string actorMethodName, Stream data, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetActorManager(actorTypeName).DispatchForXLangInvocationAsync<string>(new ActorId(actorId), actorMethodName, data, cancellationToken);
|
||||
return GetActorManager(actorTypeName).DispatchWihtoutRemotingAsync<string>(new ActorId(actorId), actorMethodName, data, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue