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

Distinguish Orleans hosts & clients, parameterize CluserId/ServiceId, improve playground app #3433

Merged
merged 3 commits into from
Apr 9, 2024

Conversation

ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Apr 5, 2024

Fixes #3399

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-integrations Issues pertaining to Aspire Integrations packages label Apr 5, 2024
{
Name = name;
Builder = builder;
ServiceId = ParameterResourceBuilderExtensions.CreateGeneratedParameter(builder, $"{name}-service-id", secret: false, new GenerateParameterDefault
Copy link
Member

Choose a reason for hiding this comment

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

@eerhardt this API is kinda crazy 😄

Copy link
Member

Choose a reason for hiding this comment

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

Suggestions on making it better?

@ReubenBond ReubenBond requested a review from eerhardt April 8, 2024 23:13
@ReubenBond
Copy link
Member Author

@mitchdenny @davidfowl @eerhardt PTAL


/// <summary>
/// Gets or sets the service identifier.
/// </summary>
public string? ServiceId { get; set; }
internal object ServiceId { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Why object?

Suggested change
internal object ServiceId { get; set; }
internal ParameterResource ServiceId { get; set; }

Copy link
Member Author

Choose a reason for hiding this comment

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

It's either a parameter or a hard-coded string value.. I made it internal so at least this detail doesn't leak.

See WithServiceId and WithClusterId

Copy link
Member

Choose a reason for hiding this comment

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

It's either a parameter or a hard-coded string value.

Might be good sticking that comment in here.

/// <param name="isProxied">Specifies if the endpoint will be proxied by DCP. Defaults to true.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
/// <exception cref="DistributedApplicationException">Throws an exception if an endpoint with the same name already exists on the specified resource.</exception>
public static IResourceBuilder<T> WithEndpoint<T>(this IResourceBuilder<T> builder, int? port = null, int? targetPort = null, string? scheme = null, string? name = null, string? env = null, bool isProxied = true) where T : IResource
public static IResourceBuilder<T> WithEndpoint<T>(this IResourceBuilder<T> builder, int? port = null, int? targetPort = null, string? scheme = null, string? name = null, string? env = null, bool isProxied = true, bool? isExternal = null) where T : IResource
Copy link
Member

Choose a reason for hiding this comment

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

Just remember we can't make changes like this after we ship stable.

It might make sense to get API compat turned on after 8.0 ships.

/// <param name="orleansServiceClient">The Orleans service client, containing clustering, etc.</param>
/// <returns>The resource builder.</returns>
/// <exception cref="InvalidOperationException">Clustering has not been configured.</exception>
public static IResourceBuilder<T> WithReference<T>(
Copy link
Member

Choose a reason for hiding this comment

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

When would I use WithReference(OrleansServiceClient) over using WithReference(OrleansService)?

Is it confusing to have both? What's the difference between:

builder.AddProject<Projects.OrleansServer>("silo")
       .WithReference(orleans);

and

builder.AddProject<Projects.OrleansClient>("frontend")
       .WithReference(orleans.AsClient());

?

Copy link
Member Author

Choose a reason for hiding this comment

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

You use the service one for projects with an Orleans server and the client one with the Orleans clients. Their configuration follows the same format, but servers have more (storage, etc)

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

I just had one last question. The rest LGTM

Comment on lines +413 to +416
// NOTE: These endpoints are specified as proxied even though we never expect any connections via the proxy, and that would be invalid anyway.
// this is a workaround for current Aspire/DCP behavior.
builder.WithEndpoint(scheme: "tcp", name: "orleans-silo", env: "Orleans__Endpoints__SiloPort", isProxied: true, isExternal: false);
builder.WithEndpoint(scheme: "tcp", name: "orleans-gateway", env: "Orleans__Endpoints__GatewayPort", isProxied: true, isExternal: false);
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 a bit confused by this comment.

  1. Isn't "isProxied" defaulted to true?
  2. What exactly is this working around?

Copy link
Member Author

Choose a reason for hiding this comment

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

IsProxied is defaulted to true. In this case, we don't actually want a proxy, but we need to make sure IsProxied is set to true, because otherwise DCP will barf. It's a limitation. The proxy ends up being unused by the app (they connect directly to each other), so it's benign but worth mentioning in a comment and being explicit about the current behavior.

@ReubenBond ReubenBond merged commit 20b7ccf into main Apr 9, 2024
8 checks passed
@ReubenBond ReubenBond deleted the rebond/orleans-parameters branch April 9, 2024 02:05
@ReubenBond
Copy link
Member Author

/azp backport to release/8.0

@davidfowl
Copy link
Member

/backport to release/8.0

Copy link
Contributor

github-actions bot commented Apr 9, 2024

Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8610492653

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OrleansService generates a new GUID each time.
3 participants