Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
40 lines
754 B
Go
40 lines
754 B
Go
package core_test
|
|
|
|
|
|
import (
|
|
. "forge.lthn.ai/core/go/pkg/core"
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkMessageBus_Action(b *testing.B) {
|
|
c, _ := New()
|
|
c.RegisterAction(func(c *Core, msg Message) error {
|
|
return nil
|
|
})
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
_ = c.ACTION("test")
|
|
}
|
|
}
|
|
|
|
func BenchmarkMessageBus_Query(b *testing.B) {
|
|
c, _ := New()
|
|
c.RegisterQuery(func(c *Core, q Query) (any, bool, error) {
|
|
return "result", true, nil
|
|
})
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
_, _, _ = c.QUERY("test")
|
|
}
|
|
}
|
|
|
|
func BenchmarkMessageBus_Perform(b *testing.B) {
|
|
c, _ := New()
|
|
c.RegisterTask(func(c *Core, t Task) (any, bool, error) {
|
|
return "result", true, nil
|
|
})
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
_, _, _ = c.PERFORM("test")
|
|
}
|
|
}
|