client

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 17 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 client 统一配置解析、SDK client 创建与 required/optional 认证生命周期。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options *invocation.RootOptions, token string) (*javdb.Client, error)

New 读取配置、校验命令行 host 与 proxy、解析运行时,并在 auto 时先完成线路选择,再构造 携带给定 token 的公开 SDK client。固定 host 完全绕过 route cache 与 selector。基线配置在 host/proxy 无副作用校验与 device UUID provision 之后创建;无效 host/proxy 不落盘,选线 失败也不回滚已创建的本机基线状态。

func NewWithDefaultToken added in v0.7.0

func NewWithDefaultToken(options *invocation.RootOptions) (*javdb.Client, error)

NewWithDefaultToken 解析运行时与默认账号 token 并构造公开 SDK client; 供管道批处理调用方每次批量只构造一次。解析失败显式返回错误。

func RetryAnonymousAuth added in v0.7.2

func RetryAnonymousAuth(c *javdb.Client, errOut io.Writer, fn func() error) error

RetryAnonymousAuth 为已经构造好的批处理 client 保留 WithOptionalAuth 的匿名 回退语义:仅在已有 token 被服务端拒绝时清空 token 并重试,不触发自动登录或写入 认证存储。调用方应保证批处理 client 的使用顺序,避免并发请求同时切换 token。

func WithOptionalAuth

func WithOptionalAuth(options *invocation.RootOptions, errOut io.Writer, fn func(*javdb.Client) error) error

WithOptionalAuth 在有 token 时携带默认账户,否则匿名执行;认证失败时保留原有匿名重试。 本地 token 读取先于线路选择,避免只读/匿名命令在离线时被选线失败阻断。

func WithRequiredAuth

func WithRequiredAuth(options *invocation.RootOptions, errOut io.Writer, fn func(*javdb.Client) error) error

WithRequiredAuth 使用默认账户 token 执行 fn;按配置决定是否自动重新登录。 本地账号/token 前置检查先于线路选择:断网或代理不可用时仍先报"请先登录"类错误, 不会因自动选线失败而掩盖认证缺失。错误文本与既有 WithAuthedClient 逐字一致; errOut == nil 时不写提示。

Types

type ReverseSearchSetup added in v0.7.0

type ReverseSearchSetup struct {
	Client *javdb.Client
	// Source 是本次调用选中的 source(已展开环境 header);builtin 时
	// Name 为 "builtin"。
	Source javdb.ReverseSearchSource
	// CacheEnabled 反映配置与 --no-cache 之外的缓存开关。
	CacheEnabled bool
	// HTTPClient 是装配了最终代理配置的 HTTP client,供图片 URL 读取与
	// provider 请求共用(图片 URL、provider、JavDB 共用同一代理契约)。
	HTTPClient *http.Client
}

ReverseSearchSetup 是一次反搜调用所需的公开 SDK client 与已解析 source。

func NewReverseSearchClient added in v0.7.0

func NewReverseSearchClient(options *invocation.RootOptions, token, explicitSource string) (*ReverseSearchSetup, error)

NewReverseSearchClient 解析反搜配置(含环境 header 展开)、装配本机文件 缓存并构造携带反搜选项的公开 SDK client。explicitSource 非空时覆盖 default_source。配置损坏显式失败,绝不偷回 builtin。

Jump to

Keyboard shortcuts

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