mirror of https://github.com/dapr/dotnet-sdk.git
rename InvokeAsync to InvokeMethodAsync (#529)
This commit is contained in:
parent
9fd1900e59
commit
c650955f75
|
|
@ -416,14 +416,14 @@ namespace MyActorClient
|
||||||
// Create Actor Proxy instance to invoke the methods defined in the interface
|
// Create Actor Proxy instance to invoke the methods defined in the interface
|
||||||
var proxy = ActorProxy.Create(actorID, actorType);
|
var proxy = ActorProxy.Create(actorID, actorType);
|
||||||
// Need to specify the method name and response type explicitly
|
// Need to specify the method name and response type explicitly
|
||||||
var response = await proxy.InvokeAsync<MyData, string>("SetDataAsync", new MyData()
|
var response = await proxy.InvokeMethodAsync<MyData, string>("SetDataAsync", new MyData()
|
||||||
{
|
{
|
||||||
PropertyA = "ValueA",
|
PropertyA = "ValueA",
|
||||||
PropertyB = "ValueB",
|
PropertyB = "ValueB",
|
||||||
});
|
});
|
||||||
Console.WriteLine(response);
|
Console.WriteLine(response);
|
||||||
|
|
||||||
var savedData = await proxy.InvokeAsync<MyData>("GetDataAsync");
|
var savedData = await proxy.InvokeMethodAsync<MyData>("GetDataAsync");
|
||||||
Console.WriteLine(savedData);
|
Console.WriteLine(savedData);
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,12 @@ namespace ActorClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Making calls without Remoting, this shows method invocation using InvokeAsync methods, the method name and its payload is provided as arguments to InvokeAsync methods.
|
// Making calls without Remoting, this shows method invocation using InvokeMethodAsync methods, the method name and its payload is provided as arguments to InvokeMethodAsync methods.
|
||||||
Console.WriteLine("Making calls without Remoting.");
|
Console.WriteLine("Making calls without Remoting.");
|
||||||
var nonRemotingProxy = ActorProxy.Create(actorId, "DemoActor");
|
var nonRemotingProxy = ActorProxy.Create(actorId, "DemoActor");
|
||||||
await nonRemotingProxy.InvokeAsync("TestNoArgumentNoReturnType");
|
await nonRemotingProxy.InvokeMethodAsync("TestNoArgumentNoReturnType");
|
||||||
await nonRemotingProxy.InvokeAsync("SaveData", data);
|
await nonRemotingProxy.InvokeMethodAsync("SaveData", data);
|
||||||
var res = await nonRemotingProxy.InvokeAsync<MyData>("GetData");
|
var res = await nonRemotingProxy.InvokeMethodAsync<MyData>("GetData");
|
||||||
|
|
||||||
Console.WriteLine("Registering the timer and reminder");
|
Console.WriteLine("Registering the timer and reminder");
|
||||||
await proxy.RegisterTimer();
|
await proxy.RegisterTimer();
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Dapr.Actors.Builder
|
||||||
|
|
||||||
// TODO Should this search change to BindingFlags.NonPublic
|
// TODO Should this search change to BindingFlags.NonPublic
|
||||||
this.invokeAsyncMethodInfo = this.proxyBaseType.GetMethod(
|
this.invokeAsyncMethodInfo = this.proxyBaseType.GetMethod(
|
||||||
"InvokeAsync",
|
"InvokeMethodAsync",
|
||||||
BindingFlags.Instance | BindingFlags.NonPublic,
|
BindingFlags.Instance | BindingFlags.NonPublic,
|
||||||
null,
|
null,
|
||||||
CallingConventions.Any,
|
CallingConventions.Any,
|
||||||
|
|
@ -319,7 +319,7 @@ namespace Dapr.Actors.Builder
|
||||||
|
|
||||||
var objectTask = ilGen.DeclareLocal(typeof(Task<IActorResponseMessageBody>));
|
var objectTask = ilGen.DeclareLocal(typeof(Task<IActorResponseMessageBody>));
|
||||||
|
|
||||||
// call the base InvokeAsync method
|
// call the base InvokeMethodAsync method
|
||||||
ilGen.Emit(OpCodes.Ldarg_0); // base
|
ilGen.Emit(OpCodes.Ldarg_0); // base
|
||||||
ilGen.Emit(OpCodes.Ldc_I4, interfaceId); // interfaceId
|
ilGen.Emit(OpCodes.Ldc_I4, interfaceId); // interfaceId
|
||||||
ilGen.Emit(OpCodes.Ldc_I4, methodDescription.Id); // methodId
|
ilGen.Emit(OpCodes.Ldc_I4, methodDescription.Id); // methodId
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Dapr.Actors.Client
|
||||||
/// <param name="data">Object argument for actor method.</param>
|
/// <param name="data">Object argument for actor method.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token.</param>
|
/// <param name="cancellationToken">Cancellation Token.</param>
|
||||||
/// <returns>Response form server.</returns>
|
/// <returns>Response form server.</returns>
|
||||||
public async Task<TResponse> InvokeAsync<TRequest, TResponse>(string method, TRequest data, CancellationToken cancellationToken = default)
|
public async Task<TResponse> InvokeMethodAsync<TRequest, TResponse>(string method, TRequest data, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using var stream = new MemoryStream();
|
using var stream = new MemoryStream();
|
||||||
await JsonSerializer.SerializeAsync<TRequest>(stream, data);
|
await JsonSerializer.SerializeAsync<TRequest>(stream, data);
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Dapr.Actors.Client
|
||||||
/// <param name="data">Object argument for actor method.</param>
|
/// <param name="data">Object argument for actor method.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token.</param>
|
/// <param name="cancellationToken">Cancellation Token.</param>
|
||||||
/// <returns>Response form server.</returns>
|
/// <returns>Response form server.</returns>
|
||||||
public async Task InvokeAsync<TRequest>(string method, TRequest data, CancellationToken cancellationToken = default)
|
public async Task InvokeMethodAsync<TRequest>(string method, TRequest data, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using var stream = new MemoryStream();
|
using var stream = new MemoryStream();
|
||||||
await JsonSerializer.SerializeAsync<TRequest>(stream, data);
|
await JsonSerializer.SerializeAsync<TRequest>(stream, data);
|
||||||
|
|
@ -133,7 +133,7 @@ namespace Dapr.Actors.Client
|
||||||
/// <param name="method">Actor method name.</param>
|
/// <param name="method">Actor method name.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token.</param>
|
/// <param name="cancellationToken">Cancellation Token.</param>
|
||||||
/// <returns>Response form server.</returns>
|
/// <returns>Response form server.</returns>
|
||||||
public async Task<TResponse> InvokeAsync<TResponse>(string method, CancellationToken cancellationToken = default)
|
public async Task<TResponse> InvokeMethodAsync<TResponse>(string method, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var response = await this.actorNonRemotingClient.InvokeActorMethodWithoutRemotingAsync(this.ActorType, this.ActorId.ToString(), method, null, cancellationToken);
|
var response = await this.actorNonRemotingClient.InvokeActorMethodWithoutRemotingAsync(this.ActorType, this.ActorId.ToString(), method, null, cancellationToken);
|
||||||
return await JsonSerializer.DeserializeAsync<TResponse>(response);
|
return await JsonSerializer.DeserializeAsync<TResponse>(response);
|
||||||
|
|
@ -145,7 +145,7 @@ namespace Dapr.Actors.Client
|
||||||
/// <param name="method">Actor method name.</param>
|
/// <param name="method">Actor method name.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token.</param>
|
/// <param name="cancellationToken">Cancellation Token.</param>
|
||||||
/// <returns>Response form server.</returns>
|
/// <returns>Response form server.</returns>
|
||||||
public Task InvokeAsync(string method, CancellationToken cancellationToken = default)
|
public Task InvokeMethodAsync(string method, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return this.actorNonRemotingClient.InvokeActorMethodWithoutRemotingAsync(this.ActorType, this.ActorId.ToString(), method, null, cancellationToken);
|
return this.actorNonRemotingClient.InvokeActorMethodWithoutRemotingAsync(this.ActorType, this.ActorId.ToString(), method, null, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
@ -186,7 +186,7 @@ namespace Dapr.Actors.Client
|
||||||
/// <param name="requestMsgBodyValue">Request Message Body Value.</param>
|
/// <param name="requestMsgBodyValue">Request Message Body Value.</param>
|
||||||
/// <param name="cancellationToken">Cancellation Token.</param>
|
/// <param name="cancellationToken">Cancellation Token.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
|
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
|
||||||
protected async Task<IActorResponseMessageBody> InvokeAsync(
|
protected async Task<IActorResponseMessageBody> InvokeMethodAsync(
|
||||||
int interfaceId,
|
int interfaceId,
|
||||||
int methodId,
|
int methodId,
|
||||||
string methodName,
|
string methodName,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue