init repo

This commit is contained in:
2026-10-20 18:53:09 +08:00
commit 466b0ea05d
13 changed files with 1877 additions and 0 deletions

27
invoker.go Normal file
View File

@@ -0,0 +1,27 @@
package actor
import "runtime/debug"
type invoker[T any] struct {
handler func(T)
onPanic func(T, any, []byte)
}
func (i *invoker[T]) receive(message T) {
completed := false
defer func() {
if !completed {
value := recover()
if i.onPanic != nil {
i.reportPanic(message, value, debug.Stack())
}
}
}()
i.handler(message)
completed = true
}
func (i *invoker[T]) reportPanic(message T, value any, stack []byte) {
defer func() { _ = recover() }()
i.onPanic(message, value, stack)
}