Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: posgres support #281

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/chore/compose.content.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
timeout: 20s
retries: 10
redis:
image: redis:7.2.3-alpine3.18
image: valkey/valkey:7.2.7-alpine3.20
ports:
- 6379:6379
volumes:
Expand All @@ -41,7 +41,7 @@ services:
- 50051:50051
- 8088:8088
depends_on:
mysql:
postgres:
condition: service_healthy
db1:
condition: service_healthy
Expand All @@ -52,20 +52,19 @@ services:
image: sixwaaaay/graph:v0.5.0
ports:
- 8080:8080
mysql:
image: mysql:8.2.0
postgres:
image: postgres:17.0-bookworm
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: content
MYSQL_USER: mysql_user
MYSQL_PASSWORD: mysql
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 33306:3306
- 5432:5432
volumes:
- ./content.sql:/docker-entrypoint-initdb.d/content.sql
- mysql-data:/var/lib/mysql
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
test: [ "CMD", "pg_isready", "-U", "postgres" ]
timeout: 20s
retries: 10
jaeger:
Expand All @@ -75,6 +74,6 @@ services:
- 16686:16686

volumes:
mysql-data:
postgres-data:
redis-data:
db1-data:
155 changes: 72 additions & 83 deletions .github/chore/content.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,107 +12,96 @@
*/


CREATE TABLE `notifications`
CREATE TABLE notifications
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`sender_id` BIGINT NOT NULL,
`receiver_id` BIGINT NOT NULL,
`content` varchar(255) NOT NULL,
`type` TINYINT unsigned NOT NULL DEFAULT 0,
`status` TINYINT unsigned NOT NULL DEFAULT 0,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `query_by_receiver_id` (`status`,`receiver_id`,`id` ASC)
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;
id BIGSERIAL PRIMARY KEY,
sender_id BIGINT NOT NULL,
receiver_id BIGINT NOT NULL,
content VARCHAR(255) NOT NULL,
type SMALLINT NOT NULL DEFAULT 0,
status SMALLINT NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);


CREATE INDEX query_by_receiver_id
ON notifications (status, receiver_id, id ASC);

CREATE TABLE videos
(
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
title VARCHAR(255) NOT NULL,
des VARCHAR(255) NOT NULL,
cover_url VARCHAR(255) NOT NULL default '',
video_url VARCHAR(255) NOT NULL default '',
duration INT UNSIGNED,
view_count INT UNSIGNED NOT NULL DEFAULT 0,
like_count INT UNSIGNED NOT NULL DEFAULT 0,
cover_url VARCHAR(255) NOT NULL DEFAULT '',
video_url VARCHAR(255) NOT NULL DEFAULT '',
duration INTEGER NOT NULL DEFAULT 0,
view_count INTEGER NOT NULL DEFAULT 0,
like_count INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
processed TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY `user_created` (`processed`, `user_id`, `id` DESC),
KEY `processed` (`processed`, `id` DESC)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
processed SMALLINT NOT NULL DEFAULT 0
);

