datasource

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

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 适配器名称,需要在当前业务场景中保证唯一

func (*DataSourceAdaptor[K, V]) Set

func (c *DataSourceAdaptor[K, V]) Set(ctx context.Context, value V) error

Set 写入对象

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]) Del

func (c *DataSourceMultiAdaptor[K, V]) Del(ctx context.Context, keys adaptor.Keys[K]) error

Del 删除对象

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 适配器名称

func (*DataSourceMultiAdaptor[K, V]) Set

func (c *DataSourceMultiAdaptor[K, V]) Set(ctx context.Context, vals adaptor.ValueCol[V]) error

Set 写入对象

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 WithName

func WithName(name string) DataSourceOptionFunc

WithName 设置适配器名称

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

type ValueWithError[V adaptor.Metadata] struct {
	Val V
	Err error
}

ValueWithError 含返回值和错误的结构

Jump to

Keyboard shortcuts

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