Documentation ¶
Index ¶
- Constants
- type ICache
- type IRepository
- type IdRecord
- type IdRecordCache
- type IdRecordRepository
- type IdSegment
- func (i IdSegment) GenerateSegment(ctx context.Context, key string, num uint64) (*Segment, error)
- func (i IdSegment) NewID(ctx context.Context, key string) (uint64, error)
- func (i IdSegment) NewIDIterate(ctx context.Context, iterate func(uint64), key string, opts ...dep.Option) error
- func (i IdSegment) NewIDX(ctx context.Context, key string) uint64
- func (i IdSegment) NewSegment(ctx context.Context, key string, opts ...dep.Option) (*Segment, *Segment, error)
- func (i IdSegment) ReplGenerate(ctx context.Context, key string, num uint64, ...) (*Segment, error)
- type Segment
- type StatusCode
Constants ¶
View Source
const ( StatusCodeNil = -iota // 成功 StatusCodeUnknown // 未知错误 StatusCodeHUninit // 没有初始化 StatusCodeOverflow // 超出上限 StatusCodeBadParam // 参数错误 StatusCodeCacheIdUpdated // 缓存中的Id已经更新过 )
View Source
const LUASCRIPT_HINCR = `` /* 652-byte string literal not displayed */
LUASCRIPT_HINCR 带判断的自增脚本 -1则未知错误,-2则为没有初始化,-3则超出上限,否则返回`起始值|上一个值|最大值|当前值`。
View Source
const LUASCRIPT_HREPL = `` /* 594-byte string literal not displayed */
LUASCRIPT_HREPL 重新设置的上限与当前值 -1则未知错误,-2则为没有初始化,-4则参数错误,否则返回当前值。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IRepository ¶
type IdRecord ¶
type IdRecord struct { Key string `json:"key" gorm:"column:key;type:varchar(32);primaryKey;comment:业务主键"` BizId int64 `json:"bizId" gorm:"column:bizId;type:bigint;comment:游戏ID"` // game id Value uint64 `json:"value" gorm:"column:value;type:bigint;default:0;comment:业务当前值"` CreateAt int64 `json:"createAt" gorm:"column:createAt;<-:create;autoCreateTime;comment:创建时间"` // 创建时间 UpdateAt int64 `json:"updateAt" gorm:"column:updateAt;autoUpdateTime;comment:修改时间"` // 修改时间 }
func (IdRecord) DbSharding ¶
type IdRecordRepository ¶
type IdRecordRepository struct { gormex.BaseRepository[IdRecord] Options []dependency.BaseOptionFunc }
func (IdRecordRepository) BlockNextSegment ¶
func (IdRecordRepository) Init ¶
func (i IdRecordRepository) Init()
type IdSegment ¶
type IdSegment struct { Batch uint64 Cache ICache Repo IRepository }
func (IdSegment) GenerateSegment ¶
func (IdSegment) NewIDIterate ¶
func (IdSegment) NewSegment ¶
type Segment ¶
type Segment struct { Code StatusCode `json:"code" form:"code" url:"code"` Cursor uint64 `json:"cursor" form:"cursor" url:"cursor"` MaxId uint64 `json:"max" form:"max" url:"max"` MinId uint64 `json:"min" form:"min" url:"min"` }
type StatusCode ¶
type StatusCode int32
func (StatusCode) ToError ¶
func (i StatusCode) ToError() error
Click to show internal directories.
Click to hide internal directories.