代码拉取完成,页面将自动刷新
package actor
import (
"log/slog"
"net"
"strconv"
"gitee.com/wujianhai/protoactor-go/eventstream"
"gitee.com/wujianhai/protoactor-go/extensions"
"github.com/lithammer/shortuuid/v4"
)
//goland:noinspection GoNameStartsWithPackageName
type ActorSystem struct {
ProcessRegistry *ProcessRegistryValue
Root *RootContext
EventStream *eventstream.EventStream
Guardians *guardiansValue
DeadLetter *deadLetterProcess
Extensions *extensions.Extensions
Config *Config
ID string
stopper chan struct{}
logger *slog.Logger
}
func (as *ActorSystem) Logger() *slog.Logger {
return as.logger
}
func (as *ActorSystem) NewLocalPID(id string) *PID {
return NewPID(as.ProcessRegistry.Address, id)
}
func (as *ActorSystem) Address() string {
return as.ProcessRegistry.Address
}
func (as *ActorSystem) GetHostPort() (host string, port int, err error) {
addr := as.ProcessRegistry.Address
if h, p, e := net.SplitHostPort(addr); e != nil {
if addr != localAddress {
err = e
}
host = localAddress
port = -1
} else {
host = h
port, err = strconv.Atoi(p)
}
return
}
func (as *ActorSystem) Shutdown() {
close(as.stopper)
}
func (as *ActorSystem) IsStopped() bool {
select {
case <-as.stopper:
return true
default:
return false
}
}
func NewActorSystem(options ...ConfigOption) *ActorSystem {
config := Configure(options...)
return NewActorSystemWithConfig(config)
}
func NewActorSystemWithConfig(config *Config) *ActorSystem {
system := &ActorSystem{}
system.ID = shortuuid.New()
system.Config = config
system.logger = config.LoggerFactory(system)
system.ProcessRegistry = NewProcessRegistry(system)
system.Root = NewRootContext(system, EmptyMessageHeader)
system.Guardians = NewGuardians(system)
system.EventStream = eventstream.NewEventStream()
system.DeadLetter = NewDeadLetter(system)
system.Extensions = extensions.NewExtensions()
SubscribeSupervision(system)
system.Extensions.Register(NewMetrics(system, config.MetricsProvider))
system.ProcessRegistry.Add(NewEventStreamProcess(system), "eventstream")
system.stopper = make(chan struct{})
system.Logger().Info("actor system started", slog.String("id", system.ID))
return system
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。