okuda-seminar / log_service

Apache License 2.0
0 stars 0 forks source link

[Server] Imprement logs endpoint that return log list #47

Closed Rwatana closed 4 days ago

Rwatana commented 1 week ago

Issue Number

46

Implementation Summary

This pull request implements the presenter layer for the /logs endpoint. The presenter layer formats the data from the use case layer before sending it as a response. Key changes include:

Scope of Impact

Particular Points to Check

Test

➜  log_service git:(main) ✗ make send_message              
RABBITMQ_URL=amqp://guest:guest@localhost:5672/ go run ./cmd/client --log-level=debug --source-service=client --destination-service=server --request-type=POST --content="Hello World!"
2024/11/16 23:45:18 Received response: code: 0, message: OK

log_service git:(main) ✗ curl http://localhost:8080/logs

[{"log_level":"debug","date":"2024-11-16T14:45:19Z","source_service":"client","destination_service":"server","request_type":"POST","content":"Hello World!"}]
➜  log_service git:(main) ✗ make send_message              
RABBITMQ_URL=amqp://guest:guest@localhost:5672/ go run ./cmd/client --log-level=debug --source-service=client --destination-service=server --request-type=POST --content="Hello World!"
2024/11/17 00:08:10 Received response: code: 0, message: OK
➜  log_service git:(feature/#46_Imprement_logs_endpoint_that_return_log_list) ✗ curl http://localhost:8080/logs                                                

[{"log_level":"debug","date":"2024-11-16T14:45:19Z","source_service":"client","destination_service":"server","request_type":"POST","content":"Hello World!"},{"log_level":"debug","date":"2024-11-16T15:08:11Z","source_service":"client","destination_service":"server","request_type":"POST","content":"Hello World!"}]
➜  log_service git:(feature/#46_Imprement_logs_endpoint_that_return_log_list) ✗ 

Schedule

11/23

github-actions[bot] commented 1 week ago

Format failed

Files that need to be formatted:
github-actions[bot] commented 1 week ago

Format failed

Files that need to be formatted: cmd/server/main.go
Rwatana commented 1 week ago

@nayuta-ai Please check my code.

github-actions[bot] commented 1 week ago

Format failed

Files that need to be formatted: internal/server/server.go
Rwatana commented 1 week ago

@nayuta-ai

Topic

According to reference I think I have implemented graceful shutdown. Please check my code.

Test

 log_service git:(feature/#46_Imprement_logs_endpoint_that_return_log_list) docker stop log_service-server-1
log_service-server-1
➜  log_service git:(feature/#46_Imprement_logs_endpoint_that_return_log_list) docker logs log_service-server-1 
2024/11/18 15:12:22 Waiting for messages. To exit press CTRL^C
2024/11/18 15:12:22 HTTP server is running on :8080
2024/11/18 15:13:19 received sigint/sigterm, shutting down...
2024/11/18 15:13:19 press Ctrl^C again to force shutdown
2024/11/18 15:13:19 HTTP server gracefully stopped
2024/11/18 15:13:19 finished processing all jobs
➜  log_service git:(feature/#46_Imprement_logs_endpoint_that_return_log_list) 

Reference

https://zenn.dev/pyotarou/articles/87d43169e0abe0