Documentation
¶
Overview ¶
Package goroutine provides goroutine safety utilities for gorp framework. This file provides logger extraction helper from container. Used by SafeGo for unified panic recovery logging.
Goroutine 包提供 gorp 框架的 goroutine 安全工具能力。 本文件提供从容器获取 logger 的 helper。 用于 SafeGo 统一 panic 恢复日志记录。
Package goroutine provides goroutine safety utilities for gorp framework. This file provides SafeGo for panic recovery in goroutines. Prevents panic from crashing the entire process, logs errors instead.
Goroutine 包提供 gorp 框架的 goroutine 安全工具能力。 本文件提供 SafeGo 用于 goroutine 中的 panic 恢复。 防止 panic 把整个进程直接打崩,而是尽量记录到统一 logger。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerFromContainer ¶
func LoggerFromContainer(c runtimecontract.Container) observabilitycontract.Logger
LoggerFromContainer tries to get framework logger.
func SafeGo ¶
SafeGo 在新的 goroutine 中执行 fn,并统一 recover panic 后记录日志。
中文说明: - 它适合替代直接 `go fn()` 的裸调用方式。 - 当子 goroutine panic 时,错误不会把整个进程直接打崩,而是尽量记录到统一 logger。
func SafeGoAndWait ¶
func SafeGoAndWait(ctx context.Context, c runtimecontract.Container, fns ...func(context.Context) error) error
SafeGoAndWait runs multiple functions concurrently.
- Each function gets a derived context. - Panic is recovered and returned as an error. - The first returned error is returned.
Types ¶
This section is empty.