logic

package
v0.0.0-...-60bad89 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPMetadataKeyContentType    = "Content-Type"
	HTTPResponseHeaderContentType = "Content-Type"
)

Variables

Functions

This section is empty.

Types

type AccountLogic

type AccountLogic interface {
	CreateAccount(ctx context.Context, in CreateAccountInput) (CreateAccountOutput, error)
	CreateSession(ctx context.Context, in CreateSessionInput) (CreateSessionOutput, error)
	DeleteSession(ctx context.Context, in DeleteSessionInput) error
}

func NewAccountLogic

func NewAccountLogic(
	database database.Database,
	accountDataAccessor database.AccountDataAccessor,
	passwordDataAccessor database.AccountPasswordDataAccessor,
	hashLogic HashLogic,
	tokenLogic TokenLogic,
	takenAccountNameCache cache.TakenAccountName,
	logger *zap.Logger,
) AccountLogic

type CreateAccountInput

type CreateAccountInput struct {
	AccountName string
	Password    string
}

type CreateAccountOutput

type CreateAccountOutput struct {
	ID          uint64
	AccountName string
}

type CreateDownloadTaskInput

type CreateDownloadTaskInput struct {
	Token string
	Type  idm.DownloadType
	URL   string
}

type CreateDownloadTaskOutput

type CreateDownloadTaskOutput struct {
	DownloadTask idm.DownloadTask
}

type CreateSessionInput

type CreateSessionInput struct {
	AccountName string
	Password    string
}

type CreateSessionOutput

type CreateSessionOutput struct {
	Token       string
	ExpiresAt   time.Time
	AccountID   uint64
	AccountName string
}

type DeleteDownloadTaskInput

type DeleteDownloadTaskInput struct {
	Token          string
	DownloadTaskID uint64
}

type DeleteSessionInput

type DeleteSessionInput struct {
	Token string
}

type DeleteSessionOutput

type DeleteSessionOutput struct {
	ExpiredToken string
}

type DownloadTaskLogic

type DownloadTaskLogic interface {
	CreateDownloadTask(ctx context.Context, in CreateDownloadTaskInput) (CreateDownloadTaskOutput, error)
	GetDownloadTaskList(ctx context.Context, in GetDownloadTaskListInput) (GetDownloadTaskListOutput, error)
	UpdateDownloadTask(ctx context.Context, in UpdateDownloadTaskInput) (UpdateDownloadTaskOutput, error)
	DeleteDownloadTask(ctx context.Context, in DeleteDownloadTaskInput) error

	ExecuteDownloadTask(ctx context.Context, in ExecuteDownloadTaskInput) error
}

func NewDownloadTaskLogic

func NewDownloadTaskLogic(
	tokenLogic TokenLogic,
	accountDataAccessor database.AccountDataAccessor,
	downloadTaskDataAccessor database.DownloadTaskDataAccessor,
	downloadTaskCreatedProducer producer.DownloadTaskCreatedProducer,
	fileClient file.Client,
	database database.Database,
	logger *zap.Logger,
) (DownloadTaskLogic, error)

type Downloader

type Downloader interface {
	Download(ctx context.Context, writer io.Writer) (map[string]any, error)
}

func NewFTPDownloader

func NewFTPDownloader() (Downloader, error)

func NewHTTPDownloader

func NewHTTPDownloader(
	url string,
	logger *zap.Logger,
) (Downloader, error)

type ExecuteDownloadTaskInput

type ExecuteDownloadTaskInput struct {
	DownloadTaskID uint64
}

type GetDownloadTaskListInput

type GetDownloadTaskListInput struct {
	Token  string
	Offset uint64
	Limit  uint64
}

type GetDownloadTaskListOutput

type GetDownloadTaskListOutput struct {
	DownloadTaskList       []*idm.DownloadTask
	TotalDownloadTaskCount uint64
}

type HashLogic

type HashLogic interface {
	HashPassword(ctx context.Context, plainPassword string) (string, error)
	IsHashEqual(ctx context.Context, plainPassword string, hashedPassword string) (bool, error)
}

func NewHashLogic

func NewHashLogic() HashLogic

type TokenLogic

type TokenLogic interface {
	CreateTokenString(ctx context.Context, accountID uint64) (string, time.Time, error)
	GetAccountIDAndExpireTime(ctx context.Context, token string) (uint64, time.Time, error)
	WithDatabase(database database.Database) TokenLogic
}

func NewTokenLogic

func NewTokenLogic(
	accountDataAccessor database.AccountDataAccessor,
	tokenPublicKeyDataAccessor database.TokenPublicKeyDataAccessor,
	logger *zap.Logger,
	authConfig configs.Auth,
	tokenPublicKeyCache cache.TokenPublicKey,
) (TokenLogic, error)

type UpdateDownloadTaskInput

type UpdateDownloadTaskInput struct {
	Token          string
	DownloadTaskID uint64
	DownloadStatus uint16
	Metadata       string
}

type UpdateDownloadTaskOutput

type UpdateDownloadTaskOutput struct {
	DownloadTask idm.DownloadTask
}

Jump to

Keyboard shortcuts

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