data

package
v0.0.0-...-585f190 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetRDBClient

func GetRDBClient(rdb *tiga.RedisDao) *redis.Client

func NewAppRepo

func NewAppRepo(cfg *tiga.Configuration, log logger.Logger) biz.AppRepo

func NewAppRepoImpl

func NewAppRepoImpl(curd biz.CURD, local *LayeredCache, cfg *config.Config) biz.AppRepo

func NewAuthzRepo

func NewAuthzRepo(cfg *tiga.Configuration, log logger.Logger) biz.AuthzRepo

func NewAuthzRepoImpl

func NewAuthzRepoImpl(log logger.Logger, local *LayeredCache) biz.AuthzRepo

func NewCurdImpl

func NewCurdImpl(db *tiga.MySQLDao, conf *config.Config) biz.CURD

func NewDataLock

func NewDataLock(client *redis.Client, key string, ttl time.Duration, retry int) biz.DataLock

func NewDataOperatorRepo

func NewDataOperatorRepo(data *Data, app biz.AppRepo, user biz.UserRepo, authz biz.AuthzRepo, local *LayeredCache, log logger.Logger) biz.DataOperatorRepo

func NewEndpointRepo

func NewEndpointRepo(cfg *tiga.Configuration, log logger.Logger) endpoint.EndpointRepo

func NewEndpointRepoImpl

func NewEndpointRepoImpl(data *Data, cfg *config.Config) endpoint.EndpointRepo

func NewEtcd

func NewEtcd(config *tiga.Configuration) *tiga.EtcdDao

func NewLocker

func NewLocker(cfg *tiga.Configuration, log logger.Logger, key string, ttl time.Duration, retry int) biz.DataLock

func NewMySQL

func NewMySQL(config *tiga.Configuration) *tiga.MySQLDao

func NewOperator

func NewOperator(cfg *tiga.Configuration, log logger.Logger) biz.DataOperatorRepo

func NewRDB

func NewRDB(config *tiga.Configuration) *tiga.RedisDao

func NewUserRepo

func NewUserRepo(cfg *tiga.Configuration, log logger.Logger) biz.UserRepo

func NewUserRepoImpl

func NewUserRepoImpl(data *Data, local *LayeredCache, curd biz.CURD, cfg *config.Config) biz.UserRepo

Types

type Data

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

func NewData

func NewData(mysql *tiga.MySQLDao, rdb *tiga.RedisDao, etcd *tiga.EtcdDao) *Data

func NewDataRepo

func NewDataRepo(cfg *tiga.Configuration, log logger.Logger) *Data

func (*Data) BatchCacheByTx

func (d *Data) BatchCacheByTx(ctx context.Context, exp time.Duration, kv ...interface{}) redis.Pipeliner
	if err != nil {
		return errors.Wrap(err, "更新失败")
	}
	return nil
}
func (d *Data) Cache(ctx context.Context, key string, value string, exp time.Duration) error {
	return d.rdb.Set(ctx, key, value, exp)
}
func (d *Data) GetCache(ctx context.Context, key string) string {
	return d.rdb.Get(ctx, key)
}

func (*Data) PutEtcdWithTxn

func (d *Data) PutEtcdWithTxn(ctx context.Context, ops []clientv3.Op) (bool, error)
func (d *Data) BatchEtcdDelete(models []SourceType) error {
	if len(models) == 0 {
		return nil
	}
	if len(models) == 1 {
		key, val, err := getPrimaryColumnValue(models[0], "primary")
		if err != nil {
			return fmt.Errorf("get primary column value failed: %w", err)
		}
		return d.db.Delete(models[0], fmt.Sprintf("%s=?", key), val)
	}
	keys := make([]string, 0)
	dataModel := models[0]
	_in := "uid in ?"
	for _, item := range models {
		key, val, err := getPrimaryColumnValue(item, "primary")
		_in = fmt.Sprintf("%s in ?", key)
		if err != nil {
			return fmt.Errorf("get primary column value failed: %w", err)
		}
		keys = append(keys, val.(string))
	}
	return d.db.Delete(dataModel, _in, keys)
}
func (d *Data) EtcdPut(ctx context.Context, key string, value string, opts ...clientv3.OpOption) error {
	return d.etcd.Put(ctx, key, value, opts...)
}

type LayeredCache

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

func NewLayered

func NewLayered(cfg *tiga.Configuration, log logger.Logger) *LayeredCache

func NewLayeredCache

func NewLayeredCache(rdb *tiga.RedisDao, config *config.Config, log logger.Logger) *LayeredCache

NewLayeredCache creates a new layered cache only once

func (*LayeredCache) AddToFilter

func (l *LayeredCache) AddToFilter(ctx context.Context, key string, value []byte) error

func (*LayeredCache) CheckInFilter

func (l *LayeredCache) CheckInFilter(ctx context.Context, key string, value []byte) (bool, error)

func (*LayeredCache) Del

func (l *LayeredCache) Del(ctx context.Context, key string) error

func (*LayeredCache) DelInFilter

func (l *LayeredCache) DelInFilter(ctx context.Context, key string, value []byte) error

func (*LayeredCache) Get

func (l *LayeredCache) Get(ctx context.Context, key string) ([]byte, error)

func (*LayeredCache) GetFromLocal

func (l *LayeredCache) GetFromLocal(ctx context.Context, key string) ([]byte, error)

func (*LayeredCache) Set

func (l *LayeredCache) Set(ctx context.Context, key string, value []byte, exp time.Duration) error

func (*LayeredCache) SetToLocal

func (l *LayeredCache) SetToLocal(ctx context.Context, key string, value []byte, exp time.Duration) error

func (*LayeredCache) Watch

func (l *LayeredCache) Watch(ctx context.Context)

type SourceType

type SourceType interface {
	// 获取数据源类型
	GetUpdateMask() *fieldmaskpb.FieldMask
}

Jump to

Keyboard shortcuts

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