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

Broadcast channel to replace SMS #7735

Merged
merged 3 commits into from
Jun 23, 2022
Merged

Conversation

benjaminpetit
Copy link
Member

@benjaminpetit benjaminpetit commented May 16, 2022

This PR introduces "Broadcast channels" that will be removed in 4.x (#7475)

The interface for consuming and publishing is more streamlined, but it should behave just like SMS

For now, only implicit subscriptions are supported, but we could add explicit later on.

Microsoft Reviewers: Open in CodeFlow

@benjaminpetit benjaminpetit added the area-streaming Category for Orleans streaming issues label May 16, 2022

namespace Orleans.BroadcastChannel
{
public interface IBroadcastChannel<T>
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should be IBroadcastChannelPublisher or Writer

_grainFactory = grainFactory;
_subscriberTable = subscriberTable;
_fireAndForgetDelivery = fireAndForgetDelivery;
_logger = loggerFactory.CreateLogger($"{nameof(BroadcastChannel<T>)}-{_channelId}");
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid unique logger names like this, since it can result in a memory leak. See #6289 and #6096


public BroadcastChannelConsumerExtension(IGrainContextAccessor grainContextAccessor)
{
_subscriptionObserver = grainContextAccessor.GrainContext?.GrainInstance as IOnBroadcastChannelSubscribed;
Copy link
Member

Choose a reason for hiding this comment

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

It seems like this is not nullable: it's accessed unconditionally further down.
In that case, perhaps a direct cast would be more appropriate.

return callback;
}
var subscription = new BroadcastChannelSubscription(this, streamId);
await _subscriptionObserver.OnSubscribed(subscription);
Copy link
Member

Choose a reason for hiding this comment

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

The reason this works (BroadcastChannelSubscription.OnSubscribed calls Attach, which adds a handler) is not obvious from looking at the code - a descriptive comment would help

{
public static class ChannelHostingExtensions
{
public static ISiloBuilder AddBroadcastChannel(this ISiloBuilder @this, string name, Action<BroadcastChannelOptions> configureOptions)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be plural, AddBroadcastChannels, like ASP.NET's AddControllers extension method: https://github.com/dotnet/aspnetcore/blob/3ea008c80d5cc63de7f90ddfd6823b7b006251ff/src/Mvc/Mvc/src/MvcServiceCollectionExtensions.cs#L89

Although there is a difference: this adds support for BroadcastChannel, whereas AddControllers adds the individual controllers (and AddMvc adds support for them)

@@ -14,6 +14,7 @@
using Xunit;
using Orleans.Hosting;
using Orleans.Serialization;
using Orleans.Providers.Streams.SimpleMessageStream;
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename this namespace?

Copy link
Member

@ReubenBond ReubenBond left a comment

Choose a reason for hiding this comment

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

LGTM with a few comments

@ReubenBond
Copy link
Member

@benjaminpetit did you want to address the comments?

@ReubenBond ReubenBond merged commit 96416cd into dotnet:main Jun 23, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-streaming Category for Orleans streaming issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants