resolver

package
v7.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithByPassResolverCache added in v7.24.0

func WithByPassResolverCache(ctx context.Context) context.Context

WithByPassResolverCache 设置 Context 绕过 Resolver 内部缓存

Types

type CacheResolverConfig

type CacheResolverConfig struct {
	// 压缩周期(默认:60s)
	CompactInterval time.Duration

	// 持久化路径(默认:$TMPDIR/qiniu-golang-sdk/resolver_01.cache.json)
	PersistentFilePath string

	// 持久化周期(默认:60s)
	PersistentDuration time.Duration

	// 缓存有效期(默认:120s)
	CacheLifetime time.Duration

	// 缓存刷新时间(默认:80s)
	CacheRefreshAfter time.Duration
}

CacheResolverConfig 缓存域名解析器选项

type Resolver

type Resolver interface {
	// Resolve 解析域名的 IP 地址
	Resolve(context.Context, string) ([]net.IP, error)

	// FeedbackGood 反馈一批 IP 地址请求成功
	FeedbackGood(context.Context, string, []net.IP)

	// FeedbackBad 反馈一批 IP 地址请求失败
	FeedbackBad(context.Context, string, []net.IP)
}

Resolver 域名解析器的接口

func NewCacheResolver

func NewCacheResolver(resolver Resolver, opts *CacheResolverConfig) (Resolver, error)

NewCacheResolver 创建带缓存功能的域名解析器

func NewDefaultResolver

func NewDefaultResolver() Resolver

NewDefaultResolver 创建默认的域名解析器

func NewResolver

func NewResolver(fn func(context.Context, string) ([]net.IP, error)) Resolver

NewResolver 创建自定义的域名解析器

Jump to

Keyboard shortcuts

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