data

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 42 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) (client auth.AuthClient, err error)

func NewCache

func NewCache(client redis.UniversalClient) biz.Cache

NewCache .

func NewDB

func NewDB(c *conf.Bootstrap) (db *gorm.DB, 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) Get

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

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, db *gorm.DB, 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) 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

type Game added in v1.0.2

type Game struct {
	Id   uint64 `json:"id,string"` // auto increment id
	Name string `json:"name"`      // name
	Age  int32  `json:"age"`       // age
}

Game is database fields map

Jump to

Keyboard shortcuts

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