Documentation ¶
Index ¶
- Variables
- func MakeFutureRespAsyncRet(fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRet)
- func MakeFutureRespChan[T any](fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespChan[T])
- type Deduplication
- type Future
- type Futures
- type IDeduplication
- type IFutures
- type IMapEachElement
- type ISliceEachElement
- type Locked
- type LockedMap
- type LockedSlice
- type RWLocked
- type Reply
- type RequestHandler
- type Resp
- type RespAsyncRet
- type RespChan
- type RespDelegate
- type RespFunc
- type Ret
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFuturesClosed = errors.New("futures already closed") // Future控制器已关闭 ErrFutureNotFound = errors.New("future not found") // Future未找到 ErrFutureCanceled = errors.New("future canceled") // Future被取消 ErrFutureTimeout = errors.New("future timeout") // Future超时 ErrFutureRespIncorrectType = errors.New("future response has incorrect value type") // Future响应的返回值类型错误 ErrFutureReplyClosed = errors.New("future reply closed") // Future答复已关闭 )
Functions ¶
func MakeFutureRespAsyncRet ¶
func MakeFutureRespAsyncRet(fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRet)
MakeFutureRespAsyncRet 创建future与接收响应返回值的异步调用结果
Types ¶
type Deduplication ¶
type Deduplication struct {
// contains filtered or unexported fields
}
Deduplication 去重器,用于保持幂等性
func (*Deduplication) ValidateSeq ¶
func (d *Deduplication) ValidateSeq(remote string, seq int64) (passed bool)
ValidateSeq 验证序号
type Future ¶
type Future struct { Finish context.Context // 上下文 Id int64 // Id // contains filtered or unexported fields }
Future 异步模型Future
func MakeFuture ¶
MakeFuture 创建Future
type Futures ¶
type Futures struct { Ctx context.Context // 上下文 Id int64 // 请求id生成器 Timeout time.Duration // 请求超时时间 // contains filtered or unexported fields }
Futures Future控制器
func MakeFutures ¶
MakeFutures 创建Future控制器
type IDeduplication ¶
type IDeduplication interface { // MakeSeq 创建序号 MakeSeq() int64 // ValidateSeq 验证序号 ValidateSeq(remote string, seq int64) bool // Remove 删除对端 Remove(remote string) }
IDeduplication 去重器接口
type IFutures ¶
type IFutures interface { // Make 创建Future Make(ctx context.Context, resp Resp, timeout ...time.Duration) Future // Request 请求 Request(ctx context.Context, handler RequestHandler, timeout ...time.Duration) runtime.AsyncRet // Resolve 解决 Resolve(id int64, ret Ret[any]) error // contains filtered or unexported methods }
IFutures Future控制器接口
type IMapEachElement ¶ added in v0.1.32
type IMapEachElement[K comparable, V any] interface { Each(fun generic.Action2[K, V]) }
type ISliceEachElement ¶ added in v0.1.32
type Locked ¶
type Locked[T any] struct { // contains filtered or unexported fields }
func MakeLocked ¶
type LockedMap ¶
type LockedMap[K comparable, V any] struct { RWLocked[map[K]V] }
func MakeLockedMap ¶
func MakeLockedMap[K comparable, V any](size int) LockedMap[K, V]
func NewLockedMap ¶
func NewLockedMap[K comparable, V any](size int) *LockedMap[K, V]
type LockedSlice ¶
func MakeLockedSlice ¶
func MakeLockedSlice[T any](len, cap int) LockedSlice[T]
func NewLockedSlice ¶
func NewLockedSlice[T any](len, cap int) *LockedSlice[T]
func (*LockedSlice[T]) Append ¶
func (ls *LockedSlice[T]) Append(values ...T)
func (*LockedSlice[T]) Delete ¶
func (ls *LockedSlice[T]) Delete(idx ...int)
func (*LockedSlice[T]) Each ¶ added in v0.1.32
func (ls *LockedSlice[T]) Each(fun generic.Action1[T])
func (*LockedSlice[T]) Insert ¶
func (ls *LockedSlice[T]) Insert(idx int, values ...T)
func (*LockedSlice[T]) Len ¶
func (ls *LockedSlice[T]) Len() (l int)
type RWLocked ¶
type RWLocked[T any] struct { // contains filtered or unexported fields }
func MakeRWLocked ¶
func NewRWLocked ¶
type RequestHandler ¶
type RespAsyncRet ¶
RespAsyncRet 接收响应返回值的异步调用结果
func (RespAsyncRet) CastAsyncRet ¶
func (resp RespAsyncRet) CastAsyncRet() runtime.AsyncRet
CastAsyncRet 转换为异步调用结果
type RespDelegate ¶
type RespDelegate[T any] generic.DelegateAction1[Ret[T]]
RespDelegate 接收响应返回值的委托
Click to show internal directories.
Click to hide internal directories.