move to python
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Torma Kristóf 2020-04-13 17:15:41 +02:00
parent 11ca8ea653
commit 4c73c2e9d7
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
38 changed files with 225 additions and 7758 deletions

View File

@ -1,358 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
.git/

View File

@ -3,32 +3,41 @@ type: docker
name: default
steps:
- name: build
image: docker:stable-dind
volumes:
- name: dockersock
path: /var/run
environment:
- name: static_analysis
image: python:3
commands:
- pip3 install pylint bandit mccabe
- pip3 install -r requirements.txt
- find . -name "*.py" -exec python3 -m py_compile '{}' \;
- find . -name "*.py" -exec pylint '{}' + || if [ $? -eq 1 ]; then echo "you fail"; fi
- find . -name "*.py" -exec python3 -m mccabe --min 3 '{}' + || if [ $? -eq 1 ]; then echo "you fail"; fi
- bandit -r . + || if [ $? -eq 1 ]; then echo "you fail"; fi
- name: build
image: docker:stable-dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_USERNAME:
from_secret: DOCKER_USERNAME
DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD
commands:
- sleep 30
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin registry.kmlabz.com
- docker build -t="registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME" .
- docker build -t="registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME:$DRONE_BUILD_NUMBER" .
- docker push "registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME"
- docker push "registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME:$DRONE_BUILD_NUMBER"
commands:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin registry.kmlabz.com
- docker build -t="registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME" .
- docker build -t="registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME:$DRONE_BUILD_NUMBER" .
- docker push "registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME"
- docker push "registry.kmlabz.com/$DOCKER_USERNAME/$DRONE_REPO_NAME:$DRONE_BUILD_NUMBER"
services:
- name: docker
image: docker:stable-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
- name: docker
image: docker:stable-dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
- name: dockersock
temp: {}

365
.gitignore vendored
View File

@ -1,357 +1,8 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/.gradle
/.idea
/out
/build
*.iml
*.ipr
*.iws
venv/

Binary file not shown.

View File

@ -1,20 +1,19 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM python:3.8-slim
ENV TZ Europe/Budapest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["OutputServiceTSDB.csproj", ""]
RUN dotnet restore "./OutputServiceTSDB.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "OutputServiceTSDB.csproj" -c Release -o /app/build
ARG RELEASE_ID
ENV RELEASE_ID ${RELEASE_ID:-""}
FROM build AS publish
RUN dotnet publish "OutputServiceTSDB.csproj" -c Release -o /app/publish
COPY requirements.txt ./
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "OutputServiceTSDB.dll"]
RUN pip install --no-cache-dir -r requirements.txt
COPY ./src .
EXPOSE 8080
ENTRYPOINT ["python3", "app.py"]

View File

@ -1,32 +0,0 @@
using System;
using InfluxDB.Client;
using InfluxDB.Client.Api.Domain;
using OutputServiceTSDB.Models;
using OutputServiceTSDB.Utilities;
namespace OutputServiceTSDB.InfluxDB
{
public class InfluxWriter: IDisposable
{
private readonly char[] Token = EnvironmentVariableConfiguration.InfluxDBToken.ToCharArray();
private InfluxDBClient influxDBClient;
public InfluxWriter()
{
influxDBClient = InfluxDBClientFactory.Create(EnvironmentVariableConfiguration.InfluxDBHost, Token);
}
public void Write(MeasurementObject measurementObject)
{
using (var writeApi = influxDBClient.GetWriteApi())
{
writeApi.WriteMeasurement(EnvironmentVariableConfiguration.InfluxDBBucket, EnvironmentVariableConfiguration.InfluxDBOrg, WritePrecision.Ns, measurementObject);
}
}
public void Dispose()
{
influxDBClient.Dispose();
}
}
}

View File

@ -1,31 +0,0 @@
using System;
using InfluxDB.Client.Core;
namespace OutputServiceTSDB.Models
{
[Measurement("result")]
public class MeasurementObject
{
[Column("deviceid", IsTag = true)]
public string DeviceID { get; set; }
private double _probability;
[Column("probability")]
public double Probability
{
get => _probability;
set
{
if (value > 1.0 || value < 0.0)
throw new ArgumentOutOfRangeException(
$"{nameof(value)} must be between 0 and 1.");
else
_probability = value;
}
}
[Column(IsTimestamp = true)] public DateTime Time;
}
}

