Documentation ¶
Index ¶
- Constants
- Variables
- func MakeFutureRespAsyncRet(fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRet)
- func MakeFutureRespAsyncRetT[T any](fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRetT[T])
- type Cache
- func (c *Cache[K, V]) AutoClean(ctx context.Context, interval time.Duration, num int)
- func (c *Cache[K, V]) Clean(num int)
- func (c *Cache[K, V]) Del(k K, revision int64)
- func (c *Cache[K, V]) Get(k K) (V, bool)
- func (c *Cache[K, V]) OnAdd(cb generic.Action2[K, V])
- func (c *Cache[K, V]) OnDel(cb generic.Action2[K, V])
- func (c *Cache[K, V]) RefreshTTL(k K)
- func (c *Cache[K, V]) Set(k K, v V, revision int64, ttl time.Duration) V
- func (c *Cache[K, V]) Snapshot() generic.UnorderedSliceMap[K, V]
- type Deduplication
- type Future
- type Futures
- type IDeduplication
- type IFutures
- type Locked
- type LockedMap
- func (lm *LockedMap[K, V]) Add(k K, v V)
- func (lm *LockedMap[K, V]) Delete(k K)
- func (lm *LockedMap[K, V]) Each(fun generic.Action2[K, V])
- func (lm *LockedMap[K, V]) Exist(k K) (b bool)
- func (lm *LockedMap[K, V]) Get(k K) (v V, ok bool)
- func (lm *LockedMap[K, V]) Len() (l int)
- func (lm *LockedMap[K, V]) Range(fun generic.Func2[K, V, bool])
- func (lm *LockedMap[K, V]) TryAdd(k K, v V)
- func (lm *LockedMap[K, V]) Value(k K) (v V)
- type LockedSlice
- func (ls *LockedSlice[T]) Append(values ...T)
- func (ls *LockedSlice[T]) Delete(idx ...int)
- func (ls *LockedSlice[T]) Each(fun generic.Action1[T])
- func (ls *LockedSlice[T]) Insert(idx int, values ...T)
- func (ls *LockedSlice[T]) Len() (l int)
- func (ls *LockedSlice[T]) Range(fun generic.Func1[T, bool])
- type RWLocked
- type RequestHandler
- type Resp
- type RespAsyncRet
- type RespAsyncRetT
- type RespDelegate
- type RespFunc
Constants ¶
View Source
const ( CacheDefaultCleanNum = 64 CacheDefaultCleanInterval = 30 * time.Second )
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响应的返回值类型错误 )
Functions ¶
func MakeFutureRespAsyncRet ¶
func MakeFutureRespAsyncRet(fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRet)
MakeFutureRespAsyncRet 创建future与接收响应返回值的异步调用结果
func MakeFutureRespAsyncRetT ¶ added in v0.1.77
func MakeFutureRespAsyncRetT[T any](fs IFutures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRetT[T])
MakeFutureRespAsyncRetT 创建future与接收响应返回值的异步调用结果
Types ¶
type Cache ¶ added in v0.1.93
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
func NewCache ¶ added in v0.1.93
func NewCache[K comparable, V any]() *Cache[K, V]
func (*Cache[K, V]) RefreshTTL ¶ added in v0.1.93
func (c *Cache[K, V]) RefreshTTL(k K)
func (*Cache[K, V]) Snapshot ¶ added in v0.1.93
func (c *Cache[K, V]) Snapshot() generic.UnorderedSliceMap[K, V]
type Deduplication ¶
type Deduplication struct {
// contains filtered or unexported fields
}
Deduplication 去重器,用于保持幂等性
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 { // Make 创建序号 Make() int64 // Validate 验证序号 Validate(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) async.AsyncRet // Resolve 解决 Resolve(id int64, ret async.Ret) error // contains filtered or unexported methods }
IFutures Future控制器接口
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 (ch RespAsyncRet) CastAsyncRet() async.AsyncRet
CastAsyncRet 转换为异步调用结果
type RespAsyncRetT ¶ added in v0.1.77
RespAsyncRetT 接收响应返回值的channel
func MakeRespAsyncRetT ¶ added in v0.1.77
func MakeRespAsyncRetT[T any]() RespAsyncRetT[T]
MakeRespAsyncRetT 创建接收响应返回值的异步调用结果
func (RespAsyncRetT[T]) CastAsyncRetT ¶ added in v0.1.77
func (ch RespAsyncRetT[T]) CastAsyncRetT() async.AsyncRetT[T]
CastAsyncRetT 转换为异步调用结果
type RespDelegate ¶
type RespDelegate[T any] generic.DelegateAction1[async.RetT[T]]
RespDelegate 接收响应返回值的委托
Click to show internal directories.
Click to hide internal directories.