Skip to content

Instantly share code, notes, and snippets.

Avatar

Derek Comartin dcomartin

View GitHub Profile
View program.cs
class Program
{
static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((context, collection) =>
View producer.cs
public class KafkaProducerHostedService : IHostedService
{
private readonly ILogger<KafkaProducerHostedService> _logger;
private readonly IProducer<Null, string> _producer;
public KafkaProducerHostedService(ILogger<KafkaProducerHostedService> logger)
{
_logger = logger;
var config = new ProducerConfig()
{
View consumer.cs
public class KafkaConsumerHostedService : IHostedService
{
private readonly ILogger<KafkaConsumerHostedService> _logger;
private readonly ClusterClient _cluster;
public KafkaConsumerHostedService(ILogger<KafkaConsumerHostedService> logger)
{
_logger = logger;
_cluster = new ClusterClient(new Configuration
{
View docker-pull
# Zookeeper
docker pull confluentinc/cp-zookeeper
# Kafka
docker pull confluentinc/cp-kafka
View docker-run
# Zookeeper
docker run -d --network=kafka --name=zookeeper -e ZOOKEEPER_CLIENT_PORT=2181 -e ZOOKEEPER_TICK_TIME=2000 -p 2181:2181 confluentinc/cp-zookeeper
# Kafka
docker run -d --network=kafka --name=kafka -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 -p 9092:9092 confluentinc/cp-kafka
View Directory.Build.targets.xml
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.4.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
</ItemGroup>
</Project>
View csproj.xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.Infrastructure</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
View Directory.Build.targets.xml
<Project>
<ItemGroup>
<PackageReference Update="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
</ItemGroup>
</Project>
View csproj.xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.Infrastructure</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
You can’t perform that action at this time.