data

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 43 Imported by: 0

README

Data

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is data providers.

Functions

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 .

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) (ok bool)

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) Unlock

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

func (*Cache) WithPrefix

func (c *Cache) WithPrefix(prefix string) 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

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