duplicatechecker

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Container = &DuplicateCheckerContainer{}
)

Initialize a duplicate checker container singleton instance

Functions

func InitializeDuplicateChecker

func InitializeDuplicateChecker(config *settings.Config) error

InitializeDuplicateChecker initializes the current duplicate checker according to the config

Types

type DuplicateChecker

type DuplicateChecker interface {
	GetSubmissionRemark(checkerType DuplicateCheckerType, uid int64, identification string) (bool, string)
	SetSubmissionRemark(checkerType DuplicateCheckerType, uid int64, identification string, remark string)
	GetOrSetCronJobRunningInfo(jobName string, runningInfo string, runningInterval time.Duration) (bool, string)
	RemoveCronJobRunningInfo(jobName string)
	GetFailureCount(failureKey string) uint32
	IncreaseFailureCount(failureKey string) uint32
}

DuplicateChecker is common duplicate checker interface

type DuplicateCheckerContainer

type DuplicateCheckerContainer struct {
	Current DuplicateChecker
}

DuplicateCheckerContainer contains the current duplicate checker

func (*DuplicateCheckerContainer) GetFailureCount added in v0.8.0

func (c *DuplicateCheckerContainer) GetFailureCount(failureKey string) uint32

GetFailureCount returns the failure count of the specified failure key

func (*DuplicateCheckerContainer) GetOrSetCronJobRunningInfo added in v0.6.0

func (c *DuplicateCheckerContainer) GetOrSetCronJobRunningInfo(jobName string, runningInfo string, runningInterval time.Duration) (bool, string)

GetOrSetCronJobRunningInfo returns the running info when the cron job is running or saves the running info by the current duplicate checker

func (*DuplicateCheckerContainer) GetSubmissionRemark added in v0.6.0

func (c *DuplicateCheckerContainer) GetSubmissionRemark(checkerType DuplicateCheckerType, uid int64, identification string) (bool, string)

GetSubmissionRemark returns whether the same submission has been processed and related remark by the current duplicate checker

func (*DuplicateCheckerContainer) IncreaseFailureCount added in v0.8.0

func (c *DuplicateCheckerContainer) IncreaseFailureCount(failureKey string) uint32

IncreaseFailureCount increases the failure count of the specified failure key

func (*DuplicateCheckerContainer) RemoveCronJobRunningInfo added in v0.6.0

func (c *DuplicateCheckerContainer) RemoveCronJobRunningInfo(jobName string)

RemoveCronJobRunningInfo removes the running info of the cron job by the current duplicate checker

func (*DuplicateCheckerContainer) SetSubmissionRemark added in v0.6.0

func (c *DuplicateCheckerContainer) SetSubmissionRemark(checkerType DuplicateCheckerType, uid int64, identification string, remark string)

SetSubmissionRemark saves the identification and remark to in-memory cache by the current duplicate checker

type DuplicateCheckerType

type DuplicateCheckerType uint8

DuplicateCheckerType represents duplicate checker type

const (
	DUPLICATE_CHECKER_TYPE_BACKGROUND_CRON_JOB DuplicateCheckerType = 0
	DUPLICATE_CHECKER_TYPE_NEW_ACCOUNT         DuplicateCheckerType = 1
	DUPLICATE_CHECKER_TYPE_NEW_CATEGORY        DuplicateCheckerType = 2
	DUPLICATE_CHECKER_TYPE_NEW_TRANSACTION     DuplicateCheckerType = 3
	DUPLICATE_CHECKER_TYPE_NEW_TEMPLATE        DuplicateCheckerType = 4
	DUPLICATE_CHECKER_TYPE_NEW_PICTURE         DuplicateCheckerType = 5
	DUPLICATE_CHECKER_TYPE_IMPORT_TRANSACTIONS DuplicateCheckerType = 6
	DUPLICATE_CHECKER_TYPE_FAILURE_CHECK       DuplicateCheckerType = 255
)

Types of uuid

type InMemoryDuplicateChecker

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

InMemoryDuplicateChecker represents in-memory duplicate checker

func NewInMemoryDuplicateChecker

func NewInMemoryDuplicateChecker(config *settings.Config) (*InMemoryDuplicateChecker, error)

NewInMemoryDuplicateChecker returns a new in-memory duplicate checker

func (*InMemoryDuplicateChecker) GetFailureCount added in v0.8.0

func (c *InMemoryDuplicateChecker) GetFailureCount(failureKey string) uint32

GetFailureCount returns the failure count of the specified failure key

func (*InMemoryDuplicateChecker) GetOrSetCronJobRunningInfo added in v0.6.0

func (c *InMemoryDuplicateChecker) GetOrSetCronJobRunningInfo(jobName string, runningInfo string, runningInterval time.Duration) (bool, string)

GetOrSetCronJobRunningInfo returns the running info when the cron job is running or saves the running info by the current duplicate checker

func (*InMemoryDuplicateChecker) GetSubmissionRemark added in v0.6.0

func (c *InMemoryDuplicateChecker) GetSubmissionRemark(checkerType DuplicateCheckerType, uid int64, identification string) (bool, string)

GetSubmissionRemark returns whether the same submission has been processed and related remark

func (*InMemoryDuplicateChecker) IncreaseFailureCount added in v0.8.0

func (c *InMemoryDuplicateChecker) IncreaseFailureCount(failureKey string) uint32

IncreaseFailureCount increases the failure count of the specified failure key

func (*InMemoryDuplicateChecker) RemoveCronJobRunningInfo added in v0.6.0

func (c *InMemoryDuplicateChecker) RemoveCronJobRunningInfo(jobName string)

RemoveCronJobRunningInfo removes the running info of the cron job by the current duplicate checker

func (*InMemoryDuplicateChecker) SetSubmissionRemark added in v0.6.0

func (c *InMemoryDuplicateChecker) SetSubmissionRemark(checkerType DuplicateCheckerType, uid int64, identification string, remark string)

SetSubmissionRemark saves the identification and remark to in-memory cache

Jump to

Keyboard shortcuts

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