Migrate actors to use grpc#954
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #954 +/- ##
==========================================
- Coverage 70.17% 67.11% -3.06%
==========================================
Files 160 161 +1
Lines 5284 5526 +242
Branches 567 592 +25
==========================================
+ Hits 3708 3709 +1
- Misses 1442 1679 +237
- Partials 134 138 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
Signed-off-by: addjuarez <addiajuarez@gmail.com>
* feat: add metadata api Signed-off-by: saberwang <saberwang@hotmail.com> * Using HTTP API to get and set dapr metadata Signed-off-by: saberwang <saberwang@hotmail.com> * style Signed-off-by: saberwang <saberwang@hotmail.com> * using grpc to add metadata api Signed-off-by: saberwang <saberwang@hotmail.com> * style Signed-off-by: saberwang <saberwang@hotmail.com> Co-authored-by: halspang <70976921+halspang@users.noreply.github.com> Signed-off-by: addjuarez <addiajuarez@gmail.com>
475a087 to
593786f
Compare
| /// <summary> | ||
| /// Option to use GRPC or HTTP | ||
| /// </summary> | ||
| public bool useGrpc { get; set; } = true; |
There was a problem hiding this comment.
Nit: Missing whitespace at the top and public members are capitalized. useGrpc -> UseGrpc.
| .UseGrpcEndpoint(options.GrpcEndpoint) | ||
| .UseDaprApiToken(options.DaprApiToken) | ||
| .UseGrpcChannelOptions(options.GrpcChannelOptions) | ||
| .Build(); |
There was a problem hiding this comment.
Nit: These should be indented.
| .UseGrpcEndpoint(options.GrpcEndpoint) | ||
| .UseDaprApiToken(options.DaprApiToken) | ||
| .UseGrpcChannelOptions(options.GrpcChannelOptions) | ||
| .Build(); |
| public Task SaveStateTransactionallyAsync(string actorType, string actorId, string data, CancellationToken cancellationToken = default) | ||
| { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Why did we decide to do this and create a new method instead of just using the gRPC client here?
| return stringResponse; | ||
| } | ||
|
|
||
| public Task SaveStateTransactionallyAsyncGrpc(string actorType, string actorId, List<Autogenerated.TransactionalActorStateOperation> data, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
As commented above, I don't think we need to distinguish this.
| daprInteractor = new DaprInteractorBuilder() | ||
| .UseGrpcEndpoint(options.GrpcEndpoint) | ||
| .UseDaprApiToken(options.DaprApiToken) | ||
| .UseGrpcChannelOptions(options.GrpcChannelOptions) | ||
| .Build(); |
There was a problem hiding this comment.
Needs an indent but I also feel it shouldn't use a builder.
If you do want to use a builder, I think it should take in the options.UseGrpc field and return the appropriate interactor. The benefit of that being an interface is that we don't need to know the actual implementation.
| /// <summary> | ||
| /// Option to use GRPC or HTTP | ||
| /// </summary> | ||
| public bool useGrpc { get; set; } = true; |
| if (this.daprInteractor.GetType().Name.Equals("DaprGrpcInteractor")){ | ||
| await this.DoStateChangesTransactionallyAsyncGrpc(actorType, actorId, stateChanges, cancellationToken); | ||
| } else { | ||
| await this.DoStateChangesTransactionallyAsyncHttp(actorType, actorId, stateChanges, cancellationToken); | ||
| } |
There was a problem hiding this comment.
The interface of the interactor makes this unnecessary. Whatever the underlying object is, we'll use its method. So no need to separate them like this.
| /// <summary> | ||
| /// Represents the details of the timer set on an Actor. | ||
| /// </summary> | ||
| [Obsolete("This class is an implementation detail of the framework and will be made internal in a future release.")] |
There was a problem hiding this comment.
Did we make this internal? I don't think we did. And if we did, that's a breaking change so we shouldn't just do it. Any reason why you removed this?
| } | ||
| } | ||
|
|
||
| private async Task DoStateChangesTransactionallyAsyncGrpc(string actorType, string actorId, IReadOnlyCollection<ActorStateChange> stateChanges, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
Same comments, we can remove this.
Signed-off-by: addjuarez <addiajuarez@gmail.com>
halspang
left a comment
There was a problem hiding this comment.
How hard would it be to replicate any tests that the DaprHttpInteractor has for the DaprGrpcInteractor?
It would also be good to make a base e2e test for the actors to ensure this works correctly.
| } | ||
|
|
||
| private async Task DoStateChangesTransactionallyAsync(string actorType, string actorId, IReadOnlyCollection<ActorStateChange> stateChanges, CancellationToken cancellationToken = default) | ||
| public async Task DoStateChangesTransactionallyAsyncGrpc(string actorType, string actorId, IReadOnlyCollection<ActorStateChange> stateChanges, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
Do we still need the Grpc and Http methods here? I thought with the interactors we wouldn't need these anymore.
There was a problem hiding this comment.
For this method we do. The interface wants a ActorStateChange objects but grpc requires a proto object here.
| /// <summary> | ||
| /// Option to use GRPC or HTTP | ||
| /// </summary> | ||
| public bool UseGrpc { get; set; } = true; |
There was a problem hiding this comment.
This should default to false otherwise we'll change everyone's actor functionality without them opting into it.
| /// <summary> | ||
| /// Option to use GRPC or HTTP | ||
| /// </summary> | ||
| public bool UseGrpc { get; set; } = true; |
There was a problem hiding this comment.
Same here, this should be false.
| { | ||
| UseGrpc = false, | ||
| HttpEndpoint = this.HttpEndpoint, | ||
| GrpcEndpoint = this.GrpcEndpoint |
There was a problem hiding this comment.
Do we need both endpoints?
Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com>
I can make e2e tests for the grpcInteractor but the unit tests for grpc are a bit more complex. |
Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com>
Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com>
Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com>
Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com>
Signed-off-by: addjuarez <6789375+addjuarez@users.noreply.github.com>
| } | ||
|
|
||
| public Task SaveStateTransactionallyAsync(string actorType, string actorId, string data, CancellationToken cancellationToken = default) | ||
| public Task SaveStateTransactionallyAsync(string actorType, string actorId, string data, CancellationToken cancellationToken = default, List<Autogenerated.TransactionalActorStateOperation> grpcData = default) |
There was a problem hiding this comment.
Yes the grpcInteractor uses this for its data. It doesnt use the string argument
| public Task DoStateChangesTransactionallyAsync(DaprStateProvider provider, string actorType, string actorId, IReadOnlyCollection<ActorStateChange> stateChanges, CancellationToken cancellationToken = default) | ||
| { | ||
| return provider.DoStateChangesTransactionallyAsyncHttp(actorType, actorId, stateChanges, cancellationToken); |
There was a problem hiding this comment.
I thought we wouldn't need to split them up between http and gRPC anymore.
| } | ||
|
|
||
| private async Task DoStateChangesTransactionallyAsync(string actorType, string actorId, IReadOnlyCollection<ActorStateChange> stateChanges, CancellationToken cancellationToken = default) | ||
| public async Task DoStateChangesTransactionallyAsyncGrpc(string actorType, string actorId, IReadOnlyCollection<ActorStateChange> stateChanges, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
Moving this logic into the daprGrpcInteractor would remove the need to distinguish between http/grpc right?
|
I'm going to go ahead and close this issue for now in light of the new proposal at the runtime for formally adding (bidirectional streaming)[https://github.com/dapr/proposals/pull/72] and PubSub support on a new gRPC actor implementation. |
Signed-off-by: addjuarez addiajuarez@gmail.com
Description
Migrate .net actor implementation to use grpc by default.
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #486
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: