feat(extension): pass namespace and pool config

This commit is contained in:
iyear 2024-11-23 14:42:01 +08:00
parent eee2d1c546
commit 20aec50413
2 changed files with 30 additions and 22 deletions

View File

@ -126,9 +126,11 @@ func NewExtensionCmd(em *extensions.Manager, ext extensions.Extension, stdin io.
AppID: app.AppID,
AppHash: app.AppHash,
Session: session,
Namespace: viper.GetString(consts.FlagNamespace),
DataDir: dataDir,
NTP: opts.NTP,
Proxy: opts.Proxy,
Pool: viper.GetInt64(consts.FlagPoolSize),
Debug: viper.GetBool(consts.FlagDebug),
}

View File

@ -22,12 +22,14 @@ const EnvKey = "TDL_EXTENSION"
type Env struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
AppID int `json:"app_id"`
AppHash string `json:"app_hash"`
Session []byte `json:"session"`
DataDir string `json:"data_dir"`
NTP string `json:"ntp"`
Proxy string `json:"proxy"`
Pool int64 `json:"pool"`
Debug bool `json:"debug"`
}
@ -50,8 +52,10 @@ type Extension struct {
}
type Config struct {
Namespace string // tdl namespace
DataDir string // data directory for extension
Proxy string // proxy URL
Pool int64 // pool size
Debug bool // debug mode enabled
}
@ -136,8 +140,10 @@ func buildExtension(ctx context.Context, o Options) (*Extension, *telegram.Clien
client: client,
log: o.Logger,
config: &Config{
Namespace: env.Namespace,
DataDir: env.DataDir,
Proxy: env.Proxy,
Pool: env.Pool,
Debug: env.Debug,
},
}, client, nil