Skip to content

Commit

Permalink
use constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Turowicz committed Nov 14, 2023
1 parent 258515a commit 069f1a2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ In production you should register the provider using the extension method for `I

```c#
siloBuilder.AddMemoryGrainStorageAsDefault()
.AddMemoryGrainStorage(name: "PubSubStore")
.AddGrainsStreams(name: "Default",
.AddMemoryGrainStorage(ProviderConstants.DEFAULT_PUBSUB_PROVIDER_NAME)
.AddGrainsStreams(name: ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME,
queueCount: 1,
retry: TimeSpan.FromMinutes(1),
poison: TimeSpan.FromMinutes(3));
Expand All @@ -26,8 +26,8 @@ In test you should register the provider using the extension method for `ISiloBu
```c#
siloBuilder.ConfigureServices(Configure)
.AddMemoryGrainStorageAsDefault()
.AddMemoryGrainStorage(name: "PubSubStore")
.AddGrainsStreamsForTests(name: "Default",
.AddMemoryGrainStorage(ProviderConstants.DEFAULT_PUBSUB_PROVIDER_NAME)
.AddGrainsStreamsForTests(name: ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME,
queueCount: 3,
retry: TimeSpan.FromSeconds(1),
poison: TimeSpan.FromSeconds(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Orleans.Hosting;
using Orleans.Providers;
using Orleans.Streaming.Grains.Extensions;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.TestingHost;
Expand All @@ -20,8 +21,8 @@ public void Configure(ISiloBuilder siloBuilder)
{
siloBuilder.ConfigureServices(Configure)
.AddMemoryGrainStorageAsDefault()
.AddMemoryGrainStorage(name: "PubSubStore")
.AddMemoryStreams("Default");
.AddMemoryGrainStorage(ProviderConstants.DEFAULT_PUBSUB_PROVIDER_NAME)
.AddMemoryStreams(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
}

public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Orleans.Hosting;
using Orleans.Providers;
using Orleans.Streaming.Grains.Extensions;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.TestingHost;
Expand All @@ -21,8 +22,8 @@ public void Configure(ISiloBuilder siloBuilder)
#pragma warning disable CS0618
siloBuilder.ConfigureServices(Configure)
.AddMemoryGrainStorageAsDefault()
.AddMemoryGrainStorage(name: "PubSubStore")
.AddGrainsStreams(name: "Default",
.AddMemoryGrainStorage(ProviderConstants.DEFAULT_PUBSUB_PROVIDER_NAME)
.AddGrainsStreams(name: ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME,
queueCount: 8,
retry: TimeSpan.FromSeconds(1),
poison: TimeSpan.FromSeconds(3));
Expand Down
9 changes: 5 additions & 4 deletions src/Orleans.Streaming.Grains.Tests/BaseGrainTestConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using Orleans.Hosting;
using Orleans.Providers;
using Orleans.Providers.Streams.Common;
using Orleans.Streaming.Grains.Abstract;
using Orleans.Streaming.Grains.Extensions;
Expand Down Expand Up @@ -41,8 +42,8 @@ public void Configure(ISiloBuilder siloBuilder)
siloBuilder.ConfigureServices(Configure)
.ConfigureServices(ConfigureInner)
.AddMemoryGrainStorageAsDefault()
.AddMemoryGrainStorage(name: "PubSubStore")
.AddGrainsStreams(name: "Default",
.AddMemoryGrainStorage(ProviderConstants.DEFAULT_PUBSUB_PROVIDER_NAME)
.AddGrainsStreams(name: ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME,
queueCount: 1,
retry: TimeSpan.FromSeconds(1),
poison: TimeSpan.FromSeconds(3));
Expand All @@ -53,8 +54,8 @@ public void Configure(ISiloBuilder siloBuilder)
siloBuilder.ConfigureServices(Configure)
.ConfigureServices(ConfigureInner)
.AddMemoryGrainStorageAsDefault()
.AddMemoryGrainStorage(name: "PubSubStore")
.AddGrainsStreamsForTests(name: "Default",
.AddMemoryGrainStorage(ProviderConstants.DEFAULT_PUBSUB_PROVIDER_NAME)
.AddGrainsStreamsForTests(name: ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME,
queueCount: 3,
retry: TimeSpan.FromSeconds(1),
poison: TimeSpan.FromSeconds(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) Surveily Sp. z o.o.. All rights reserved.
// </copyright>

using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.Streams;
Expand All @@ -24,7 +25,7 @@ public BlobReceiverGrain(IProcessor processor)

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
var stream = StreamFactory.Create<BlobMessage>(streamProvider, this.GetPrimaryKey());
var broadcastStream = StreamFactory.Create<BroadcastMessage>(streamProvider, this.GetPrimaryKey());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Threading.Tasks;
using Orleans.Concurrency;
using Orleans.Providers;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.Streams;

Expand All @@ -21,7 +22,7 @@ public class CompoundReceiverGrain : Grain, ICompoundReceiverGrain

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
var stream = StreamFactory.Create<CompoundMessage>(streamProvider, this.GetPrimaryKey());

_subscription = await stream.SubscribeAsync(OnNextAsync);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// </copyright>

using Orleans.Concurrency;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.Streams;
Expand All @@ -20,7 +21,7 @@ public class EmitterGrain : Grain, IEmitterGrain
public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var id = this.GetPrimaryKey();
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);

_blobStream = StreamFactory.Create<BlobMessage>(streamProvider, id);
_simpleStream = StreamFactory.Create<SimpleMessage>(streamProvider, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Threading.Tasks;
using Orleans.Concurrency;
using Orleans.Providers;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.Streams;

Expand All @@ -20,7 +21,7 @@ public class ExplosiveReceiverGrain : Grain, IExplosiveReceiverGrain

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
var stream = StreamFactory.Create<ExplosiveMessage>(streamProvider, this.GetPrimaryKey());

_subscription = await stream.SubscribeAsync(OnNextAsync);
Expand All @@ -46,7 +47,7 @@ public class ExplosiveSecondReceiverGrain : Grain, IExplosiveReceiverGrain

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
var stream = StreamFactory.Create<ExplosiveMessage>(streamProvider, this.GetPrimaryKey());

_subscription = await stream.SubscribeAsync(OnNextAsync);
Expand All @@ -68,7 +69,7 @@ public class ExplosiveNextFirstReceiverGrain : Grain, IExplosiveReceiverGrain

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);

_compoundStreams = new List<IAsyncStream<CompoundMessage>>();

Expand Down Expand Up @@ -109,7 +110,7 @@ public class ExplosiveNextSecondReceiverGrain : Grain, IExplosiveReceiverGrain

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);

_compoundStreams = new List<IAsyncStream<CompoundMessage>>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) Surveily Sp. z o.o.. All rights reserved.
// </copyright>

using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Streaming.Grains.Tests.Streams.Messages;
using Orleans.Streams;
Expand All @@ -24,7 +25,7 @@ public SimpleReceiverGrain(IProcessor processor)

public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
var streamProvider = this.GetStreamProvider("Default");
var streamProvider = this.GetStreamProvider(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
var stream = StreamFactory.Create<SimpleMessage>(streamProvider, this.GetPrimaryKey());
var broadcastStream = StreamFactory.Create<BroadcastMessage>(streamProvider, this.GetPrimaryKey());

Expand Down

0 comments on commit 069f1a2

Please sign in to comment.