Documentation ¶
Index ¶
- Variables
- type DataSourceAdaptor
- type DataSourceFunc
- type DataSourceMultiAdaptor
- func (c *DataSourceMultiAdaptor[K, V]) Del(ctx context.Context, keys adaptor.Keys[K]) error
- func (c *DataSourceMultiAdaptor[K, V]) Get(ctx context.Context, keys adaptor.Keys[K], vals adaptor.Values[K, V], ...) (adaptor.Keys[K], error)
- func (c *DataSourceMultiAdaptor[K, V]) Name() string
- func (c *DataSourceMultiAdaptor[K, V]) Set(ctx context.Context, vals adaptor.ValueCol[V]) error
- type DataSourceOption
- type DataSourceOptionFunc
- type MultiDataSourceFunc
- type ValueWithError
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("entry not found")
ErrNotFound 值不存在
Functions ¶
This section is empty.
Types ¶
type DataSourceAdaptor ¶
type DataSourceAdaptor[K comparable, V adaptor.Metadata] struct { // contains filtered or unexported fields }
DataSourceAdaptor 数据源
func NewDataSourceAdaptor ¶
func NewDataSourceAdaptor[K comparable, V adaptor.Metadata](preAdaptor adaptor.Adaptor[K, V], dsfn DataSourceFunc[K, V], fns ...DataSourceOptionFunc) *DataSourceAdaptor[K, V]
NewDataSourceAdaptor 创建一个新的数据源适配器对象
func (*DataSourceAdaptor[K, V]) Del ¶
func (c *DataSourceAdaptor[K, V]) Del(ctx context.Context, key K) error
Del 删除对象 -
func (*DataSourceAdaptor[K, V]) Get ¶
func (c *DataSourceAdaptor[K, V]) Get(ctx context.Context, key K, value V) (bool, error)
Get 读取对象
func (*DataSourceAdaptor[K, V]) Name ¶
func (c *DataSourceAdaptor[K, V]) Name() string
Name 适配器名称,需要在当前业务场景中保证唯一
type DataSourceFunc ¶
type DataSourceFunc[K comparable, V adaptor.Metadata] func(key K) (V, bool, error)
DataSourceFunc 数据源构造函数
type DataSourceMultiAdaptor ¶
type DataSourceMultiAdaptor[K comparable, V adaptor.Metadata] struct { // contains filtered or unexported fields }
DataSourceMultiAdaptor 多值数据源适配器
func NewDataSourceMultiAdaptor ¶
func NewDataSourceMultiAdaptor[K comparable, V adaptor.Metadata](preAdaptor adaptor.MultiAdaptor[K, V], dsfn MultiDataSourceFunc[K, V], fns ...DataSourceOptionFunc) *DataSourceMultiAdaptor[K, V]
NewDataSourceMultiAdaptor 多值数据源适配器
func (*DataSourceMultiAdaptor[K, V]) Get ¶
func (c *DataSourceMultiAdaptor[K, V]) Get(ctx context.Context, keys adaptor.Keys[K], vals adaptor.Values[K, V], fn adaptor.NewValueFunc[V]) (adaptor.Keys[K], error)
Get 读取对象
func (*DataSourceMultiAdaptor[K, V]) Name ¶
func (c *DataSourceMultiAdaptor[K, V]) Name() string
Name 适配器名称
type DataSourceOption ¶
type DataSourceOption struct { Name string SolutionName string SingleFlightWaitTime time.Duration // 单飞请求等待时间 }
DataSourceOption 数据源配置选项
func DefaultDataSourceOption ¶
func DefaultDataSourceOption() DataSourceOption
DefaultDataSourceOption 默认数据源配置
type DataSourceOptionFunc ¶
type DataSourceOptionFunc func(*DataSourceOption)
DataSourceOptionFunc 数据源配置函数
func WithSingleFlightWaitTime ¶
func WithSingleFlightWaitTime(waitTime time.Duration) DataSourceOptionFunc
WithSingleFlightWaitTime 单飞请求等待时间, 超过等待时长则直接调用底层数据方法(可能会触发查库)
func WithSolutionName ¶
func WithSolutionName(name string) DataSourceOptionFunc
WithSolutionName 场景名称
type MultiDataSourceFunc ¶
type MultiDataSourceFunc[K comparable, V adaptor.Metadata] func(keys adaptor.Keys[K]) (adaptor.Values[K, V], error)
MultiDataSourceFunc 多值数据源构造函数
type ValueWithError ¶
ValueWithError 含返回值和错误的结构
Click to show internal directories.
Click to hide internal directories.