View File

@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>dotnet-OutputServiceTSDB-B24657EA-E178-41CE-A32D-2C85CE1021AB</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="InfluxDB.Client" Version="1.6.0" />
<PackageReference Include="InfluxDB.Client.Flux" Version="1.6.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="Sentry" Version="2.1.1" />
</ItemGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30002.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OutputServiceTSDB", "OutputServiceTSDB.csproj", "{78A1F335-F516-41DA-8AD5-1ADB9FEF67F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{78A1F335-F516-41DA-8AD5-1ADB9FEF67F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78A1F335-F516-41DA-8AD5-1ADB9FEF67F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78A1F335-F516-41DA-8AD5-1ADB9FEF67F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78A1F335-F516-41DA-8AD5-1ADB9FEF67F3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4C722189-3231-4653-808F-EB09306889F8}
EndGlobalSection
EndGlobal

View File

@ -1,29 +0,0 @@
using OutputServiceTSDB.RabbitMQ;
using Sentry;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace OutputServiceTSDB
{
public class Program
{
public static void Main(string[] args)
{
using (SentrySdk.Init("https://744f5d479bdb4478b386173b92d081ac@sentry.kmlabz.com/12"))
{
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
RabbitMQWorker rabbitMQWorker = serviceProvider.GetService<RabbitMQWorker>();
rabbitMQWorker.ProcessMessages();
}
}
private static void ConfigureServices(IServiceCollection services)
{
services.AddLogging(configure => configure.AddConsole())
.Configure<LoggerFilterOptions>(options => options.MinLevel = LogLevel.Information)
.AddTransient<RabbitMQWorker>();
}
}
}

View File

@ -1,13 +0,0 @@
{
"profiles": {
"OutputServiceTSDB": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker"
}
}
}

View File

@ -1,64 +0,0 @@
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using OutputServiceTSDB.Utilities;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using OutputServiceTSDB.InfluxDB;
using OutputServiceTSDB.Models;
using Newtonsoft.Json;
using System;
namespace OutputServiceTSDB.RabbitMQ
{
public class RabbitMQWorker : IDisposable
{
private readonly ILogger _logger;
private IConnection _connection;
private IModel _channel;
private InfluxWriter influxWriter;
public RabbitMQWorker(ILogger<RabbitMQWorker> logger)
{
_logger = logger;
influxWriter = new InfluxWriter();
InitRabbitMQ();
}
private void InitRabbitMQ()
{
var factory = new ConnectionFactory { HostName = EnvironmentVariableConfiguration.RabbitMQHostname, UserName = EnvironmentVariableConfiguration.RabbitMQUserName, Password = EnvironmentVariableConfiguration.RabbitMQPassword };
_connection = factory.CreateConnection();
_channel = _connection.CreateModel();
_channel.ExchangeDeclare(EnvironmentVariableConfiguration.RabbitMQExchange, ExchangeType.Topic);
_channel.QueueDeclare(EnvironmentVariableConfiguration.RabbitMQQueue, false, false, false, null);
_channel.QueueBind(EnvironmentVariableConfiguration.RabbitMQQueue, EnvironmentVariableConfiguration.RabbitMQExchange, null, null);
_channel.BasicQos(0, 1, false);
}
public void ProcessMessages()
{
var consumer = new AsyncEventingBasicConsumer(_channel);
consumer.Received += HandleMessage;
_channel.BasicConsume("demo.queue.log", false, consumer);
}
private async Task HandleMessage(object sender, BasicDeliverEventArgs @event)
{
var content = System.Text.Encoding.UTF8.GetString(@event.Body);
_logger.LogInformation($"received {content}");
MeasurementObject measurementObject = JsonConvert.DeserializeObject<MeasurementObject>(content);
await Task.Run(() => influxWriter.Write(measurementObject));
}
public void Dispose()
{
_channel.Close();
_connection.Close();
influxWriter.Dispose();
}
}
}

View File

