forked from OrleansContrib/SignalR.Orleans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generic host): implement UseSignalR for generic host (OrleansCon…
- Loading branch information
1 parent
f72aa6a
commit 7a5ef22
Showing
5 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using SignalR.Orleans; | ||
using SignalR.Orleans.Clients; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Orleans.Hosting | ||
{ | ||
public static class SiloBuilderExtensions | ||
{ | ||
public static ISiloBuilder UseSignalR(this ISiloBuilder builder, Action<SignalrOrleansSiloConfigBuilder> configure = null) | ||
{ | ||
var cfg = new SignalrOrleansSiloConfigBuilder(); | ||
configure?.Invoke(cfg); | ||
|
||
cfg.ConfigureBuilder?.Invoke(builder, new HostBuilderConfig()); | ||
|
||
try | ||
{ | ||
builder.AddMemoryGrainStorage(Constants.PUBSUB_PROVIDER); | ||
} | ||
catch | ||
{ | ||
/** PubSubStore was already added. Do nothing. **/ | ||
} | ||
|
||
try | ||
{ | ||
builder.AddMemoryGrainStorage(Constants.STORAGE_PROVIDER); | ||
} | ||
catch | ||
{ | ||
/** Grain storage provider was already added. Do nothing. **/ | ||
} | ||
|
||
return builder | ||
.AddSimpleMessageStreamProvider(Constants.STREAM_PROVIDER, opt => opt.FireAndForgetDelivery = cfg.UseFireAndForgetDelivery) | ||
.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(ClientGrain).Assembly).WithReferences()); | ||
} | ||
} | ||
|
||
public static class SiloHostBuilderExtensions | ||
{ | ||
public static ISiloHostBuilder UseSignalR(this ISiloHostBuilder builder, Action<SignalrOrleansSiloHostConfigBuilder> configure = null) | ||
{ | ||
var cfg = new SignalrOrleansSiloHostConfigBuilder(); | ||
configure?.Invoke(cfg); | ||
|
||
cfg.ConfigureBuilder?.Invoke(builder, new HostBuilderConfig()); | ||
|
||
try | ||
{ | ||
builder.AddMemoryGrainStorage(Constants.PUBSUB_PROVIDER); | ||
} | ||
catch | ||
{ | ||
/** PubSubStore was already added. Do nothing. **/ | ||
} | ||
|
||
try | ||
{ | ||
builder.AddMemoryGrainStorage(Constants.STORAGE_PROVIDER); | ||
} | ||
catch | ||
{ | ||
/** Grain storage provider was already added. Do nothing. **/ | ||
} | ||
|
||
return builder | ||
.AddSimpleMessageStreamProvider(Constants.STREAM_PROVIDER, opt => opt.FireAndForgetDelivery = cfg.UseFireAndForgetDelivery) | ||
.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(ClientGrain).Assembly).WithReferences()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters