Documentation
¶
Overview ¶
Package lifecycle 提供与产品、账号和传输协议无关的资源生命周期。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNilContext 表示调用方没有提供 context。 ErrNilContext = errors.New("lifecycle: context is nil") // ErrNilOpen 表示调用方没有提供资源打开函数。 ErrNilOpen = errors.New("lifecycle: open function is nil") // ErrNilUse 表示调用方没有提供资源使用函数。 ErrNilUse = errors.New("lifecycle: use function is nil") // ErrNilLease 表示打开函数成功但没有返回 Lease。 ErrNilLease = errors.New("lifecycle: open function returned a nil lease") )
Functions ¶
Types ¶
type Attempt ¶
type Attempt struct {
// contains filtered or unexported fields
}
Attempt 标记一次资源使用是否已经越过可重放边界。 state 只允许从 0 到 1,Commit 幂等且不会回退。
type Lease ¶
type Lease[T any] struct { // contains filtered or unexported fields }
Lease 持有一个需要在使用后释放的资源。
Lease 只能通过 NewLease 创建;Close 可以被重复调用,底层释放函数最多 执行一次,所有调用都会得到同一个释放错误。
Click to show internal directories.
Click to hide internal directories.