@ -1,71 +0,0 @@
using System;
namespace OutputServiceTSDB.Utilities
{
public static class EnvironmentVariableConfiguration
{
public static string RabbitMQHostname
{
get
{
return Environment.GetEnvironmentVariable("CS_RABBITMQ_HOSTNAME");
}
}
public static string RabbitMQUserName
{
get
{
return Environment.GetEnvironmentVariable("CS_RABBITMQ_USERNAME");
}
}
public static string RabbitMQPassword
{
get
{
return Environment.GetEnvironmentVariable("CS_RABBITMQ_PASSWORD");
}
}
public static string RabbitMQExchange
{
get
{
return Environment.GetEnvironmentVariable("CS_RABBITMQ_EXCHANGE");
}
}
public static string RabbitMQQueue
{
get
{
return Environment.GetEnvironmentVariable("CS_RABBITMQ_QUEUE");
}
}
public static string InfluxDBHost
{
get
{
return Environment.GetEnvironmentVariable("CS_INFLUXDB_HOST");
}
}
public static string InfluxDBToken
{
get
{
return Environment.GetEnvironmentVariable("CS_INFLUXDB_TOKEN");
}
}
public static string InfluxDBBucket
{
get
{
return Environment.GetEnvironmentVariable("CS_INFLUXDB_BUCKET");
}
}
public static string InfluxDBOrg
{
get
{
return Environment.GetEnvironmentVariable("CS_INFLUXDB_ORG");
}
}
}
}

View File

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -1,9 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

47
docker-compose.yml Normal file
View File

@ -0,0 +1,47 @@
version: '3'
services:
output-service-postgres:
image: "postgres:12"
restart: "always"
volumes:
- "ktor-data:/var/lib/postgresql/data"
ports:
- "127.0.0.1:54321:5432"
environment:
POSTGRES_USER: "output-service-rdb"
POSTGRES_PASSWORD: "output-service-rdb"
POSTGRES_DB: "output-service-rdb"
output-service-rdb:
image: "registry.kmlabz.com/tormakris/output-service-rdb"
restart: "always"
ports:
- "127.0.0.1:8080:8080"
environment:
DB_USER: "output-service-rdb"
DB_PASSWORD: "output-service-rdb"
POSTGRES_DB: "output-service-rdb"
DB_URL: "jdbc:postgresql://output-service-postgres:5432/output-service-rdb"
MQ_HOST: rabbitmq
MQ_USERNAME: rabbitmq
MQ_PASSWORD: rabbitmq
depends_on:
- rabbitmq
- output-service-postgres
rabbitmq:
image: "rabbitmq:3-management"
hostname: "rabbitmq"
environment:
RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG"
RABBITMQ_DEFAULT_USER: "rabbitmq"
RABBITMQ_DEFAULT_PASS: "rabbitmq"
RABBITMQ_DEFAULT_VHOST: "/"
ports:
- "127.0.0.1:15672:15672"
- "127.0.0.1:5672:5672"
volumes:
ktor-data:

View File

@ -1,17 +1,17 @@
 apiVersion: v1
kind: ConfigMap
metadata:
name: output-service-tsdb-config
labels:
app: output-service-tsdb
namespace: birbnetes
data:
CS_RABBITMQ_HOSTNAME: rabbitmq
CS_RABBITMQ_USERNAME: rabbitmq
CS_RABBITMQ_PASSWORD: rabbitmq
CS_RABBITMQ_EXCHANGE: rabbitmq
CS_RABBITMQ_QUEUE: rabbitmq
CS_INFLUXDB_HOST: "http://localhost:9999/"
CS_INFLUXDB_TOKEN: ""
CS_INFLUXDB_BUCKET: buck_ket
CS_INFLUXDB_ORG: birbnetes
apiVersion: v1
kind: ConfigMap
metadata:
name: output-service-tsdb-config
labels:
app: output-service-tsdb
namespace: birbnetes
data:
SENTRY_DSN: "https://744f5d479bdb4478b386173b92d081ac@sentry.kmlabz.com/12"
RELEASE_ID: luna-k8s
RABBITMQ_HOST: "amqp://user:1wZVQnP5vy@birb-rabbitmq/"
RABBITMQ_EXCHANGE: output
INFLUX_HOST: output-influxdb
INFLUX_PORT: "8086"
INFLUX_USERNAME: output-service
INFLUX_PASSWORD: output-service-supersecret
INFLUX_DB: output-service

View File

