feat: add im kafka admin integration
This commit is contained in:
@@ -10,10 +10,13 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
BaseUrl string `json:"baseUrl"`
|
||||
ServiceId string `json:"serviceId"`
|
||||
ServiceSecret string `json:"serviceSecret"`
|
||||
Timeout time.Duration `json:"timeout"`
|
||||
BaseUrl string `json:"baseUrl"`
|
||||
ServiceId string `json:"serviceId"`
|
||||
ServiceSecret string `json:"serviceSecret"`
|
||||
Timeout time.Duration `json:"timeout"`
|
||||
InternalBaseUrl string `json:"internalBaseUrl"`
|
||||
InternalServiceName string `json:"internalServiceName"`
|
||||
InternalServiceSecret string `json:"internalServiceSecret"`
|
||||
}
|
||||
|
||||
func LoadConfig(ctx context.Context) Config {
|
||||
@@ -28,10 +31,25 @@ func LoadConfig(ctx context.Context) Config {
|
||||
if serviceSecret == "" {
|
||||
serviceSecret = os.Getenv("IM_ADMIN_API_SECRET")
|
||||
}
|
||||
internalSecret := g.Cfg().MustGet(ctx, "imInternalApi.serviceSecret").String()
|
||||
if strings.HasPrefix(internalSecret, "${") && strings.HasSuffix(internalSecret, "}") {
|
||||
internalSecret = os.Getenv(strings.TrimSuffix(strings.TrimPrefix(internalSecret, "${"), "}"))
|
||||
}
|
||||
if internalSecret == "" {
|
||||
internalSecret = os.Getenv("IM_INTERNAL_API_SECRET")
|
||||
}
|
||||
if internalSecret == "" {
|
||||
internalSecret = serviceSecret
|
||||
}
|
||||
baseUrl := g.Cfg().MustGet(ctx, "imAdminApi.baseUrl").String()
|
||||
serviceId := g.Cfg().MustGet(ctx, "imAdminApi.serviceId", "hotgo-admin").String()
|
||||
return Config{
|
||||
BaseUrl: g.Cfg().MustGet(ctx, "imAdminApi.baseUrl").String(),
|
||||
ServiceId: g.Cfg().MustGet(ctx, "imAdminApi.serviceId", "hotgo-admin").String(),
|
||||
ServiceSecret: serviceSecret,
|
||||
Timeout: timeout,
|
||||
BaseUrl: baseUrl,
|
||||
ServiceId: serviceId,
|
||||
ServiceSecret: serviceSecret,
|
||||
Timeout: timeout,
|
||||
InternalBaseUrl: g.Cfg().MustGet(ctx, "imInternalApi.baseUrl", baseUrl).String(),
|
||||
InternalServiceName: g.Cfg().MustGet(ctx, "imInternalApi.serviceName", serviceId).String(),
|
||||
InternalServiceSecret: internalSecret,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user