loaders

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package loaders 提供 entitycache.Loader 的具体实现(每实体一个文件)。

每个 Loader 单一职责:

  • 把 entitycache.Loader 接口翻译成对 master 的 sync.fetchEntity RPC 调用
  • 必要时写关联实体的 warm side effect(如 TokenLoader 在 Load 成功时 warm user)
  • Loader 不持有 Store 引用,避免循环依赖;它持有具体的关联 EntityCache 引用即可

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateChannelsVisibleLoader added in v0.0.2

type PrivateChannelsVisibleLoader struct {
	Client app.WSClient
}

PrivateChannelsVisibleLoader 通过 sync.fetchEntity 拉取某用户可见的 private channel 块。master 端已展开 owner ∪ share→user ∪ share→group 内 members, 并对每条 channel 做了 KEK 解密;agent 端拿到的就是 plaintext key 投影。

func (*PrivateChannelsVisibleLoader) Load added in v0.0.2

Load 实现 entitycache.Loader[uint, *protocol.VisiblePrivateChannelSet]。

type TokenAPIRoleSetLoader added in v0.0.16

type TokenAPIRoleSetLoader struct {
	Client app.WSClient
}

func (*TokenAPIRoleSetLoader) Load added in v0.0.16

func (l *TokenAPIRoleSetLoader) Load(ctx context.Context, principalID uint) (*protocol.APIRoleSet, error)

type TokenLoader

type TokenLoader struct {
	Client        app.WSClient                                        // RPC 通道
	Users         entitycache.EntityCache[uint, *protocol.SyncedUser] // 关联 user 缓存(用于 warm)
	TokenRoutings entitycache.EntityCache[uint, *protocol.TokenRoutingMap]
}

TokenLoader 通过 sync.fetchEntity 拉取 token,同时 warm 关联的 user。

func (*TokenLoader) Load

func (l *TokenLoader) Load(ctx context.Context, key string) (*models.Token, error)

Load 实现 entitycache.Loader[string, *models.Token]。

type TokenRoutingsLoader added in v0.0.13

type TokenRoutingsLoader struct {
	Client app.WSClient
}

func (*TokenRoutingsLoader) Load added in v0.0.13

type UserAPIRoleSetLoader added in v0.0.16

type UserAPIRoleSetLoader struct {
	Client app.WSClient
}

func (*UserAPIRoleSetLoader) Load added in v0.0.16

func (l *UserAPIRoleSetLoader) Load(ctx context.Context, principalID uint) (*protocol.APIRoleSet, error)

type UserLoader

type UserLoader struct {
	Client app.WSClient
}

UserLoader 通过 sync.fetchEntity 拉取 SyncedUser。 与 TokenLoader 不同,UserLoader 没有副作用 warm。

func (*UserLoader) Load

func (l *UserLoader) Load(ctx context.Context, id uint) (*protocol.SyncedUser, error)

Load 实现 entitycache.Loader[uint, *protocol.SyncedUser]。

type UserRoutingsLoader

type UserRoutingsLoader struct {
	Client app.WSClient
}

UserRoutingsLoader 通过 sync.fetchEntity 拉某用户的整块 user-scope routings。 解析 data → protocol.UserRoutingMap,缓存按 user 粒度存取。

func (*UserRoutingsLoader) Load

Load 实现 entitycache.Loader[uint, *protocol.UserRoutingMap]。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL