duplicatechecker

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 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)
}

DuplicateChecker is common duplicate checker interface

type DuplicateCheckerContainer

type DuplicateCheckerContainer struct {
	Current DuplicateChecker
}

DuplicateCheckerContainer contains the current duplicate checker

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) 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
)

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) 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) 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