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

register add depEnv to metadata #346

Merged
merged 2 commits into from
Jun 29, 2023
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
2 changes: 2 additions & 0 deletions core/constant/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ const (
// EgoDefaultConfigExt defines default config file extension, support ".toml",".yaml",".json",
// EgoDefaultConfigExt effective only the configuration file path without extension name
EgoDefaultConfigExt = "EGO_DEFAULT_CONFIG_EXT"
// EgoDeploymentEnv defines deployment environment, such as "k8s", "ecs"
EgoDeploymentEnv = "EGO_DEPLOYMENT_ENV"
)
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"reflect"

"github.com/gotomicro/ego/core/constant"
Expand Down Expand Up @@ -164,5 +165,6 @@ func defaultServiceInfo() ServiceInfo {
si.Metadata["buildTime"] = eapp.BuildTime()
si.Metadata["appVersion"] = eapp.AppVersion()
si.Metadata["egoVersion"] = eapp.EgoVersion()
si.Metadata["depEnv"] = os.Getenv(constant.EgoDeploymentEnv) // 部署环境
return si
}
1 change: 1 addition & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestServiceInfo(t *testing.T) {
"buildTime": "",
"egoVersion": "unknown version",
"key": "val",
"depEnv": "",
"startTime": xtime.TS.Format(time.Now()),
},
},
Expand Down