@ -1,4 +1,4 @@
apiVersion: apps/v1
apiVersion: apps/v1
kind: Deployment
metadata:
name: output-service-tsdb
@ -15,7 +15,7 @@ spec:
template:
metadata:
labels:
app: output-service-tsdb
app: output-service-rdb
spec:
containers:
- image: registry.kmlabz.com/tormakris/output-service-tsdb
@ -24,4 +24,4 @@ spec:
- configMapRef:
name: output-service-tsdb-config
imagePullSecrets:
- name: regcred
- name: regcred

View File

@ -1,23 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("OutputServiceTSDB")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("OutputServiceTSDB")]
[assembly: System.Reflection.AssemblyTitleAttribute("OutputServiceTSDB")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1 +0,0 @@
9983ad2e5303f678aefde2c1d017124ab095d016

View File

@ -1,5 +0,0 @@
C:\Users\Torma Kristóf\source\repos\OutputServiceTSDB\bin\Debug\netcoreapp3.1\appsettings.Development.json
C:\Users\Torma Kristóf\source\repos\OutputServiceTSDB\bin\Debug\netcoreapp3.1\appsettings.json
C:\Users\Torma Kristóf\source\repos\OutputServiceTSDB\obj\Debug\netcoreapp3.1\OutputServiceTSDB.csprojAssemblyReference.cache
C:\Users\Torma Kristóf\source\repos\OutputServiceTSDB\obj\Debug\netcoreapp3.1\OutputServiceTSDB.AssemblyInfoInputs.cache
C:\Users\Torma Kristóf\source\repos\OutputServiceTSDB\obj\Debug\netcoreapp3.1\OutputServiceTSDB.AssemblyInfo.cs

View File

@ -1,102 +0,0 @@
{
"format": 1,
"restore": {
"C:\\Users\\Torma Kristóf\\source\\repos\\OutputServiceTSDB\\OutputServiceTSDB.csproj": {}
},
"projects": {
"C:\\Users\\Torma Kristóf\\source\\repos\\OutputServiceTSDB\\OutputServiceTSDB.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Torma Kristóf\\source\\repos\\OutputServiceTSDB\\OutputServiceTSDB.csproj",
"projectName": "OutputServiceTSDB",
"projectPath": "C:\\Users\\Torma Kristóf\\source\\repos\\OutputServiceTSDB\\OutputServiceTSDB.csproj",
"packagesPath": "C:\\Users\\Torma Kristóf\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Torma Kristóf\\source\\repos\\OutputServiceTSDB\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Torma Kristóf\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"dependencies": {
"InfluxDB.Client": {
"target": "Package",
"version": "[1.6.0, )"
},
"InfluxDB.Client.Flux": {
"target": "Package",
"version": "[1.6.0, )"
},
"Microsoft.Extensions.DependencyInjection": {
"target": "Package",
"version": "[3.1.3, )"
},
"Microsoft.Extensions.Hosting": {
"target": "Package",
"version": "[3.1.3, )"
},
"Microsoft.Extensions.Logging": {
"target": "Package",
"version": "[3.1.3, )"
},
"Microsoft.Extensions.Logging.Console": {
"target": "Package",
"version": "[3.1.3, )"
},
"Microsoft.VisualStudio.Azure.Containers.Tools.Targets": {
"target": "Package",
"version": "[1.10.8, )"
},
"Newtonsoft.Json": {
"target": "Package",
"version": "[12.0.3, )"
},
"RabbitMQ.Client": {
"target": "Package",
"version": "[5.1.2, )"
},
"Sentry": {
"target": "Package",
"version": "[2.1.1, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.201\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Torma Kristóf\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.visualstudio.azure.containers.tools.targets\1.10.8\build\Microsoft.VisualStudio.Azure.Containers.Tools.Targets.props" Condition="Exists('$(NuGetPackageRoot)microsoft.visualstudio.azure.containers.tools.targets\1.10.8\build\Microsoft.VisualStudio.Azure.Containers.Tools.Targets.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgMicrosoft_VisualStudio_Azure_Containers_Tools_Targets Condition=" '$(PkgMicrosoft_VisualStudio_Azure_Containers_Tools_Targets)' == '' ">C:\Users\Torma Kristóf\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.10.8</PkgMicrosoft_VisualStudio_Azure_Containers_Tools_Targets>
</PropertyGroup>
</Project>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.visualstudio.azure.containers.tools.targets\1.10.8\build\Microsoft.VisualStudio.Azure.Containers.Tools.Targets.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.visualstudio.azure.containers.tools.targets\1.10.8\build\Microsoft.VisualStudio.Azure.Containers.Tools.Targets.targets')" />
</ImportGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -1,133 +0,0 @@
{
"version": 2,
"dgSpecHash": "Y/6fMu2P/3gq1w+wO9swqWBfIAy49Js0lDcBxLmORYkmSYDUbIKsTkVnSDtk0GHLM9lS0j/m07/jpNWC8WvQNg==",
"success": true,
"projectFilePath": "C:\\Users\\Torma Kristóf\\source\\repos\\OutputServiceTSDB\\OutputServiceTSDB.csproj",
"expectedPackageFiles": [
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\csvhelper\\8.1.1\\csvhelper.8.1.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\influxdb.client\\1.6.0\\influxdb.client.1.6.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\influxdb.client.core\\1.6.0\\influxdb.client.core.1.6.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\influxdb.client.flux\\1.6.0\\influxdb.client.flux.1.6.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\jsonsubtypes\\1.5.2\\jsonsubtypes.1.5.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.csharp\\4.4.0\\microsoft.csharp.4.4.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration\\3.1.3\\microsoft.extensions.configuration.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.abstractions\\3.1.3\\microsoft.extensions.configuration.abstractions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.binder\\3.1.3\\microsoft.extensions.configuration.binder.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.commandline\\3.1.3\\microsoft.extensions.configuration.commandline.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.environmentvariables\\3.1.3\\microsoft.extensions.configuration.environmentvariables.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.fileextensions\\3.1.3\\microsoft.extensions.configuration.fileextensions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.json\\3.1.3\\microsoft.extensions.configuration.json.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.configuration.usersecrets\\3.1.3\\microsoft.extensions.configuration.usersecrets.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.dependencyinjection\\3.1.3\\microsoft.extensions.dependencyinjection.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\3.1.3\\microsoft.extensions.dependencyinjection.abstractions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.fileproviders.abstractions\\3.1.3\\microsoft.extensions.fileproviders.abstractions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.fileproviders.physical\\3.1.3\\microsoft.extensions.fileproviders.physical.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.filesystemglobbing\\3.1.3\\microsoft.extensions.filesystemglobbing.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.hosting\\3.1.3\\microsoft.extensions.hosting.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.hosting.abstractions\\3.1.3\\microsoft.extensions.hosting.abstractions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging\\3.1.3\\microsoft.extensions.logging.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\3.1.3\\microsoft.extensions.logging.abstractions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging.configuration\\3.1.3\\microsoft.extensions.logging.configuration.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging.console\\3.1.3\\microsoft.extensions.logging.console.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging.debug\\3.1.3\\microsoft.extensions.logging.debug.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging.eventlog\\3.1.3\\microsoft.extensions.logging.eventlog.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.logging.eventsource\\3.1.3\\microsoft.extensions.logging.eventsource.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.options\\3.1.3\\microsoft.extensions.options.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.options.configurationextensions\\3.1.3\\microsoft.extensions.options.configurationextensions.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.extensions.primitives\\3.1.3\\microsoft.extensions.primitives.3.1.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.net.http.headers\\2.1.1\\microsoft.net.http.headers.2.1.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.netcore.platforms\\3.1.0\\microsoft.netcore.platforms.3.1.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.netcore.targets\\1.1.0\\microsoft.netcore.targets.1.1.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.visualstudio.azure.containers.tools.targets\\1.10.8\\microsoft.visualstudio.azure.containers.tools.targets.1.10.8.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.win32.primitives\\4.3.0\\microsoft.win32.primitives.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\microsoft.win32.registry\\4.7.0\\microsoft.win32.registry.4.7.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\netstandard.library\\1.6.1\\netstandard.library.1.6.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\newtonsoft.json\\12.0.3\\newtonsoft.json.12.0.3.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\nodatime\\2.4.1\\nodatime.2.4.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\nodatime.serialization.jsonnet\\2.0.0\\nodatime.serialization.jsonnet.2.0.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\rabbitmq.client\\5.1.2\\rabbitmq.client.5.1.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\restsharp\\106.6.10\\restsharp.106.6.10.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.debian.8-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.debian.8-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.fedora.23-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.fedora.23-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.fedora.24-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.fedora.24-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.native.system\\4.3.0\\runtime.native.system.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.native.system.io.compression\\4.3.0\\runtime.native.system.io.compression.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.native.system.net.http\\4.3.0\\runtime.native.system.net.http.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.native.system.security.cryptography.apple\\4.3.0\\runtime.native.system.security.cryptography.apple.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.opensuse.13.2-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.opensuse.13.2-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.opensuse.42.1-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.opensuse.42.1-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.osx.10.10-x64.runtime.native.system.security.cryptography.apple\\4.3.0\\runtime.osx.10.10-x64.runtime.native.system.security.cryptography.apple.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.osx.10.10-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.osx.10.10-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.rhel.7-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.rhel.7-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.ubuntu.14.04-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.ubuntu.14.04-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.ubuntu.16.04-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.ubuntu.16.04-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl\\4.3.2\\runtime.ubuntu.16.10-x64.runtime.native.system.security.cryptography.openssl.4.3.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\sentry\\2.1.1\\sentry.2.1.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\sentry.platformabstractions\\1.1.0\\sentry.platformabstractions.1.1.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\sentry.protocol\\2.1.1\\sentry.protocol.2.1.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.appcontext\\4.3.0\\system.appcontext.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.buffers\\4.5.0\\system.buffers.4.5.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.collections\\4.3.0\\system.collections.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.collections.concurrent\\4.3.0\\system.collections.concurrent.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.collections.immutable\\1.5.0\\system.collections.immutable.1.5.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.configuration.configurationmanager\\4.5.0\\system.configuration.configurationmanager.4.5.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.console\\4.3.0\\system.console.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.diagnostics.debug\\4.3.0\\system.diagnostics.debug.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.diagnostics.diagnosticsource\\4.3.0\\system.diagnostics.diagnosticsource.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.diagnostics.eventlog\\4.7.0\\system.diagnostics.eventlog.4.7.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.diagnostics.tools\\4.3.0\\system.diagnostics.tools.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.diagnostics.tracing\\4.3.0\\system.diagnostics.tracing.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.globalization\\4.3.0\\system.globalization.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.globalization.calendars\\4.3.0\\system.globalization.calendars.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.globalization.extensions\\4.3.0\\system.globalization.extensions.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.io\\4.3.0\\system.io.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.io.compression\\4.3.0\\system.io.compression.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.io.compression.zipfile\\4.3.0\\system.io.compression.zipfile.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.io.filesystem\\4.3.0\\system.io.filesystem.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.io.filesystem.primitives\\4.3.0\\system.io.filesystem.primitives.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.linq\\4.3.0\\system.linq.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.linq.expressions\\4.3.0\\system.linq.expressions.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.net.http\\4.3.4\\system.net.http.4.3.4.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.net.primitives\\4.3.0\\system.net.primitives.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.net.sockets\\4.3.0\\system.net.sockets.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.objectmodel\\4.3.0\\system.objectmodel.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reactive\\4.1.2\\system.reactive.4.1.2.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection\\4.3.0\\system.reflection.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection.emit\\4.3.0\\system.reflection.emit.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection.emit.ilgeneration\\4.3.0\\system.reflection.emit.ilgeneration.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection.emit.lightweight\\4.3.0\\system.reflection.emit.lightweight.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection.extensions\\4.3.0\\system.reflection.extensions.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection.primitives\\4.3.0\\system.reflection.primitives.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.reflection.typeextensions\\4.4.0\\system.reflection.typeextensions.4.4.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.resources.resourcemanager\\4.3.0\\system.resources.resourcemanager.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime\\4.3.0\\system.runtime.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime.extensions\\4.3.0\\system.runtime.extensions.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime.handles\\4.3.0\\system.runtime.handles.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime.interopservices\\4.3.0\\system.runtime.interopservices.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime.interopservices.runtimeinformation\\4.3.0\\system.runtime.interopservices.runtimeinformation.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime.interopservices.windowsruntime\\4.3.0\\system.runtime.interopservices.windowsruntime.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.runtime.numerics\\4.3.0\\system.runtime.numerics.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.accesscontrol\\4.7.0\\system.security.accesscontrol.4.7.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.algorithms\\4.3.0\\system.security.cryptography.algorithms.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.cng\\4.3.0\\system.security.cryptography.cng.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.csp\\4.3.0\\system.security.cryptography.csp.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.encoding\\4.3.0\\system.security.cryptography.encoding.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.openssl\\4.3.0\\system.security.cryptography.openssl.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.primitives\\4.3.0\\system.security.cryptography.primitives.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.protecteddata\\4.5.0\\system.security.cryptography.protecteddata.4.5.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.cryptography.x509certificates\\4.3.0\\system.security.cryptography.x509certificates.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.permissions\\4.5.0\\system.security.permissions.4.5.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.security.principal.windows\\4.7.0\\system.security.principal.windows.4.7.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.text.encoding\\4.3.0\\system.text.encoding.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.text.encoding.extensions\\4.3.0\\system.text.encoding.extensions.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.text.regularexpressions\\4.3.0\\system.text.regularexpressions.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.threading\\4.3.0\\system.threading.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.threading.tasks\\4.3.0\\system.threading.tasks.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.threading.tasks.extensions\\4.5.1\\system.threading.tasks.extensions.4.5.1.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.threading.timer\\4.3.0\\system.threading.timer.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.xml.readerwriter\\4.3.0\\system.xml.readerwriter.4.3.0.nupkg.sha512",
"C:\\Users\\Torma Kristóf\\.nuget\\packages\\system.xml.xdocument\\4.3.0\\system.xml.xdocument.4.3.0.nupkg.sha512"
],
"logs": []
}

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
aio-pika
sentry-sdk
aioinflux

78
src/app.py Normal file
View File

@ -0,0 +1,78 @@
#!/usr/bin/env python
"""
Main entrypoint
"""
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, Birbnetes Team"
__module_name__ = "app"
__version__text__ = "1"
from datetime import datetime
import json
import asyncio
from aio_pika import connect, IncomingMessage, ExchangeType
import sentry_sdk
from aioinflux import InfluxDBClient
import config
if config.SENTRY_DSN:
sentry_sdk.init(
dsn=config.SENTRY_DSN,
send_default_pii=True,
release=config.RELEASE_ID,
environment=config.RELEASEMODE
)
async def on_message(message: IncomingMessage):
"""
on_message doesn't necessarily have to be defined as async.
Here it is to show that it's possible.
"""
msg_json = json.loads(message.body)
now = datetime.now()
point = {
'time': now,
'measurement': 'sturnus',
'tags': {'device': 'dummy'},
'fields': {'probability': msg_json['probability']}
}
async with InfluxDBClient(username=config.INFLUXDB_USERNAME, password=config.INFLUXDB_PASSWORD,
host=config.INFLUXDB_HOST, port=config.INFLUXDB_PORT) as client:
await client.create_database(db=config.INFLUXDB_DB)
await client.write(point)
async def main(loop_):
# Perform connection
connection = await connect(
config.RABBITMQ_HOST, loop=loop_
)
# Creating a channel
channel = await connection.channel()
# Declare exchange
exchange = await channel.declare_exchange(
config.RABBITMQ_EXCHANGE, ExchangeType.FANOUT
)
# Declaring queue
queue = await channel.declare_queue(exclusive=True)
# Bind queue to exchange
await queue.bind(exchange)
# Start listening the queue with name 'hello'
await queue.consume(on_message, no_ack=True)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(main(loop))
# we enter a never-ending loop that waits for data and
# runs callbacks whenever necessary.
loop.run_forever()

25
src/config.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
"""
Configuration
"""
import os
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, Birbnetes Team"
__module_name__ = "config"
__version__text__ = "1"
SENTRY_DSN = os.environ.get("SENTRY_DSN")
RELEASE_ID = os.environ.get("RELEASE_ID", "test")
RELEASEMODE = os.environ.get("RELEASEMODE", "dev")
RABBITMQ_HOST = os.getenv("RABBITMQ_HOST", "amqp://guest:guest@localhost/")
RABBITMQ_EXCHANGE = os.getenv("RABBITMQ_EXCHANGE", "output")
INFLUXDB_HOST = os.getenv("INFLUX_HOST", "output-service")
INFLUXDB_PORT = os.getenv("INFLUX_PORT", "8086")
INFLUXDB_USERNAME = os.getenv("INFLUX_USERNAME", "output-service")
INFLUXDB_PASSWORD = os.getenv("INFLUX_PASSWORD", "output-service-supersecret")
INFLUXDB_DB = os.getenv("INFLUX_DB", "output-service")