CREATE TABLE counter
(
id BIGINT NOT NULL,
counter INT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;

INSERT INTO content.videos (id, user_id, title, des, cover_url, video_url, duration, view_count, like_count, created_at, updated_at, processed)
VALUES (1, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:12:27', '2023-12-31 01:12:27', 1),
(2, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:02', '2023-12-31 01:13:02', 1),
(3, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:19', '2023-12-31 01:13:19', 1),
(4, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:14:18', '2023-12-31 01:14:18', 1),
(5, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:07', '2023-12-31 12:05:07', 1),
(6, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:23', '2023-12-31 12:05:23', 1),
(7, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:42:53', '2023-12-31 12:42:53', 1),
(8, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:43:40', '2023-12-31 12:43:40', 1),
(9, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:18', '2023-12-31 12:53:18', 1),
(10, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:58', '2023-12-31 12:53:58', 1),
(11, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:08:05', '2023-12-31 13:08:05', 1),
(12, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:55:52', '2023-12-31 13:55:52', 1),
(13, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:56:22', '2023-12-31 13:56:22', 1),
(14, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:01:47', '2023-12-31 14:01:47', 1),
(15, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:10', '2023-12-31 14:02:10', 1),
(16, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:22', '2023-12-31 14:02:22', 1),
(17, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:42', '2023-12-31 14:02:42', 1),
(18, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:08:44', '2023-12-31 14:08:44', 1),
(19, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:09:13', '2023-12-31 14:09:13', 1),
(20, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:04', '2023-12-31 14:10:04', 1),
(21, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:48', '2023-12-31 14:10:48', 1),
(22, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:17:40', '2023-12-31 14:17:40', 1),
(23, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:32:50', '2023-12-31 14:32:50', 1),
(24, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:33:19', '2023-12-31 14:33:19', 1),
(25, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:41:41', '2023-12-31 14:41:41', 1),
(26, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:46:15', '2023-12-31 14:46:15', 1),
(27, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 22:03:32', '2023-12-31 22:03:32', 1),
(28, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:22:43', '2023-12-31 23:22:43', 1),
(29, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:23:05', '2023-12-31 23:23:05', 1),
(30, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:55:59', '2023-12-31 23:55:59', 1),
(31, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:51:46', '2024-01-01 14:51:46', 1),
(32, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:38', '2024-01-01 14:52:38', 1),
(33, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:49', '2024-01-01 14:52:49', 1),
(34, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:53:01', '2024-01-01 14:53:01', 1),
(35, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 15:10:38', '2024-01-01 15:10:38', 1),
(36, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 19:51:31', '2024-01-01 19:51:31', 1),
(37, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:15:07', '2024-01-01 20:15:07', 1),
(38, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:17:29', '2024-01-01 20:17:29', 1),
(39, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:11:43', '2024-01-02 14:11:43', 1),
(40, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:12:04', '2024-01-02 14:12:04', 1),
(41, 1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 15:36:48', '2024-01-02 15:36:48', 1);
CREATE INDEX user_created
ON videos (processed, user_id, id DESC);
CREATE INDEX processed
ON videos (processed, id DESC);


INSERT INTO content.counter (id, counter)
SELECT videos.user_id, count(*) FROM videos GROUP BY videos.user_id;
INSERT INTO videos (user_id, title, des, cover_url, video_url, duration, view_count, like_count, created_at, updated_at, processed)
VALUES (1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:12:27', '2023-12-31 01:12:27', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:02', '2023-12-31 01:13:02', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:13:19', '2023-12-31 01:13:19', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 01:14:18', '2023-12-31 01:14:18', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:07', '2023-12-31 12:05:07', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:05:23', '2023-12-31 12:05:23', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:42:53', '2023-12-31 12:42:53', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:43:40', '2023-12-31 12:43:40', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:18', '2023-12-31 12:53:18', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 12:53:58', '2023-12-31 12:53:58', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:08:05', '2023-12-31 13:08:05', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:55:52', '2023-12-31 13:55:52', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 13:56:22', '2023-12-31 13:56:22', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:01:47', '2023-12-31 14:01:47', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:10', '2023-12-31 14:02:10', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:22', '2023-12-31 14:02:22', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:02:42', '2023-12-31 14:02:42', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:08:44', '2023-12-31 14:08:44', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:09:13', '2023-12-31 14:09:13', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:04', '2023-12-31 14:10:04', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:10:48', '2023-12-31 14:10:48', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:17:40', '2023-12-31 14:17:40', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:32:50', '2023-12-31 14:32:50', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:33:19', '2023-12-31 14:33:19', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:41:41', '2023-12-31 14:41:41', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 14:46:15', '2023-12-31 14:46:15', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 22:03:32', '2023-12-31 22:03:32', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:22:43', '2023-12-31 23:22:43', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:23:05', '2023-12-31 23:23:05', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2023-12-31 23:55:59', '2023-12-31 23:55:59', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:51:46', '2024-01-01 14:51:46', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:38', '2024-01-01 14:52:38', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:52:49', '2024-01-01 14:52:49', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 14:53:01', '2024-01-01 14:53:01', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 15:10:38', '2024-01-01 15:10:38', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 19:51:31', '2024-01-01 19:51:31', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:15:07', '2024-01-01 20:15:07', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-01 20:17:29', '2024-01-01 20:17:29', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:11:43', '2024-01-02 14:11:43', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 14:12:04', '2024-01-02 14:12:04', 1),
(1, 'title', 'des', 'coverUrl', 'videoUrl', 1, 1, 1, '2024-01-02 15:36:48', '2024-01-02 15:36:48', 1);

CREATE TABLE popular_videos
(
order_num BIGINT NOT NULL
id BIGINT NOT NULL
PRIMARY KEY,
id BIGINT NULL,
score DOUBLE NULL
order_num BIGINT NOT NULL,
score DOUBLE PRECISION NULL
);



INSERT INTO popular_videos (id, order_num, score)
VALUES ('16', 1, 90.077423201946),
('38', 2, 89.7837850170059),
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/content.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
dotnet test --collect "Code Coverage;Format=cobertura"
dotnet-coverage merge -o merged.cobertura.xml -f cobertura TestResults/**/*.cobertura.xml
env:
CONNECTION_STRING: "server=localhost;port=33306;database=content;user=mysql_user;password=mysql;SslMode=none;Max Pool Size=2;AllowPublicKeyRetrieval=True; "
CONNECTION_STRING: "Host=localhost; Port=5432; Username=postgres; Password=postgres; Database=postgres; Maximum Pool Size=25;"
USER_STRING: "http://localhost:50051"
VOTE_STRING: "http://localhost:8080"
FFPROBE_PATH: "/usr/bin/ffprobe"
Expand Down
16 changes: 8 additions & 8 deletions sharp/content.Tests/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using content.repository;
using JetBrains.Annotations;
using MySqlConnector;
using Npgsql;
using Xunit.Abstractions;

namespace content.Tests;
Expand All @@ -27,7 +27,7 @@ public class UnitTest(ITestOutputHelper testOutputHelper)
[Fact(DisplayName = "Video Repository")]
public async void Test1()
{
await using var dataSource = new MySqlDataSource(_connectString);
await using var dataSource = NpgsqlDataSource.Create(_connectString);
var videoRepository = (IVideoRepository)new VideoRepository(dataSource);
var video = new Video
{
Expand All @@ -40,8 +40,8 @@ public async void Test1()
Duration = 1,
ViewCount = 1,
LikeCount = 1,
CreatedAt = DateTime.Now,
UpdatedAt = DateTime.Now,
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow,
Processed = 1
};
video = await videoRepository.Save(video);
Expand Down Expand Up @@ -79,7 +79,7 @@ public async void Test1()
[Fact(DisplayName = "Command")]
public async void TestInsert()
{
await using var dataSource = new MySqlDataSource(_connectString);
await using var dataSource = NpgsqlDataSource.Create(_connectString);
var videoRepository = (IVideoRepository)new VideoRepository(dataSource);
var video = new Video
{
Expand All @@ -92,8 +92,8 @@ public async void TestInsert()
Duration = 1,
ViewCount = 1,
LikeCount = 1,
CreatedAt = DateTime.Now,
UpdatedAt = DateTime.Now,
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow,
Processed = 1
};
video = await videoRepository.Save(video);
Expand All @@ -105,7 +105,7 @@ public async Task Test3()
{
var now = DateTime.Now;
var tasks = new List<Task>();
await using var dataSource = new MySqlDataSource(_connectString);
await using var dataSource = NpgsqlDataSource.Create(_connectString);
for (var i = 0; i < 10000; i++)
{
var videoRepository = new VideoRepository(dataSource);
Expand Down
4 changes: 2 additions & 2 deletions sharp/content.Tests/repository/NotificationRepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/


using MySqlConnector;
using content.repository;
using Npgsql;

namespace content.Tests.repository;
public class NotificationRepositoryTests
Expand All @@ -23,7 +23,7 @@ public class NotificationRepositoryTests

public NotificationRepositoryTests()
{
var dataSource = new MySqlDataSource(Environment.GetEnvironmentVariable("CONNECTION_STRING") !);
var dataSource = NpgsqlDataSource.Create(Environment.GetEnvironmentVariable("CONNECTION_STRING") !);
_repository = new NotificationRepository(dataSource);
}

Expand Down
8 changes: 4 additions & 4 deletions sharp/content/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using content.repository;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using MySqlConnector;
using Npgsql;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
Expand Down Expand Up @@ -51,7 +51,7 @@
builder.Services.AddOpenTelemetry().WithTracing(tcb =>
{
tcb
.AddSource(serviceName).AddSource("MySqlConnector")
.AddSource(serviceName).AddNpgsql()

Check warning on line 54 in sharp/content/Program.cs

View check run for this annotation

Codecov / codecov/patch

sharp/content/Program.cs#L54

Added line #L54 was not covered by tests
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName: serviceName))
.AddHttpClientInstrumentation()
.AddGrpcClientInstrumentation()
Expand All @@ -66,7 +66,7 @@
}).WithMetrics(mtb =>
{
mtb
.AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel", "MySqlConnector")
.AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel", "Npgsql")

Check warning on line 69 in sharp/content/Program.cs

View check run for this annotation

Codecov / codecov/patch

sharp/content/Program.cs#L69

Added line #L69 was not covered by tests
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddPrometheusExporter();
Expand All @@ -78,7 +78,7 @@
builder.Services.AddAuthorization().AddProbe();
builder.Services.AddProblemDetails().AddResponseCompression();

builder.Services.AddMySqlDataSource(builder.Configuration.GetConnectionString("Default") ??
builder.Services.AddNpgsqlDataSource(builder.Configuration.GetConnectionString("Default") ??
throw new InvalidOperationException("Connection string is null"));
builder.Services.AddVideoRepository().AddNotificationRepository();

Expand Down
5 changes: 3 additions & 2 deletions sharp/content/content.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MySqlConnector" Version="2.3.3" />
<PackageReference Include="MySqlConnector.DependencyInjection" Version="2.3.1" />
<PackageReference Include="npgsql" Version="8.0.5" />
<PackageReference Include="Npgsql.DependencyInjection" Version="8.0.5" />
<PackageReference Include="Npgsql.OpenTelemetry" Version="8.0.5" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.7.0-rc.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
Expand Down
Loading
Loading