-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from sixwaaaay/native
content native
- Loading branch information
Showing
27 changed files
with
2,012 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
services: | ||
db1: | ||
image: mysql:8.2.0 | ||
environment: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: users | ||
MYSQL_USER: mysql_user | ||
MYSQL_PASSWORD: mysql | ||
ports: | ||
- 3306:3306 | ||
volumes: | ||
- ../../cmd/shauser/scripts/schema.sql:/docker-entrypoint-initdb.d/schema.sql | ||
- db1-data:/var/lib/mysql | ||
healthcheck: | ||
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ] | ||
timeout: 20s | ||
retries: 10 | ||
redis: | ||
image: redis:7.2.3-alpine3.18 | ||
ports: | ||
- 6379:6379 | ||
volumes: | ||
- redis-data:/data | ||
|
||
shauser: | ||
image: sixwaaaay/shauser:latest | ||
ports: | ||
- 50051:50051 | ||
- 8088:8088 | ||
depends_on: | ||
mysql: | ||
condition: service_healthy | ||
db1: | ||
condition: service_healthy | ||
volumes: | ||
- ./config.user.yaml:/app/configs/config.yaml | ||
|
||
graph: | ||
image: sixwaaaay/graph:v0.5.0 | ||
ports: | ||
- 8080:8080 | ||
mysql: | ||
image: mysql:8.2.0 | ||
environment: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: content | ||
MYSQL_USER: mysql_user | ||
MYSQL_PASSWORD: mysql | ||
ports: | ||
- 33306:3306 | ||
volumes: | ||
- ./content.sql:/docker-entrypoint-initdb.d/content.sql | ||
- mysql-data:/var/lib/mysql | ||
healthcheck: | ||
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ] | ||
timeout: 20s | ||
retries: 10 | ||
|
||
volumes: | ||
mysql-data: | ||
redis-data: | ||
db1-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ListenOn: :50051 | ||
HTTP: :8088 | ||
MySQL: | ||
DSN: mysql_user:mysql@tcp(db1:3306)/users?charset=utf8mb4&parseTime=True&loc=Local&allowNativePasswords=true | ||
Replicas: [] # support multiple mysql replicas dsn | ||
DefaultLimit: 20 | ||
MaxLimit: 100 | ||
Secret: "this is a secret" | ||
TTL: 360h # 15day 15 * 24 * 60 * 60 | ||
Cache: | ||
Enabled: true | ||
TTL: 10m # cache expire time 10 minutes | ||
Redis: | ||
Addrs: | ||
- "redis:6379" | ||
Oauth: | ||
clientid: $OAUTH_CLIENT_ID | ||
clientsecret: $OAUTH_CLIENT_SECRET | ||
endpoint: | ||
authurl: https://github.com/login/oauth/authorize | ||
tokenurl: https://github.com/login/oauth/access_token | ||
redirecturl: ${REDIRECT_URL}/oauth/callback/github | ||
scopes: | ||
- user:email | ||
- read:user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
CREATE TABLE videos | ||
( | ||
id BIGINT NOT NULL AUTO_INCREMENT, | ||
user_id BIGINT NOT NULL, | ||
title VARCHAR(255) NOT NULL, | ||
des TEXT 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, | ||
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; | ||
|
||
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); | ||
|
||
INSERT INTO content.counter (id, counter) | ||
SELECT videos.user_id, count(*) FROM videos GROUP BY videos.user_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: "Content" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'sharp/**' | ||
- '.github/workflows/compose.content.yaml' | ||
pull_request: | ||
paths: | ||
- 'sharp/**' | ||
- '.github/workflows/compose.content.yaml' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Docker Compose | ||
working-directory: .github/chore | ||
run: | | ||
docker compose -f compose.content.yaml up -d | ||
- name: Setup C# environment | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: "8.0.x" | ||
|
||
- name: Install FFmpeg | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install ffmpeg | ||
- name: Install dependencies | ||
run: | | ||
dotnet tool install -g dotnet-coverage | ||
dotnet restore sharp/content/content.csproj | ||
dotnet restore sharp/content.Tests/content.Tests.csproj | ||
- name: Coverage | ||
working-directory: sharp/content.Tests | ||
run: | | ||
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; " | ||
USER_STRING: "http://localhost:50051" | ||
VOTE_STRING: "http://localhost:8080" | ||
FFPROBE_PATH: "/usr/bin/ffprobe" | ||
|
||
- name: Upload coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: sharp/content.Tests/merged.cobertura.xml | ||
flags: content | ||
fail_ci_if_error: true | ||
container: | ||
name: Container Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./sharp/content | ||
file: ./sharp/content/Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKERHUB_USERNAME || 'app' }}/content:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
component_management: | ||
individual_components: | ||
- component_id: users | ||
path: | ||
- cmd/shauser/** | ||
- component_id: content | ||
path: | ||
- sharp/** | ||
ignore: | ||
- sharp/content/Program.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/bin | ||
**/obj | ||
**/Properties/launchSettings.json |
Oops, something went wrong.