modelreg

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelreg 实现全局模型注册表:model_registry 表持久化 + /v1 准入用的 启用开关与重定向覆盖。等价于 ccLoad 单渠道 ModelEntry{redirect_model, disabled} 的集合——本服务只有一条上游,注册表是全局覆盖层而非渠道属性。

生效序:注册表 redirect_model → config.yaml 的 devin.aliases → 原名 (别名解析在 adapter 内完成,注册表只改写请求的模型名)。停用命中在 准入层返回 404——对客户端的语义是「本网关不提供该模型」,与令牌 白名单的 403 分层。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	RedirectModel string
	Disabled      bool
}

Entry 是一条注册表覆盖;字段名对齐 ccLoad model.ModelEntry。

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store 管理 model_registry 表与内存覆盖表;管理操作写穿透入库(低频), /v1 准入路径的 Lookup 纯走内存。

func New

func New(st *store.Store) (*Store, error)

New 从 model_registry 表水合内存覆盖表;空表以空仓起步。

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete 移除覆盖;不存在时按成功处理(幂等删除)。键口径同 Lookup (见 foldKey);入名先过 normalize——带首尾空白的名字同样是删不掉的变体。 锁外写库的理由同 Set。

func (*Store) Entries

func (s *Store) Entries() map[string]Entry

Entries 返回全部覆盖项的副本(键为注册时的原始大小写)。

func (*Store) Lookup

func (s *Store) Lookup(name string) (Entry, bool)

Lookup 查模型的覆盖项:精确命中 → 大小写折叠(与 ResolveModelAlias 的匹配顺序一致)。未命中返回 ok=false,调用方按默认启用、无重定向处理。

func (*Store) Names

func (s *Store) Names() []string

Names 返回覆盖项的名字表(排序后),供渠道模型清单投影并入注册表名。

func (*Store) Set

func (s *Store) Set(name string, e Entry) error

Set 覆盖写一条注册项并入库;项退化为全默认(启用且无重定向)时自动 删除——表只承载非默认覆盖,PUT 传默认值即等价于重置。先写库后改 内存:写失败时两侧一致保持旧值。写库在 entries 锁外进行——写连接 stall 只拖住本次管理操作,/v1 准入的 Lookup 读锁不被波及。

Jump to

Keyboard shortcuts

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