1 Star 0 Fork 0

jack/protoactor-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config_opts.go 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
490689386@qq.com 提交于 2025-05-19 14:50 +08:00 . 初始化
package actor
import (
"log/slog"
"time"
"go.opentelemetry.io/otel/metric"
)
// ConfigOption is a function that configures the actor system
type ConfigOption func(config *Config)
// Configure sets the configuration options
func Configure(options ...ConfigOption) *Config {
config := defaultConfig()
for _, option := range options {
option(config)
}
return config
}
// WithDeadLetterThrottleInterval sets the dead letter throttle interval
func WithDeadLetterThrottleInterval(duration time.Duration) ConfigOption {
return func(config *Config) {
config.DeadLetterThrottleInterval = duration
}
}
// WithDeadLetterThrottleCount sets the dead letter throttle count
func WithDeadLetterThrottleCount(count int32) ConfigOption {
return func(config *Config) {
config.DeadLetterThrottleCount = count
}
}
// WithDeadLetterRequestLogging sets the dead letter request logging on or off
func WithDeadLetterRequestLogging(enabled bool) ConfigOption {
return func(config *Config) {
config.DeadLetterRequestLogging = enabled
}
}
// WithDeveloperSupervisionLogging sets the developer supervision logging on or off
func WithDeveloperSupervisionLogging(enabled bool) ConfigOption {
return func(config *Config) {
config.DeveloperSupervisionLogging = enabled
}
}
// WithDiagnosticsSerializer sets the diagnostics serializer
func WithDiagnosticsSerializer(serializer func(Actor) string) ConfigOption {
return func(config *Config) {
config.DiagnosticsSerializer = serializer
}
}
// WithMetricProviders sets the metric providers
func WithMetricProviders(provider metric.MeterProvider) ConfigOption {
return func(config *Config) {
config.MetricsProvider = provider
}
}
// WithDefaultPrometheusProvider sets the default prometheus provider
func WithDefaultPrometheusProvider(port ...int) ConfigOption {
_port := 2222
if len(port) > 0 {
_port = port[0]
}
return WithMetricProviders(defaultPrometheusProvider(_port))
}
// WithLoggerFactory sets the logger factory to use for the actor system
func WithLoggerFactory(factory func(system *ActorSystem) *slog.Logger) ConfigOption {
return func(config *Config) {
config.LoggerFactory = factory
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wujianhai/protoactor-go.git
git@gitee.com:wujianhai/protoactor-go.git
wujianhai
protoactor-go
protoactor-go
5633fe2499dd

搜索帮助