You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngs/component/options.go

35 lines
795 B
Go

3 years ago
package component
type (
options struct {
name string // component name
nameFunc func(string) string // rename handler name
schedulerName string // schedulerName name
}
// Option used to customize handler
Option func(options *options)
)
// WithName used to rename component name
func WithName(name string) Option {
return func(opt *options) {
opt.name = name
}
}
// WithNameFunc override handler name by specific function
// such as: strings.ToUpper/strings.ToLower
func WithNameFunc(fn func(string) string) Option {
return func(opt *options) {
opt.nameFunc = fn
}
}
// WithSchedulerName set the name of the service scheduler
func WithSchedulerName(name string) Option {
return func(opt *options) {
opt.schedulerName = name
}
}