1 Star 0 Fork 0

李文建/protoactor-go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
supervision.go 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Potter Dai 提交于 2019-02-01 15:09 +08:00 . Double quote comments.
package actor
import (
"time"
"github.com/AsynkronIT/protoactor-go/eventstream"
)
// DeciderFunc is a function which is called by a SupervisorStrategy
type DeciderFunc func(reason interface{}) Directive
// SupervisorStrategy is an interface that decides how to handle failing child actors
type SupervisorStrategy interface {
HandleFailure(supervisor Supervisor, child *PID, rs *RestartStatistics, reason interface{}, message interface{})
}
// Supervisor is an interface that is used by the SupervisorStrategy to manage child actor lifecycle
type Supervisor interface {
Children() []*PID
EscalateFailure(reason interface{}, message interface{})
RestartChildren(pids ...*PID)
StopChildren(pids ...*PID)
ResumeChildren(pids ...*PID)
}
func logFailure(child *PID, reason interface{}, directive Directive) {
eventstream.Publish(&SupervisorEvent{
Child: child,
Reason: reason,
Directive: directive,
})
}
// DefaultDecider is a decider that will always restart the failing child actor
func DefaultDecider(_ interface{}) Directive {
return RestartDirective
}
var (
defaultSupervisionStrategy = NewOneForOneStrategy(10, 10*time.Second, DefaultDecider)
restartingSupervisionStrategy = NewRestartingStrategy()
)
func DefaultSupervisorStrategy() SupervisorStrategy {
return defaultSupervisionStrategy
}
func RestartingSupervisorStrategy() SupervisorStrategy {
return restartingSupervisionStrategy
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lwj8507/protoactor-go.git
git@gitee.com:lwj8507/protoactor-go.git
lwj8507
protoactor-go
protoactor-go
v0.0.1

搜索帮助