Documentation ¶
Index ¶
- Constants
- Variables
- func MakeFutureRespAsyncRet(fs *Futures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRet)
- func MakeFutureRespAsyncRetT[T any](fs *Futures, 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 Deduplicator
- type Future
- type Futures
- 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]) All(fun generic.Func1[T, bool]) (ret bool)
- func (ls *LockedSlice[T]) Any(fun generic.Func1[T, bool]) (ret bool)
- func (ls *LockedSlice[T]) AnySorted(target T, fun generic.Func2[T, T, int]) (ret bool)
- func (ls *LockedSlice[T]) Append(values ...T)
- func (ls *LockedSlice[T]) AppendSorted(fun generic.Func2[T, T, int], values ...T)
- func (ls *LockedSlice[T]) AppendStableSorted(fun generic.Func2[T, T, int], values ...T)
- func (ls *LockedSlice[T]) Delete(fun generic.Func1[T, bool])
- func (ls *LockedSlice[T]) DeleteOnce(fun generic.Func1[T, bool])
- func (ls *LockedSlice[T]) DeleteOnceSorted(target T, fun generic.Func2[T, T, int])
- func (ls *LockedSlice[T]) Each(fun generic.Action1[T])
- func (ls *LockedSlice[T]) Filter(fun generic.Func1[T, bool]) (ret []T)
- func (ls *LockedSlice[T]) FilterNot(fun generic.Func1[T, bool]) (ret []T)
- func (ls *LockedSlice[T]) Len() (l int)
- func (ls *LockedSlice[T]) Prepend(values ...T)
- func (ls *LockedSlice[T]) Range(fun generic.Func1[T, bool])
- func (ls *LockedSlice[T]) Shuffle()
- func (ls *LockedSlice[T]) Sort(fun generic.Func2[T, T, int])
- func (ls *LockedSlice[T]) SortStable(fun generic.Func2[T, T, int])
- 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 *Futures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRet)
MakeFutureRespAsyncRet 创建future与接收响应返回值的异步调用结果
func MakeFutureRespAsyncRetT ¶
func MakeFutureRespAsyncRetT[T any](fs *Futures, ctx context.Context, timeout ...time.Duration) (Future, RespAsyncRetT[T])
MakeFutureRespAsyncRetT 创建future与接收响应返回值的异步调用结果
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
func NewCache ¶
func NewCache[K comparable, V any]() *Cache[K, V]
func (*Cache[K, V]) RefreshTTL ¶
func (c *Cache[K, V]) RefreshTTL(k K)
func (*Cache[K, V]) Snapshot ¶
func (c *Cache[K, V]) Snapshot() generic.UnorderedSliceMap[K, V]
type Deduplicator ¶ added in v0.2.39
type Deduplicator struct {
// contains filtered or unexported fields
}
Deduplicator 去重器,用于保持幂等性
func (*Deduplicator) Remove ¶ added in v0.2.39
func (d *Deduplicator) Remove(remote string)
Remove 删除对端
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 {
// contains filtered or unexported fields
}
Futures Future控制器
func NewFutures ¶ added in v0.2.39
NewFutures 创建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]) All ¶ added in v0.2.43
func (ls *LockedSlice[T]) All(fun generic.Func1[T, bool]) (ret bool)
func (*LockedSlice[T]) Any ¶ added in v0.2.43
func (ls *LockedSlice[T]) Any(fun generic.Func1[T, bool]) (ret bool)
func (*LockedSlice[T]) AnySorted ¶ added in v0.2.45
func (ls *LockedSlice[T]) AnySorted(target T, fun generic.Func2[T, T, int]) (ret bool)
func (*LockedSlice[T]) Append ¶
func (ls *LockedSlice[T]) Append(values ...T)
func (*LockedSlice[T]) AppendSorted ¶ added in v0.2.45
func (ls *LockedSlice[T]) AppendSorted(fun generic.Func2[T, T, int], values ...T)
func (*LockedSlice[T]) AppendStableSorted ¶ added in v0.2.45
func (ls *LockedSlice[T]) AppendStableSorted(fun generic.Func2[T, T, int], values ...T)
func (*LockedSlice[T]) DeleteOnce ¶ added in v0.2.45
func (ls *LockedSlice[T]) DeleteOnce(fun generic.Func1[T, bool])
func (*LockedSlice[T]) DeleteOnceSorted ¶ added in v0.2.45
func (ls *LockedSlice[T]) DeleteOnceSorted(target T, fun generic.Func2[T, T, int])
func (*LockedSlice[T]) Each ¶
func (ls *LockedSlice[T]) Each(fun generic.Action1[T])
func (*LockedSlice[T]) Filter ¶ added in v0.2.43
func (ls *LockedSlice[T]) Filter(fun generic.Func1[T, bool]) (ret []T)
func (*LockedSlice[T]) FilterNot ¶ added in v0.2.43
func (ls *LockedSlice[T]) FilterNot(fun generic.Func1[T, bool]) (ret []T)
func (*LockedSlice[T]) Len ¶
func (ls *LockedSlice[T]) Len() (l int)
func (*LockedSlice[T]) Prepend ¶ added in v0.2.45
func (ls *LockedSlice[T]) Prepend(values ...T)
func (*LockedSlice[T]) Shuffle ¶ added in v0.2.43
func (ls *LockedSlice[T]) Shuffle()
func (*LockedSlice[T]) Sort ¶ added in v0.2.43
func (ls *LockedSlice[T]) Sort(fun generic.Func2[T, T, int])
func (*LockedSlice[T]) SortStable ¶ added in v0.2.43
func (ls *LockedSlice[T]) SortStable(fun generic.Func2[T, T, int])
type RWLocked ¶
type RWLocked[T any] struct { // contains filtered or unexported fields }
func MakeRWLocked ¶
func NewRWLocked ¶
type RequestHandler ¶
type RespAsyncRet ¶
RespAsyncRet 接收响应返回值的异步调用结果
func (RespAsyncRet) ToAsyncRet ¶ added in v0.1.96
func (ch RespAsyncRet) ToAsyncRet() async.AsyncRet
ToAsyncRet 转换为异步调用结果
type RespAsyncRetT ¶
RespAsyncRetT 接收响应返回值的channel
func MakeRespAsyncRetT ¶
func MakeRespAsyncRetT[T any]() RespAsyncRetT[T]
MakeRespAsyncRetT 创建接收响应返回值的异步调用结果
func (RespAsyncRetT[T]) ToAsyncRetT ¶ added in v0.1.96
func (ch RespAsyncRetT[T]) ToAsyncRetT() async.AsyncRetT[T]
ToAsyncRetT 转换为异步调用结果
type RespDelegate ¶
type RespDelegate[T any] generic.DelegateVoid1[async.RetT[T]]
RespDelegate 接收响应返回值的委托
Click to show internal directories.
Click to hide internal directories.