-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate actors to use grpc #954
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ 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.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
* feat: add metadata api Signed-off-by: saberwang <[email protected]> * Using HTTP API to get and set dapr metadata Signed-off-by: saberwang <[email protected]> * style Signed-off-by: saberwang <[email protected]> * using grpc to add metadata api Signed-off-by: saberwang <[email protected]> * style Signed-off-by: saberwang <[email protected]> Co-authored-by: halspang <[email protected]> Signed-off-by: addjuarez <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: These should be indented.
.UseGrpcEndpoint(options.GrpcEndpoint) | ||
.UseDaprApiToken(options.DaprApiToken) | ||
.UseGrpcChannelOptions(options.GrpcChannelOptions) | ||
.Build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
public Task SaveStateTransactionallyAsync(string actorType, string actorId, string data, CancellationToken cancellationToken = default) | ||
{ | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we decide to do this and create a new method instead of just using the gRPC client here?
@@ -75,6 +76,11 @@ HttpRequestMessage RequestFunc() | |||
return stringResponse; | |||
} | |||
|
|||
public Task SaveStateTransactionallyAsyncGrpc(string actorType, string actorId, List<Autogenerated.TransactionalActorStateOperation> data, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useGrpc
-> UseGrpc
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/Dapr.Actors/Runtime/TimerInfo.cs
Outdated
@@ -24,7 +24,6 @@ namespace Dapr.Actors.Runtime | |||
/// <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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments, we can remove this.
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this should be false.
{ | ||
UseGrpc = false, | ||
HttpEndpoint = this.HttpEndpoint, | ||
GrpcEndpoint = this.GrpcEndpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need both endpoints?
Signed-off-by: addjuarez <[email protected]>
I can make e2e tests for the grpcInteractor but the unit tests for grpc are a bit more complex. |
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
@@ -75,7 +77,7 @@ HttpRequestMessage RequestFunc() | |||
return stringResponse; | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is grpcData
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this logic into the daprGrpcInteractor
would remove the need to distinguish between http/grpc right?
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez <[email protected]>
Signed-off-by: addjuarez [email protected]
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: