Skip to content
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

Update Samples (Console, Netfx, Functions) #78

Merged
merged 7 commits into from
Nov 30, 2022

Conversation

jviau
Copy link
Member

@jviau jviau commented Nov 10, 2022

Updates the ConsoleApp and NetFxConsoleApp samples to the latest way of using the packages.

{
tasks.AddOrchestrator("HelloSequence", async context =>
services.AddDurableTaskClient(builder =>
Copy link
Member Author

@jviau jviau Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, client and worker must be registered independently. I am not against worker also bringing in the client, but I'd like to gather feedback on that before committing time to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the common case would be registering both, and that registering one or the other would be the advanced case. Could we simply have an AddDurableTask extension method that registers both? Or is that complicated because we've put them in two separate packages with no top-level package to give developers everything?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the common case will probably be registering both for worker scenarios only. I think it will also be common to want to register only the client (e.g., Web API with client, but worker is in a separate console app). I think in the future we should explore AddDurableTaskWorker also registering the corresponding client, but yes, the package separation complicates it. I am open to adding a Worker --> Client package reference, but it will require some design around integrating the calls together. I think this can be left to post-GA.

await context.CallActivityAsync<string>("SayHello", "Seattle"),
};
builder.UseGrpc();
builder.RegisterDirectly();
Copy link
Member Author

@jviau jviau Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line registers the DurableTaskClient directly to the service collection. I am wondering if we should register the "Default" (no name provided) client to the service container?

You can always import IDurableTaskClientProvider and get a client by name,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid I don't understand the type architecture well enough to understand the question. I also worry customers might struggle to understand like I am. The call to host.Services.GetRequiredService<DurableTaskClient>() makes me a tiny bit uneasy since it's not particularly discoverable, but I think it's okay. I do worry about this builder.RegisterDirectly() requirement though. I would never think to call that. Could be make this the default configuration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#81 partially addresses this - removing the need for RegisterDirectly in this case. I will update this PR to reflect that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to remove this now?

@jviau jviau requested a review from cgillum November 10, 2022 22:28
@@ -7,9 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.DurableTask.Client" Version="0.4.1-beta" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so this is why your PRs haven't needed to update the samples until now. :) I wonder if we can still keep these package references in as comments, maybe with placeholder version values. My intention was to make it as easy as possible for users to copy/paste the samples and have them work in their own projects, which won't have access to the project references.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - I will introduce the commented-out package references when we release the next NuGet package

// You can configure custom data converter multiple ways. One is through worker/client options configuration.
// Alternatively, data converter will be used from the service provider if available (as a singleton) AND no
// converter was explicitly set on the options.
services.AddSingleton<DataConverter>(JsonDataConverter.Default);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how you added these optional configuration calls and described them with the comments. 👍🏽

samples/ConsoleApp/Program.cs Show resolved Hide resolved
await context.CallActivityAsync<string>("SayHello", "Seattle"),
};
builder.UseGrpc();
builder.RegisterDirectly();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid I don't understand the type architecture well enough to understand the question. I also worry customers might struggle to understand like I am. The call to host.Services.GetRequiredService<DurableTaskClient>() makes me a tiny bit uneasy since it's not particularly discoverable, but I think it's okay. I do worry about this builder.RegisterDirectly() requirement though. I would never think to call that. Could be make this the default configuration?

{
tasks.AddOrchestrator("HelloSequence", async context =>
services.AddDurableTaskClient(builder =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the common case would be registering both, and that registering one or the other would be the advanced case. Could we simply have an AddDurableTask extension method that registers both? Or is that complicated because we've put them in two separate packages with no top-level package to give developers everything?

@jviau jviau requested a review from cgillum November 11, 2022 19:43
@jviau jviau changed the title Update ConsoleApp and NetfxConsoleApp samples Update Samples (Console, Netfx, Functions) Nov 29, 2022
@jviau jviau merged commit 98728ff into microsoft:main Nov 30, 2022
@jviau jviau deleted the update-samples branch November 30, 2022 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants