Skip to content

Commit

Permalink
Upgrade 'Streaming' samples (#8134)
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist authored Nov 17, 2022
1 parent e1481f7 commit cbe80ae
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 52 deletions.
2 changes: 1 addition & 1 deletion samples/Streaming/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="System.Text.Json" Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Orleans;

namespace GrainInterfaces;

public interface IConsumerGrain : IGrainWithGuidKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Common;
using GrainInterfaces;
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.Streams;
using Orleans.Streams.Core;

Expand Down
6 changes: 3 additions & 3 deletions samples/Streaming/CustomDataAdapter/Grains/Grains.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.6.2" />
<PackageReference Include="System.Text.Json" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.7.4" />
<PackageReference Include="System.Text.Json" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Text.Json;
using Azure.Messaging.EventHubs;
using Newtonsoft.Json.Serialization;
using Orleans.Runtime;
using Orleans.Serialization;
using Orleans.ServiceBus.Providers;
using Orleans.Streaming.EventHubs;
using Orleans.Streams;

namespace Silo;
Expand Down
1 change: 0 additions & 1 deletion samples/Streaming/CustomDataAdapter/Silo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Orleans.Hosting;

using Silo;

Expand Down
8 changes: 4 additions & 4 deletions samples/Streaming/CustomDataAdapter/Silo/Silo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="Microsoft.Orleans.Server" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Server" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs " Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions samples/Streaming/Simple/Client/Client.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="Microsoft.Orleans.Client" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Client" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs " Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions samples/Streaming/Simple/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using GrainInterfaces;
using Orleans;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using Orleans.Streams;
using Orleans.Hosting;
using Common;
using Microsoft.Extensions.DependencyInjection;
using Orleans.Runtime;

internal class Program
{
Expand Down Expand Up @@ -50,11 +49,12 @@ private static async Task<int> Main(string[] args)
// Now you should see that a consumer grain was activated on the silo, and is logging when it is receiving event

// Client can also subscribe to streams
var streamId = StreamId.Create(Constants.StreamNamespace, key);
var stream = client
.GetStreamProvider(Constants.StreamProvider)
.GetStream<int>(key, Constants.StreamNamespace);
.GetStream<int>(streamId);
await stream.SubscribeAsync(OnNextAsync);

// Now the client will also log received events

await Task.Delay(TimeSpan.FromSeconds(15));
Expand Down Expand Up @@ -86,7 +86,7 @@ async Task<bool> RetryFilter(Exception exception, CancellationToken cancellation
{
return false;
}
await Task.Delay(TimeSpan.FromSeconds(4));
await Task.Delay(TimeSpan.FromSeconds(4), cancellationToken);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0" />
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions samples/Streaming/Simple/GrainInterfaces/IConsumerGrain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Orleans;

namespace GrainInterfaces;

public interface IConsumerGrain : IGrainWithGuidKey
Expand Down
2 changes: 0 additions & 2 deletions samples/Streaming/Simple/GrainInterfaces/IProducerGrain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Orleans;

namespace GrainInterfaces;

public interface IProducerGrain : IGrainWithStringKey
Expand Down
1 change: 0 additions & 1 deletion samples/Streaming/Simple/Grains/ConsumerGrain.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Common;
using GrainInterfaces;
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.Streams;
using Orleans.Streams.Core;

Expand Down
10 changes: 5 additions & 5 deletions samples/Streaming/Simple/Grains/Grains.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Core.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk " Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions samples/Streaming/Simple/Grains/ProducerGrain.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Common;
using GrainInterfaces;
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.Runtime;
using Orleans.Streams;

namespace Grains;
Expand All @@ -26,8 +26,9 @@ public Task StartProducing(string ns, Guid key)
throw new Exception("This grain is already producing events");

// Get the stream
var streamId = StreamId.Create(ns, key);
_stream = this.GetStreamProvider(Constants.StreamProvider)
.GetStream<int>(key, ns);
.GetStream<int>(streamId);

// Register a timer that produce an event every second
var period = TimeSpan.FromSeconds(1);
Expand Down
1 change: 0 additions & 1 deletion samples/Streaming/Simple/SiloHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Common;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Orleans.Hosting;

try
{
Expand Down
12 changes: 6 additions & 6 deletions samples/Streaming/Simple/SiloHost/SiloHost.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="Microsoft.Orleans.Server" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs " Version="7.0.0-rc2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Server" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming " Version="7.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming.EventHubs " Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit cbe80ae

Please sign in to comment.