-
Notifications
You must be signed in to change notification settings - Fork 0
Feature : 분산 시스템 세션 개선 - Redis Pub/sub #23
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
Changes from 6 commits
95679f8
4e1c7d0
1ba9e2a
eaf1959
5f1f9dc
992e21a
98522a2
a1364dd
90529c3
d8455dd
625cc80
15adfec
f16b34c
4a56676
48f34c6
c548522
295337c
095564f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,13 +3,23 @@ | |||||
| # =========================================== | ||||||
| # Copy this file to .env and fill in your actual values | ||||||
|
|
||||||
| ENVIRONMENT=development | ||||||
| DEBUG_MODE=true | ||||||
| LOG_LEVEL=INFO | ||||||
| LOG_FORMAT=json | ||||||
| DATA_PATH=../data | ||||||
|
|
||||||
| # Database Configuration | ||||||
| DB_CONNECTION_STRING=Server=host.docker.internal,1433;Database=ProjectVG;User Id=sa;Password=YOUR_DB_PASSWORD;TrustServerCertificate=true;MultipleActiveResultSets=true | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DB 연결 문자열은 따옴표로 감싸기 특수문자 포함 값은 인용이 안전합니다. dotenv-linter 경고도 해소됩니다. -DB_CONNECTION_STRING=Server=host.docker.internal,1433;Database=ProjectVG;User Id=sa;Password=YOUR_DB_PASSWORD;TrustServerCertificate=true;MultipleActiveResultSets=true
+DB_CONNECTION_STRING="Server=host.docker.internal,1433;Database=ProjectVG;User Id=sa;Password=YOUR_DB_PASSWORD;TrustServerCertificate=true;MultipleActiveResultSets=true"📝 Committable suggestion
Suggested change
🧰 Tools🪛 dotenv-linter (3.3.0)[warning] 13-13: [ValueWithoutQuotes] This value needs to be surrounded in quotes (ValueWithoutQuotes) 🤖 Prompt for AI Agents |
||||||
| DB_PASSWORD=YOUR_DB_PASSWORD | ||||||
|
|
||||||
| # Redis Configuration | ||||||
| REDIS_CONNECTION_STRING=host.docker.internal:6380 | ||||||
|
|
||||||
| # Distributed System Configuration | ||||||
| DISTRIBUTED_MODE=false | ||||||
| SERVER_ID= | ||||||
|
|
||||||
| # External Services | ||||||
| LLM_BASE_URL=http://host.docker.internal:7930 | ||||||
| MEMORY_BASE_URL=http://host.docker.internal:7940 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| using System.Text.Json; | ||
|
|
||
| namespace ProjectVG.Application.Models.MessageBroker | ||
| { | ||
| public class BrokerMessage | ||
| { | ||
| public string MessageId { get; set; } = Guid.NewGuid().ToString(); | ||
| public string MessageType { get; set; } = string.Empty; | ||
| public string? TargetUserId { get; set; } | ||
| public string? TargetServerId { get; set; } | ||
| public string? SourceServerId { get; set; } | ||
| public DateTime Timestamp { get; set; } = DateTime.UtcNow; | ||
| public string Payload { get; set; } = string.Empty; | ||
| public Dictionary<string, string> Headers { get; set; } = new(); | ||
|
|
||
| public static BrokerMessage CreateUserMessage(string userId, object payload, string? sourceServerId = null) | ||
| { | ||
| return new BrokerMessage | ||
| { | ||
| MessageType = "user_message", | ||
| TargetUserId = userId, | ||
| SourceServerId = sourceServerId, | ||
| Payload = JsonSerializer.Serialize(payload), | ||
| Headers = new Dictionary<string, string> | ||
| { | ||
| ["content-type"] = "application/json" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public static BrokerMessage CreateServerMessage(string serverId, object payload, string? sourceServerId = null) | ||
| { | ||
| return new BrokerMessage | ||
| { | ||
| MessageType = "server_message", | ||
| TargetServerId = serverId, | ||
| SourceServerId = sourceServerId, | ||
| Payload = JsonSerializer.Serialize(payload), | ||
| Headers = new Dictionary<string, string> | ||
| { | ||
| ["content-type"] = "application/json" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public static BrokerMessage CreateBroadcastMessage(object payload, string? sourceServerId = null) | ||
| { | ||
| return new BrokerMessage | ||
| { | ||
| MessageType = "broadcast_message", | ||
| SourceServerId = sourceServerId, | ||
| Payload = JsonSerializer.Serialize(payload), | ||
| Headers = new Dictionary<string, string> | ||
| { | ||
| ["content-type"] = "application/json" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| public T? DeserializePayload<T>() | ||
| { | ||
| try | ||
| { | ||
| return JsonSerializer.Deserialize<T>(Payload); | ||
| } | ||
| catch | ||
| { | ||
| return default; | ||
| } | ||
| } | ||
|
|
||
| public string ToJson() | ||
| { | ||
| return JsonSerializer.Serialize(this); | ||
| } | ||
|
|
||
| public static BrokerMessage? FromJson(string json) | ||
| { | ||
| try | ||
| { | ||
| return JsonSerializer.Deserialize<BrokerMessage>(json); | ||
| } | ||
| catch | ||
| { | ||
| return null; | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| namespace ProjectVG.Application.Models.Server | ||
| { | ||
| public class ServerInfo | ||
| { | ||
| public string ServerId { get; set; } = string.Empty; | ||
| public DateTime StartedAt { get; set; } | ||
| public DateTime LastHeartbeat { get; set; } | ||
| public int ActiveConnections { get; set; } | ||
| public string Status { get; set; } = "healthy"; | ||
| public string? Environment { get; set; } | ||
| public string? Version { get; set; } | ||
|
|
||
| public ServerInfo() | ||
| { | ||
| } | ||
|
|
||
| public ServerInfo(string serverId) | ||
| { | ||
| ServerId = serverId; | ||
| StartedAt = DateTime.UtcNow; | ||
| LastHeartbeat = DateTime.UtcNow; | ||
| ActiveConnections = 0; | ||
| Status = "healthy"; | ||
| } | ||
|
|
||
| public void UpdateHeartbeat() | ||
| { | ||
| LastHeartbeat = DateTime.UtcNow; | ||
| } | ||
|
|
||
| public void UpdateConnectionCount(int count) | ||
| { | ||
| ActiveConnections = count; | ||
| } | ||
|
|
||
| public bool IsHealthy(TimeSpan timeout) | ||
| { | ||
| return DateTime.UtcNow - LastHeartbeat < timeout; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENVIRONMENT vs ASPNETCORE_ENVIRONMENT 값 충돌
두 변수가 서로 다른 값을 갖고 있어 실제 실행 환경이 오인될 수 있습니다. 하나로 통일하세요.
(또는 ENVIRONMENT 키를 제거/주석 처리하고 ASPNETCORE_ENVIRONMENT만 사용)
Also applies to: 50-50
🧰 Tools
🪛 dotenv-linter (3.3.0)
[warning] 7-7: [UnorderedKey] The DEBUG_MODE key should go before the ENVIRONMENT key
(UnorderedKey)
[warning] 9-9: [UnorderedKey] The LOG_FORMAT key should go before the LOG_LEVEL key
(UnorderedKey)
[warning] 10-10: [UnorderedKey] The DATA_PATH key should go before the DEBUG_MODE key
(UnorderedKey)
🤖 Prompt for AI Agents