ICommand增加配置方法,支持覆盖全局配置
This commit is contained in:
46
config/command.go
Normal file
46
config/command.go
Normal file
@ -0,0 +1,46 @@
|
||||
// Package config ...
|
||||
//
|
||||
// Description : WS-Command 相关配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 2021-04-17 2:34 下午
|
||||
package config
|
||||
|
||||
// commandConfig 指令相关配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 2:36 下午 2021/4/17
|
||||
type CommandConfig struct {
|
||||
PushMessageWithError bool // 当调度指令时,指令执行错误,是否想客户端推送错误消息
|
||||
}
|
||||
|
||||
// SetCommandConfig 设置command配置
|
||||
type SetCommandConfig func(cc *CommandConfig)
|
||||
|
||||
// ClosePushCommandErrorMessage 关闭指令执行异常时的消息推送
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 2:51 下午 2021/4/17
|
||||
func ClosePushCommandErrorMessage() SetCommandConfig {
|
||||
return func(cc *CommandConfig) {
|
||||
cc.PushMessageWithError = false
|
||||
}
|
||||
}
|
||||
|
||||
// NewCommandConfig 指令的配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 2:39 下午 2021/4/17
|
||||
func NewCommandConfig(optionFunc ...SetCommandConfig) *CommandConfig {
|
||||
cc := &CommandConfig{
|
||||
PushMessageWithError: true, // 默认推送异常消息
|
||||
}
|
||||
for _, o := range optionFunc {
|
||||
o(cc)
|
||||
}
|
||||
return cc
|
||||
}
|
8
config/server.go
Normal file
8
config/server.go
Normal file
@ -0,0 +1,8 @@
|
||||
// Package config ...
|
||||
//
|
||||
// Description : WS-Server 相关配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 2021-04-17 2:32 下午
|
||||
package config
|
Reference in New Issue
Block a user