From 8e71eba6c409a66abcf158a0fdcd907d2ab5f838 Mon Sep 17 00:00:00 2001 From: Simon Hung Date: Mon, 28 Oct 2024 16:25:31 +0800 Subject: [PATCH 1/2] docs: update readme --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb2ddfe --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# 專案說明 + +通知服務 + +# 啟動說明 + +## Quick Start + +```bash +cd app-cloudep-notification-service +go mod tidy +make gen-rpc +# 設定 etc/notification.yml 各依賴的 config +go run notification.go +``` + +## 依賴套件或工具 + +以下已 macOS 為例,若已安裝或有其他可用服務則可跳過 + +- go-zero goctl (https://go-zero.dev/docs/tasks/installation/goctl) + ```bash + $ go install github.com/zeromicro/go-zero/tools/goctl@latest + ``` +- protobuf (https://protobuf.dev/) + ```bash + brew install protobuf + ``` +- etcd (https://etcd.io/) + ```bash + brew install etcd + brew services start etcd + ``` +- SMTP 服務(以 mailhog 為例) (https://github.com/mailhog/MailHog) + ```bash + brew install mailhog + brew services start mailhog + ``` + +# 專案架構 + +``` +$tree -L 3 --gitignore + +. +├── Makefile +├── build +│ └── Dockerfile +├── chart +│ └── readme.md +├── etc +│ └── service.example.yaml # 設定檔範例 +├── generate # 這個資料夾會用來自動生成一些程式 +│ ├── database ## 資料庫生成檔案或紀錄遷移版本 +│ │ ├── mongodb +│ │ ├── mysql +│ │ ├── readme.md +│ │ └── seeder +│ └── protobuf ## gRPC 的定義,用來生成 gRPC 檔案 +│ └── notification.proto +├── go.mod +├── internal +│ ├── config # 設定的結構 +│ │ └── config.go +│ ├── domain # 此服務下的一些常數定義 +│ │ ├── errors.go ## 錯誤定義 +│ │ └── usecase ## usecase 內的常數定義 +│ │ ├── mail.go +│ │ └── sms.go +│ ├── logic # 主要的程式邏輯都在這,每個功能用一個資料夾開發 +│ │ └── senderservice +│ ├── server +│ │ └── senderservice # gRPC 自動產生的檔案 +│ ├── svc # 此服務下會共用的功能,例如 API context, db 連線等 +│ │ └── service_context.go ## API context +│ └── usecase +│ ├── mitake.go +│ └── smtp.go +└── notification.go # 服務主入口 +``` -- 2.40.1 From 0abd901db14388ba1c555ceec99b241da96bdd55 Mon Sep 17 00:00:00 2001 From: Simon Hung Date: Tue, 29 Oct 2024 13:58:47 +0800 Subject: [PATCH 2/2] docs: update readme --- README.md | 80 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index fb2ddfe..852d7a5 100644 --- a/README.md +++ b/README.md @@ -2,41 +2,6 @@ 通知服務 -# 啟動說明 - -## Quick Start - -```bash -cd app-cloudep-notification-service -go mod tidy -make gen-rpc -# 設定 etc/notification.yml 各依賴的 config -go run notification.go -``` - -## 依賴套件或工具 - -以下已 macOS 為例,若已安裝或有其他可用服務則可跳過 - -- go-zero goctl (https://go-zero.dev/docs/tasks/installation/goctl) - ```bash - $ go install github.com/zeromicro/go-zero/tools/goctl@latest - ``` -- protobuf (https://protobuf.dev/) - ```bash - brew install protobuf - ``` -- etcd (https://etcd.io/) - ```bash - brew install etcd - brew services start etcd - ``` -- SMTP 服務(以 mailhog 為例) (https://github.com/mailhog/MailHog) - ```bash - brew install mailhog - brew services start mailhog - ``` - # 專案架構 ``` @@ -78,3 +43,48 @@ $tree -L 3 --gitignore │ └── smtp.go └── notification.go # 服務主入口 ``` + +# 啟動說明 + +此文件會介紹以下兩種啟動方式: + +1. Docker 啟動 (Production 時使用) +2. 本地端 go compiler 啟動 (開發、測試時使用) + +## Docker 啟動 (Production) + +```bash +make build-docker +make run-docker +``` + +## 本地端啟動(測試用) + +```bash +go mod tidy +# 進入 etc/notification.yml 設定各依賴的 config +go run notification.go +``` + +### 本地啟動需要依賴套件或工具 + +以下已 macOS 為例,若已安裝或有其他可用服務則可跳過 + +- go-zero goctl (https://go-zero.dev/docs/tasks/installation/goctl) + ```bash + $ go install github.com/zeromicro/go-zero/tools/goctl@latest + ``` +- protobuf (https://protobuf.dev/) + ```bash + brew install protobuf + ``` +- etcd (https://etcd.io/) + ```bash + brew install etcd + brew services start etcd + ``` +- SMTP 服務(以 mailhog 為例) (https://github.com/mailhog/MailHog) + ```bash + brew install mailhog + brew services start mailhog + ``` -- 2.40.1