domain

package
v0.0.0-...-e365fa7 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageTTL time.Duration = 24 * time.Hour
)

Variables

View Source
var (
	ErrInvalidUserID     = errors.New(errors.BadRequest, "userID should be greater than 0")
	ErrInvalidListKey    = errors.New(errors.BadRequest, "listKey can not be empty")
	ErrListAlreadyExists = errors.New(errors.ResourceAlreadyExist, "list already exist")
	ErrListNotFound      = errors.New(errors.ResourceNotFound, "list not found")
	ErrInternal          = errors.New(errors.Internal, "Internal Server Error")
	ErrPageNotFound      = errors.New(errors.ResourceNotFound, "page not found")
)

Errors defined by our domain

Functions

This section is empty.

Types

type Article

type Article struct {
	Title   string
	Content string
}

type ListKey

type ListKey string

func GenerateListKeyByUserID

func GenerateListKeyByUserID(listKey ListKey, userID int64) ListKey

GenerateListKeyByUserID generates pageList (sorted set) redis key by listKey, userID, and have format pageList:{<listKey>:<userID>}

type Page

type Page struct {
	Key     PageKey `json:"key"`
	Content string  `json:"content"`
	Next    PageKey `json:"next"`
}

func (*Page) GetJSONContent

func (p *Page) GetJSONContent() string

func (*Page) Marshal

func (p *Page) Marshal() []byte

func (*Page) SetContent

func (p *Page) SetContent(c string)

func (*Page) String

func (p *Page) String() string

type PageKey

type PageKey string

func GeneratePageKeyByListKeyUserID

func GeneratePageKeyByListKeyUserID(listKey ListKey, userID int64, now time.Time) PageKey

GeneratePageKeyByListKeyUserID generates given redis key by userID, listKey, and have format page:{<listKey>:<userID>}:<ulid>

type PageMetaKey

type PageMetaKey string

func GenerateListMetaKeyByUserID

func GenerateListMetaKeyByUserID(listKey ListKey, userID int64) PageMetaKey

GenerateListKeyByUserID generates pageList (sorted set) redis key by listKey, userID, and have format pageList:{<listKey>:<userID>}

type PageRepo

type PageRepo interface {
	GetPage(ctx context.Context, uesrID int64, listKey ListKey, pageKey PageKey) (Page, error)
	GetHead(ctx context.Context, userID int64, listKey ListKey) (PageKey, error)
	SetPage(ctx context.Context, userID int64, listkey ListKey, page Page) (PageKey, error)
	NewList(ctx context.Context, userID int64, listKey ListKey) error
}

type PageUsecase

type PageUsecase interface {
	GetPage(ctx context.Context, userID int64, listKey ListKey, pageKey PageKey) (Page, error)
	GetHead(ctx context.Context, userID int64, listKey ListKey) (PageKey, error)
	SetPage(ctx context.Context, userID int64, listKey ListKey, page Page) (PageKey, error)
	NewList(ctx context.Context, userID int64, listKey ListKey) error
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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