Documentation
¶
Index ¶
- type DataSlot
- type FlowContext
- func (c *FlowContext) Cancel(err error)
- func (c *FlowContext) Done() <-chan struct{}
- func (c *FlowContext) Err() error
- func (c *FlowContext) Get(key string) (any, error)
- func (c *FlowContext) GetContext() context.Context
- func (c *FlowContext) GetError() error
- func (c *FlowContext) IsReady(key string) bool
- func (c *FlowContext) Set(key string, value any)
- func (c *FlowContext) SetError(err error) error
- func (c *FlowContext) SetOnce(key string, value any)
- func (c *FlowContext) SetOrUpdate(key string, value any)
- func (c *FlowContext) TryGet(key string) (any, bool)
- func (c *FlowContext) Wait(key string) (any, error)
- func (c *FlowContext) WaitAll(keys ...string) (map[string]any, error)
- func (c *FlowContext) WaitAllWithContext(ctx context.Context, keys ...string) (map[string]any, error)
- func (c *FlowContext) WaitForAny(keys ...string) (string, any, error)
- func (c *FlowContext) WaitWithContext(ctx context.Context, key string) (any, error)
- type SafeMap
- func (s *SafeMap[K, V]) Clear()
- func (s *SafeMap[K, V]) Delete(key K)
- func (s *SafeMap[K, V]) Exist(key K) bool
- func (s *SafeMap[K, V]) Get(key K) (V, bool)
- func (s *SafeMap[K, V]) GetOrSet(key K, createFn func() V) V
- func (s *SafeMap[K, V]) MustGet(key K) V
- func (s *SafeMap[K, V]) Range(fn func(key K, value V) bool)
- func (s *SafeMap[K, V]) Set(key K, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataSlot ¶
type DataSlot struct {
// contains filtered or unexported fields
}
DataSlot 数据槽 作用:存储一个值,支持多协程等待、多订阅、重复读取、广播唤醒 一个值生成后,所有节点都能获取
func NewDataSlot ¶
func NewDataSlot() *DataSlot
func (*DataSlot) SetOrUpdate ¶
SetOrUpdate 写入或更新值(始终覆盖,唤醒等待者) 适用于:ReAct 重规划时更新计划、状态变更等场景 注意:更新时会再次 Broadcast,确保新等待者能获取最新值
type FlowContext ¶
type FlowContext struct {
// contains filtered or unexported fields
}
func NewFlowContext ¶
func NewFlowContext(ctx context.Context) *FlowContext
func (*FlowContext) GetContext ¶
func (c *FlowContext) GetContext() context.Context
func (*FlowContext) SetOrUpdate ¶
func (c *FlowContext) SetOrUpdate(key string, value any)
SetOrUpdate 放入或更新数据(始终覆盖)
func (*FlowContext) WaitAll ¶
func (c *FlowContext) WaitAll(keys ...string) (map[string]any, error)
WaitAll 等待多个数据全部就绪
func (*FlowContext) WaitAllWithContext ¶
func (c *FlowContext) WaitAllWithContext(ctx context.Context, keys ...string) (map[string]any, error)
WaitAllWithContext 使用指定 context 等待多个数据全部就绪
func (*FlowContext) WaitForAny ¶
func (c *FlowContext) WaitForAny(keys ...string) (string, any, error)
WaitForAny 等待多个 key 中任意一个就绪 基于 done channel + reflect.Select,零轮询
func (*FlowContext) WaitWithContext ¶
WaitWithContext 使用指定 context 等待数据就绪 用于切面级超时控制:传入切面的 context 而非工作流的 context
type SafeMap ¶
type SafeMap[K comparable, V any] struct { // contains filtered or unexported fields }
SafeMap 泛型并发安全 Map K: 键类型(必须可比较) V: 值类型(任意)
func (*SafeMap[K, V]) GetOrSet ¶
func (s *SafeMap[K, V]) GetOrSet(key K, createFn func() V) V
GetOrSet 原子的「获取或创建」 已存在则返回已有值,不存在则调用 createFn 创建后存入
Click to show internal directories.
Click to hide internal directories.