db

package
v0.0.0-...-7a2dd3a Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BatchUnit = 25
)

Variables

View Source
var (
	ErrUserIdIsEmpty   = errors.New("user_id is empty")
	ErrKifuIdIsEmpty   = errors.New("kifu_id is empty")
	ErrPositionIsEmpty = errors.New("position is empty")
	ErrLockError       = errors.New("optimistic locking error")
)
View Source
var (
	ErrEmpty = errors.New("result is empty")
)

Functions

This section is empty.

Types

type DB

type DB interface {
	PutKifu(ctx context.Context, kifu *documentpb.Kifu, steps []*documentpb.Step, version int64) (int64, error)
	GetKifu(ctx context.Context, kifuId string) (*documentpb.Kifu, int64, error)
	GetKifuAndSteps(ctx context.Context, kifuId string) (*documentpb.Kifu, []*documentpb.Step, int64, error)
	ListKifu(ctx context.Context, userId string, f func(*documentpb.Kifu, int64)) error
	GetKifuIdsBySfen(ctx context.Context, sfen string) ([]*UserKifu, error)
	GetSamePositions(ctx context.Context, userIds []string, pos string, options ...GetSamePositionsOption) ([]*Position, error)
	GetRecentKifu(ctx context.Context, userId string, limit int) ([]*documentpb.Kifu, error)
	DeleteKifu(ctx context.Context, kifuId string, version int64) error
}

type DynamoDB

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

func NewDynamoDB

func NewDynamoDB(client *dynamodb.DynamoDB, tableName string, ops ...DynamoDBOption) *DynamoDB

func (*DynamoDB) DeleteKifu

func (db *DynamoDB) DeleteKifu(ctx context.Context, kifuId string, version int64) error

func (*DynamoDB) GetKifu

func (db *DynamoDB) GetKifu(
	ctx context.Context,
	kifuId string,
) (*documentpb.Kifu, int64, error)

func (*DynamoDB) GetKifuAndSteps

func (db *DynamoDB) GetKifuAndSteps(
	ctx context.Context,
	kifuId string,
) (*documentpb.Kifu, []*documentpb.Step, int64, error)

func (*DynamoDB) GetKifuIdsBySfen

func (db *DynamoDB) GetKifuIdsBySfen(ctx context.Context, sfen string) ([]*UserKifu, error)

func (*DynamoDB) GetRecentKifu

func (db *DynamoDB) GetRecentKifu(ctx context.Context, userId string, limit int) ([]*documentpb.Kifu, error)

func (*DynamoDB) GetSamePositions

func (db *DynamoDB) GetSamePositions(ctx context.Context, userIds []string, pos string, options ...GetSamePositionsOption) ([]*Position, error)

func (*DynamoDB) ListKifu

func (db *DynamoDB) ListKifu(ctx context.Context, userId string, f func(kifu *documentpb.Kifu, version int64)) error

func (*DynamoDB) PutKifu

func (db *DynamoDB) PutKifu(
	ctx context.Context,
	kifu *documentpb.Kifu,
	steps []*documentpb.Step,
	version int64,
) (int64, error)

type DynamoDBKifuRecord

type DynamoDBKifuRecord struct {
	UserId    string `dynamodbav:"userId,omitempty"`
	KifuId    string `dynamodbav:"kifuId"`
	Var       string `dynamodbav:"var"`
	CreatedTs int64  `dynamodbav:"createdTs,omitempty"`
	StartTs   int64  `dynamodbav:"startTs,omitempty"`
	Sfen      string `dynamodbav:"sfen,omitempty"`
	Seq       int32  `dynamodbav:"seq,omitempty"`
	Pos       string `dynamodbav:"pos,omitempty"`
	Kifu      []byte `dynamodbav:"kifu,omitempty"`
	Step      []byte `dynamodbav:"step,omitempty"`
	Version   int64  `dynamodbav:"version,omitempty"`
	StepNum   int32  `dynamodbav:"stepNum,omitempty"`
}

type DynamoDBOption

type DynamoDBOption func(*DynamoDB)

func SetParallelism

func SetParallelism(i int) DynamoDBOption

type ErrInvalidValue

type ErrInvalidValue struct {
	Details string
}

func (*ErrInvalidValue) Error

func (*ErrInvalidValue) Error() string

type GetSamePositionsOption

type GetSamePositionsOption func(*getSamePositionsOptions)

func GetSamePositionsAddExcludeKifuId

func GetSamePositionsAddExcludeKifuId(kifuId string) GetSamePositionsOption

func GetSamePositionsAddExcludeKifuIds

func GetSamePositionsAddExcludeKifuIds(kifuIds []string) GetSamePositionsOption

func GetSamePositionsSetNumStep

func GetSamePositionsSetNumStep(n int32) GetSamePositionsOption

type GetStepsOption

type GetStepsOption func(*getStepsOptions)

func GetStepsSetRange

func GetStepsSetRange(start, end int32) GetStepsOption

type Position

type Position struct {
	UserId string
	KifuId string
	Steps  []*documentpb.Step
}

type StepSlice

type StepSlice []*documentpb.Step

func (StepSlice) Len

func (s StepSlice) Len() int

func (StepSlice) Less

func (s StepSlice) Less(i int, j int) bool

func (StepSlice) Swap

func (s StepSlice) Swap(i int, j int)

type UserKifu

type UserKifu struct {
	UserId string
	KifuId string
}

Jump to

Keyboard shortcuts

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