reportverifs

package
v0.0.0-...-570c91f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDropType      = errors.New("invalid drop type")
	ErrInvalidDropItem      = errors.New("invalid drop item")
	ErrInvalidDropInfoCount = errors.New("invalid drop info count")
	ErrUnknownItemID        = errors.New("unknown item id")
	ErrUnknownDropInfoTuple = errors.New("unknown drop type + item id tuple")
)
View Source
var (
	ErrAccountIDEmpty  = errors.New("account id is empty")
	ErrAccountNotFound = errors.New("account not found with given id")
)
View Source
var ErrExprMatched = errors.New("reject expr matched")
View Source
var ErrMD5Conflict = errors.New("report with specified md5 has already existed")

Functions

func Module

func Module() fx.Option

Types

type DropInfoTuple

type DropInfoTuple struct {
	ItemID   int64
	DropType string
}

type DropVerifier

type DropVerifier struct {
	DropInfoRepo *repo.DropInfo
}

func NewDropVerifier

func NewDropVerifier(dropInfoRepo *repo.DropInfo) *DropVerifier

func (*DropVerifier) Name

func (d *DropVerifier) Name() string

func (*DropVerifier) Verify

func (d *DropVerifier) Verify(ctx context.Context, report *types.ReportTaskSingleReport, reportTask *types.ReportTask) *Rejection

type MD5Verifier

type MD5Verifier struct {
	DropReportExtraRepo *repo.DropReportExtra
}

func NewMD5Verifier

func NewMD5Verifier(dropReportExtraRepo *repo.DropReportExtra) *MD5Verifier

func (*MD5Verifier) Name

func (u *MD5Verifier) Name() string

func (*MD5Verifier) Verify

func (u *MD5Verifier) Verify(ctx context.Context, report *types.ReportTaskSingleReport, reportTask *types.ReportTask) *Rejection

type RejectRuleVerifier

type RejectRuleVerifier struct {
	RejectRuleRepo *repo.RejectRule
}

func NewRejectRuleVerifier

func NewRejectRuleVerifier(rejectRuleRepo *repo.RejectRule) *RejectRuleVerifier

func (*RejectRuleVerifier) Name

func (d *RejectRuleVerifier) Name() string

func (*RejectRuleVerifier) Verify

type Rejection

type Rejection struct {
	Reliability int    `json:"reliability"`
	Message     string `json:"message"`
}

type ReportContext

type ReportContext struct {
	Report *types.ReportTaskSingleReport
	Task   *types.ReportTask
}

func (ReportContext) SemVerCompare

func (ReportContext) SemVerCompare(a, b string) int

type ReportVerifiers

type ReportVerifiers []Verifier

func NewReportVerifier

func NewReportVerifier(userVerifier *UserVerifier, dropVerifier *DropVerifier, md5Verifier *MD5Verifier, rejectRuleVerifier *RejectRuleVerifier) *ReportVerifiers

func (ReportVerifiers) Verify

func (verifiers ReportVerifiers) Verify(ctx context.Context, reportTask *types.ReportTask) (violations Violations)

type UserVerifier

type UserVerifier struct {
	AccountRepo *repo.Account
}

func NewUserVerifier

func NewUserVerifier(accountRepo *repo.Account) *UserVerifier

func (*UserVerifier) Name

func (u *UserVerifier) Name() string

func (*UserVerifier) Verify

func (u *UserVerifier) Verify(ctx context.Context, report *types.ReportTaskSingleReport, reportTask *types.ReportTask) *Rejection

type Verifier

type Verifier interface {
	Name() string
	Verify(ctx context.Context, report *types.ReportTaskSingleReport, reportTask *types.ReportTask) *Rejection
}

type Violation

type Violation struct {
	Rejection
	Name string `json:"name"`
}

type Violations

type Violations map[int]*Violation

func (Violations) Reliability

func (v Violations) Reliability(index int) int

func (Violations) String

func (v Violations) String() string

Jump to

Keyboard shortcuts

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