data

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 45 Imported by: 0

README

Data

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is data providers.

Functions

func DelFromLocal added in v1.2.0

func DelFromLocal(key string)

func GetFromLocal added in v1.2.0

func GetFromLocal(key string) (string, error)

func NewAuthClient

func NewAuthClient(c *conf.Bootstrap) (auth.AuthClient, error)

func NewCache

func NewCache(c *conf.Bootstrap, client redis.UniversalClient) biz.Cache

NewCache .

func NewClient added in v1.1.0

func NewClient[T any](name, endpoint string, health bool, timeout time.Duration, newClient func(cc g.ClientConnInterface) T) (client T, err error)

func NewDB

func NewDB(c *conf.Bootstrap) (gormTenant *tenant.Tenant, err error)

NewDB is initialize db connection from config

func NewGameRepo added in v1.0.2

func NewGameRepo(data *Data) biz.GameRepo

func NewRedis

func NewRedis(c *conf.Bootstrap) (client redis.UniversalClient, err error)

NewRedis is initialize redis connection from config

func NewSonyflake

func NewSonyflake(c *conf.Bootstrap) (sf *id.Sonyflake, err error)

NewSonyflake is initialize sonyflake id generator

func NewTracer

func NewTracer(c *conf.Bootstrap) (tp *trace.TracerProvider, err error)

func NewTransaction

func NewTransaction(d *Data) biz.Transaction

NewTransaction .

func Set2Local added in v1.2.0

func Set2Local(key, val string, expire int)

Types

type Cache

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

Cache .

func (*Cache) Cache

func (c *Cache) Cache() redis.UniversalClient

func (*Cache) Del

func (c *Cache) Del(ctx context.Context, action string)

func (*Cache) Flush

func (c *Cache) Flush(ctx context.Context, handler func(ctx context.Context) error) (err error)

func (*Cache) FlushByPrefix added in v1.1.0

func (c *Cache) FlushByPrefix(ctx context.Context, prefix ...string) (err error)

func (*Cache) Get

func (c *Cache) Get(
	ctx context.Context,
	action string,
	write func(context.Context) (string, error),
) (res string, err error)

func (*Cache) Lock

func (c *Cache) Lock(ctx context.Context, action string) (*redislock.Lock, error)

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, action, data string, short bool)

func (*Cache) SetWithExpiration

func (c *Cache) SetWithExpiration(ctx context.Context, action, data string, seconds int64)

func (*Cache) WithPrefix

func (c *Cache) WithPrefix(prefix string) biz.Cache

func (*Cache) WithRefresh added in v1.1.2

func (c *Cache) WithRefresh() biz.Cache

type Data

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

Data .

func NewData

func NewData(
	redis redis.UniversalClient,
	gormTenant *tenant.Tenant,
	sonyflake *id.Sonyflake,
	tp *trace.TracerProvider,
	auth auth.AuthClient,
) (d *Data, cleanup func())

NewData .

func (*Data) Cache

func (d *Data) Cache() redis.UniversalClient

Cache can get cache instance

func (*Data) DB

func (d *Data) DB(ctx context.Context) *gorm.DB

DB can get tx from ctx, if not exist return db

func (*Data) HiddenSQL added in v1.0.3

func (*Data) HiddenSQL(ctx context.Context) context.Context

HiddenSQL return a hidden sql ctx

func (*Data) ID added in v1.1.2

func (d *Data) ID(ctx context.Context) uint64

ID can get unique id

func (*Data) Tx

func (d *Data) Tx(ctx context.Context, handler func(ctx context.Context) error) error

Tx is transaction wrapper

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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