dotnet / dotnet/aspnetcore

Allow overriding SignalR's Redis backplane channel's prefix instead of relying on hub class' name

Open
#49,457 0 comments 1 reaction 0 assignees View on GitHub
area-signalr
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I am using SignalR infrastructure with Redis backplane. Since projects are part of the same solution, the most efficient way (code-wise) is to have the specific hub's class implementation shared between the various components. The problem is that this class has to contain certain implementation or reference(s) to other components within the solution, which aren't needed or can't be shared with all hub's using parties. That leads to the necessity to copy&paste the hub class' definition on multiple projects within the solution, under the same namespace. That leads to compile-time warnings as the (hub) class defined on one project overlaps with the (hub) class on another one.

### Describe the solution you'd like

One way to deal with the problem is to modify this part:

https://github.com/dotnet/aspnetcore/blob/240377059ec25b4d9d86d4188a26722e55edc5a1/src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs#L74

Instead of always using the hub class' FullName to form the Redis prefix for the channel, to have a way to override it via options. This would allow different Hub classes (containing their specific implementation needs) to communicate without the need of class name overlapping.

### Additional context

I'll try to be more precise about my actual issue. I need to use the hub to interface a front-end application (Angular based). Some activities that are started via the front-end (through a hub class that's part of an ASP Core web application) are completed on back-end instances. Those back-end instances must have a way to notify the caller or broadcast the result of the back-end handled operation to interested parties. Therefore I need two quite different hub class implementations - one to be integrated on the web infrastructure, which only knows how to trigger an operation and another one, for the back-end components that have very different dependency requirements to be able to push notifications to the hub-connected clients. I had already achieved it by using the same hub class name and suppressed the compile time CS0436 warnings, but that seems flimsy.

Contributor guide

Open the contributing guide

Research direction

Start with src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs around line 74, where the Redis channel prefix is formed from the hub class name. Trace the related Redis options and lifetime-manager setup to determine the appropriate override point; done means distinct hub implementations can share an explicitly configured channel prefix and communicate through the Redis backplane.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.