Skip to content

Commit

Permalink
switch to new Cheetah.OpenSearch+Kafka packages
Browse files Browse the repository at this point in the history
  • Loading branch information
cthtrifork committed Jan 11, 2024
1 parent 7be7560 commit 4692c57
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 206 deletions.
12 changes: 2 additions & 10 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [Choice] .NET version: 6.0-bullseye-slim, 6.0-jammy, 6.0-focal
FROM mcr.microsoft.com/devcontainers/dotnet:1-6.0-jammy
FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm

ENV DOCKER_BUILDKIT=1
ENV DOCKER_DEFAULT_PLATFORM=linux/amd64
Expand All @@ -8,15 +8,7 @@ ENV DOCKER_DEFAULT_PLATFORM=linux/amd64
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends git curl exa

# Install Docker to use in docker-in-docker
RUN apt-get update && apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
# Add user "admin" to the Docker group
#&& usermod -a -G docker admin
ADD https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker /etc/bash_completion.d/docker.sh

USER vscode
#USER vscode
ARG GITHUB_ACTOR
ARG GITHUB_TOKEN

Expand Down
23 changes: 6 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,28 @@
},
"containerEnv": {
"GITHUB_ACTOR": "${localEnv:GITHUB_ACTOR}",
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
"DOTNET_ROLL_FORWARD": "LatestMajor"
},
"runArgs": [
// Network where OpenSearch is running
"--network=cheetah-infrastructure"
],
"initializeCommand": "docker network create cheetah-infrastructure || true",
"customizations": {
"vscode": {
"extensions": [
// Recommended extensions - GitHub
"GitHub.vscode-pull-request-github",
"GitHub.copilot",
// Recommended extensions - Collaboration
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"MS-vsliveshare.vsliveshare-pack",
"streetsidesoftware.code-spell-checker",
"redhat.vscode-yaml",
// Recommended extensions - .NET
"Fudge.auto-using",
"jongrant.csharpsortusings",
"kreativ-software.csharpextensions",
// Recommended extensions - Markdown
"bierner.github-markdown-preview",
"DavidAnson.vscode-markdownlint",
"docsmsft.docs-linting",
"yzhang.markdown-all-in-one",
// Required extensions
"ms-dotnettools.csharp",
"VisualStudioExptTeam.vscodeintellicode",
"aliasadidev.nugetpackagemanagergui"
]
"aliasadidev.nugetpackagemanagergui",
"ms-dotnettools.csdevkit"
],
}
},
"features": {
Expand All @@ -63,5 +52,5 @@
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
"remoteUser": "root"
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dotnetAcquisitionExtension.installTimeoutValue": 500,
"dotnet.dotnetPath": "/usr/share/dotnet",
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "msazurermtools.azurerm-vscode-tools",
"path": "/usr/share/dotnet/dotnet"
},
{
"extensionId": "visualstudiotoolsforunity.vstuc",
"path": "/usr/share/dotnet/dotnet"
}
]
}
3 changes: 2 additions & 1 deletion src/Cheetah.WebApi/Cheetah.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
<PackageReference Include="Cheetah.WebApi.Shared" Version="1.7.0" />
<PackageReference Include="Cheetah.OpenSearch" Version="0.1.0" />
<PackageReference Include="Cheetah.Kafka" Version="0.1.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.25" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
Expand Down
5 changes: 5 additions & 0 deletions src/Cheetah.WebApi/Cheetah.WebApi.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/Cheetah.WebApi/Core/Config/OpenSearchConfig.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Cheetah.WebApi/Core/Config/Priorities.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using FluentValidation.AspNetCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Cheetah.WebApi.Shared.Infrastructure.ServiceProvider;
using Cheetah.WebApi.Core.Config;

namespace Cheetah.WebApi.Infrastructure.Installers
{

[InstallerPriority(Priorities.BeforeConfig)]
public class FluentValidationInstaller : IServiceCollectionInstaller
public static class FluentValidationInstaller
{
public void Install(IServiceCollection services, IHostEnvironment hostEnvironment)
public static void InstallFluentValidation(this IServiceCollection services)
{
services.AddFluentValidation(config =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Prometheus;
using Cheetah.WebApi.Shared.Infrastructure.ServiceProvider;
using Cheetah.WebApi.Core.Config;

namespace Cheetah.WebApi.Infrastructure.Installers
{
[InstallerPriority(Priorities.AfterConfig)]
public class HealthCheckInstaller : IServiceCollectionInstaller
public static class HealthCheckInstaller
{
public void Install(IServiceCollection services, IHostEnvironment hostEnvironment)
public static void InstallHealthChecks(this IServiceCollection services)
{
services.AddHealthChecks()
.ForwardToPrometheus();
Expand Down

This file was deleted.

32 changes: 32 additions & 0 deletions src/Cheetah.WebApi/Infrastructure/Installers/KafkaInstaller.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Cheetah.WebApi.Core.Config;
using Confluent.Kafka;
using Microsoft.Extensions.Logging;
using Cheetah.Kafka.Extensions;
using Microsoft.Extensions.Configuration;

namespace Cheetah.WebApi.Infrastructure.Installers
{
public static class KafkaInstaller
{
public static void InstallKafka(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration)
{
var kafkaConsumerOptions = configuration.Get<KafkaConsumerConfig>();
services.AddCheetahKafka(configuration, options =>
{
options.ConfigureDefaultConsumer(config =>
{
config.AllowAutoCreateTopics = false;
config.GroupId = kafkaConsumerOptions.ConsumerName;
config.AutoOffsetReset = AutoOffsetReset.Latest;
config.EnableAutoCommit = true;
});
})
// todo: SetErrorHandler && SecurityProtocol
.WithConsumer<Ignore, string>()
.WithProducer<string, string>();
}
}
}

This file was deleted.

14 changes: 5 additions & 9 deletions src/Cheetah.WebApi/Infrastructure/Installers/OpenApiInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using System.Reflection;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.SwaggerGen;
using Cheetah.WebApi.Shared.Infrastructure.ServiceProvider;
using Cheetah.WebApi.Core.Config;

namespace Cheetah.WebApi.Infrastructure.Installers
{
[InstallerPriority(Priorities.BeforeConfig)]
public class OpenApiInstaller : IServiceCollectionInstaller
public static class OpenApiInstaller
{
public void Install(IServiceCollection services, IHostEnvironment hostEnvironment)
public static void InstallOpenAPI(this IServiceCollection services)
{
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
services
Expand All @@ -25,6 +18,9 @@ public void Install(IServiceCollection services, IHostEnvironment hostEnvironmen
.AddJsonOptions(options =>
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));


services.AddEndpointsApiExplorer();

services.AddApiVersioning(options =>
{
// reporting api versions will return the headers "api-supported-versions" and "api-deprecated-versions"
Expand Down
Loading

0 comments on commit 4692c57

Please sign in to comment.