Documentation
¶
Index ¶
- type Kind
- type Option
- type Session
- func (s *Session) AddConn(conn network.Conn)
- func (s *Session) Bind(cid, uid int64) error
- func (s *Session) Broadcast(kind Kind, message []byte) (n int64, err error)
- func (s *Session) Close(kind Kind, target int64, force ...bool) error
- func (s *Session) Has(kind Kind, target int64) (ok bool, err error)
- func (s *Session) LocalAddr(kind Kind, target int64) (net.Addr, error)
- func (s *Session) LocalIP(kind Kind, target int64) (string, error)
- func (s *Session) Multicast(kind Kind, targets []int64, message []byte) (n int64, err error)
- func (s *Session) Publish(channel string, message []byte) (n int64)
- func (s *Session) Push(kind Kind, target int64, message []byte) error
- func (s *Session) RemConn(conn network.Conn)
- func (s *Session) RemoteAddr(kind Kind, target int64) (net.Addr, error)
- func (s *Session) RemoteIP(kind Kind, target int64) (string, error)
- func (s *Session) Send(kind Kind, target int64, message []byte) error
- func (s *Session) Stat(kind Kind) (int64, error)
- func (s *Session) Subscribe(kind Kind, targets []int64, channel string) (err error)
- func (s *Session) Unbind(uid int64) (int64, error)
- func (s *Session) Unsubscribe(kind Kind, targets []int64, channel string) (err error)
- type ShardMap
- func (m *ShardMap[K, V]) Delete(key K)
- func (m *ShardMap[K, V]) Get(key K) (V, bool)
- func (m *ShardMap[K, V]) GetAndDelete(key K) (V, bool)
- func (m *ShardMap[K, V]) GetOrSet(key K, value V) (V, bool)
- func (m *ShardMap[K, V]) Has(key K) bool
- func (m *ShardMap[K, V]) Len() int64
- func (m *ShardMap[K, V]) RangeAll(fn func(key K, value V) bool)
- func (m *ShardMap[K, V]) Set(key K, value V)
- func (m *ShardMap[K, V]) WithShard(key K, fn func(items map[K]V))
- func (m *ShardMap[K, V]) WithShardRLock(key K, fn func(items map[K]V))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session 会话管理器(泛型 ShardMap 分片锁设计) 使用 ShardMap[K,V] 统一分片存储,减少锁竞争
func (*Session) RemoteAddr ¶
RemoteAddr 获取远端地址
type ShardMap ¶ added in v1.0.10
type ShardMap[K comparable, V any] struct { // contains filtered or unexported fields }
ShardMap 通用分片锁 Map,减少锁竞争 使用泛型替代重复的 connShard/userShard/channelShard 实现
func NewInt64ShardMap ¶ added in v1.0.10
NewInt64ShardMap 创建 int64 键的分片锁 Map(常用场景的便捷构造函数)
func NewShardMap ¶ added in v1.0.10
func NewShardMap[K comparable, V any](shardCount int, hasher func(K) uint32) *ShardMap[K, V]
NewShardMap 创建分片锁 Map
func NewStringShardMap ¶ added in v1.0.10
NewStringShardMap 创建 string 键的分片锁 Map(常用场景的便捷构造函数)
func (*ShardMap[K, V]) GetAndDelete ¶ added in v1.0.10
GetAndDelete 获取并删除值(原子操作)
func (*ShardMap[K, V]) WithShard ¶ added in v1.0.10
func (m *ShardMap[K, V]) WithShard(key K, fn func(items map[K]V))
WithShard 在指定键的分片锁保护下执行操作(用于复杂的原子操作)
func (*ShardMap[K, V]) WithShardRLock ¶ added in v1.0.10
func (m *ShardMap[K, V]) WithShardRLock(key K, fn func(items map[K]V))
WithShardRLock 在指定键的分片读锁保护下执行操作
Click to show internal directories.
Click to hide internal directories.