Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-01-09 15:55:51 * @FilePath: \go-toolbox\pkg\contextx\context.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- func IsContext(ctx context.Context) bool
- type Context
- func MergeContext(ctxs ...context.Context) *Context
- func NewContext(parent context.Context, pool *syncx.LimitedPool) *Context
- func NewContextWithCancel(parent context.Context, pool *syncx.LimitedPool) *Context
- func NewContextWithTimeout(parent context.Context, timeout time.Duration, pool *syncx.LimitedPool) *Context
- func NewContextWithValue(parent context.Context, key, val interface{}, pool *syncx.LimitedPool) (*Context, error)
- func NewLocalContextWithValue(ctx *Context, key, val interface{}) (*Context, error)
- func (c *Context) Cancel()
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Remove(key interface{})
- func (c *Context) Set(key, value interface{}) error
- func (c *Context) String() string
- func (c *Context) Value(key interface{}) interface{}
- func (c *Context) Values() map[interface{}]interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶ added in v0.11.29
Context 是一个自定义的上下文,支持多个值的存储
func MergeContext ¶ added in v0.11.29
MergeContext 合并多个上下文为一个 Context
func NewContext ¶ added in v0.11.29
func NewContext(parent context.Context, pool *syncx.LimitedPool) *Context
NewContext 创建一个新的 Context,允许用户传入自定义的字节切片池
func NewContextWithCancel ¶ added in v0.11.29
func NewContextWithCancel(parent context.Context, pool *syncx.LimitedPool) *Context
NewContextWithCancel 创建一个可以手动取消的 Context
func NewContextWithTimeout ¶ added in v0.11.29
func NewContextWithTimeout(parent context.Context, timeout time.Duration, pool *syncx.LimitedPool) *Context
NewContextWithTimeout 创建一个带有超时的 Context
func NewContextWithValue ¶
func NewContextWithValue(parent context.Context, key, val interface{}, pool *syncx.LimitedPool) (*Context, error)
NewContextWithValue 在父上下文中设置值并返回新的 Context
func NewLocalContextWithValue ¶
NewLocalContextWithValue 在当前 Context 中设置局部值
func (*Context) Remove ¶ added in v0.11.29
func (c *Context) Remove(key interface{})
Remove 删除指定键的键值对
Click to show internal directories.
Click to hide internal directories.