Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed cleaner #15

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ func (c *Controller) Start() error {
case job := <-c.FailedJobChan:
c.processFailedJob(job)
case job := <-c.PrepareJobChan:
if job == nil {
continue
}
// add new job to database before processing
if err := c.prepareJob(job); err != nil {
log.Error("[Controller] failed on preparing job", "err", err, "jobType", job.GetType(), "tx", job.GetTransaction().GetHash().Hex())
Expand All @@ -281,10 +284,9 @@ func (c *Controller) Start() error {
}
// get 1 workerCh from queue and push job to this channel
hash := job.Hash()
if _, ok := c.processedJobs.Load(hash); ok {
if _, ok := c.processedJobs.LoadOrStore(hash, struct{}{}); ok {
continue
}
c.processedJobs.Store(hash, struct{}{})
log.Info("[Controller] jobChan received a job", "jobId", job.GetID(), "nextTry", job.GetNextTry(), "type", job.GetType())
workerCh := <-c.Queue
workerCh <- job
Expand Down
10 changes: 0 additions & 10 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,11 @@ type Config struct {
Listeners map[string]*LsConfig `json:"listeners"`
NumberOfWorkers int `json:"numberOfWorkers"`
DB *stores.Database `json:"database"`
Cleaner Cleaner `json:"cleaner"`

// this field is used for testing purpose
Testing bool
}

type Cleaner map[string]*CleanerConfig

type CleanerConfig struct {
Cron string `json:"cron"`
RemoveAfter uint64 `json:"removeAfter"`
SkipIfLessThan uint64 `json:"SkipIfLessThan"`
Description string `json:"description"`
}

type LsConfig struct {
ChainId string `json:"chainId"`
Name string `json:"-"`
Expand Down