Skip to content

Conversation

@cnlangzi
Copy link
Owner

@cnlangzi cnlangzi commented Jan 11, 2026

Summary by Sourcery

Remove configurable scheduler interval in favor of a fixed 24h scheduler ticker and clean up related config, validator fields, and tests.

Enhancements:

  • Simplify validator configuration by removing the scheduler interval option and associated struct fields, relying instead on a constant scheduler interval.
  • Update the scheduler to use the fixed interval constant directly rather than a per-instance configuration value.
  • Remove tests related to the deprecated scheduler interval configuration option.

The scheduler interval is now fixed at 24 hours and no longer configurable.
This prevents misconfiguration that could cause CPU overuse (e.g., setting
interval to 0 or nanosecond values).
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 11, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the configurable scheduler interval from the validator configuration and hardcodes the background scheduler to run at the package-level SchedulerInterval, cleaning up unused config and tests accordingly.

Class diagram for Config and Validator scheduler interval changes

classDiagram
    class ConfigBefore {
        string Root
        time_Duration Interval
        int FailLimit
        bool ClassifyUA
    }

    class ConfigAfter {
        string Root
        int FailLimit
        bool ClassifyUA
    }

    class ValidatorBefore {
        string root
        atomic_Pointer_bots bots
        atomic_Pointer_uaIndex uaIndex
        context_CancelFunc cancel
        time_Duration interval
        int failLimit
        bool classifyUA
        startScheduler(ctx context_Context)
    }

    class ValidatorAfter {
        string root
        atomic_Pointer_bots bots
        atomic_Pointer_uaIndex uaIndex
        context_CancelFunc cancel
        int failLimit
        bool classifyUA
        startScheduler(ctx context_Context)
    }

    class Option {
        apply(c *ConfigAfter)
    }

    class OptionsBefore {
        WithRoot(dir string) Option
        WithSchedulerInterval(interval time_Duration) Option
        WithFailLimit(limit int) Option
    }

    class OptionsAfter {
        WithRoot(dir string) Option
        WithFailLimit(limit int) Option
    }

    ConfigBefore <|.. ConfigAfter
    ValidatorBefore <|.. ValidatorAfter
    Option <.. OptionsBefore
    Option <.. OptionsAfter
    ValidatorAfter ..> ConfigAfter
    ValidatorBefore ..> ConfigBefore
Loading

File-Level Changes

Change Details Files
Remove scheduler interval from configuration and validator and use fixed SchedulerInterval in the scheduler ticker.
  • Drop Interval field from Config and the related WithSchedulerInterval option helper
  • Remove interval field from Validator and its initialization from Config in New
  • Change startScheduler to construct ticker with SchedulerInterval instead of Validator.interval
  • Delete the WithSchedulerInterval test and related time imports from tests
config.go
knownbots_test.go
validator.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Jan 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.84%. Comparing base (126b6ea) to head (02d1225).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #9      +/-   ##
==========================================
- Coverage   75.03%   74.84%   -0.20%     
==========================================
  Files          14       14              
  Lines         645      640       -5     
==========================================
- Hits          484      479       -5     
  Misses        117      117              
  Partials       44       44              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Jan 11, 2026

Benchmark Results

BenchmarkFindBotByUA_Hit_First             	  947763	      1124 ns/op	       9 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_First-4           	 3298666	       562.6 ns/op	       6 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_First-8           	 3156214	       565.9 ns/op	       4 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_Middle            	 1000000	      1048 ns/op	       8 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_Middle-4          	 4256664	       312.0 ns/op	       1 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_Middle-8          	 4654444	       243.7 ns/op	       2 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_Last              	 1000000	      1045 ns/op	      11 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_Last-4            	 2860400	       502.6 ns/op	       6 B/op	       0 allocs/op
BenchmarkFindBotByUA_Hit_Last-8            	 2713896	       413.6 ns/op	       4 B/op	       0 allocs/op
BenchmarkFindBotByUA_Miss                  	  509080	      2384 ns/op	      24 B/op	       0 allocs/op
BenchmarkFindBotByUA_Miss-4                	--- FAIL: BenchmarkFindBotByUA_Miss-4
BenchmarkFindBotByUA_Miss-8                	 1359884	       865.1 ns/op	      10 B/op	       0 allocs/op
BenchmarkFindBotByUA_CaseSensitive         	 1764852	      1174 ns/op	       7 B/op	       0 allocs/op
BenchmarkFindBotByUA_CaseSensitive-4       	 2439975	       513.7 ns/op	       3 B/op	       0 allocs/op
BenchmarkFindBotByUA_CaseSensitive-8       	 4327837	       285.0 ns/op	       2 B/op	       0 allocs/op
BenchmarkValidate_KnownBot_IPHit           	 1217682	       888.1 ns/op	       8 B/op	       0 allocs/op
BenchmarkValidate_KnownBot_IPHit-4         	 4019341	       458.7 ns/op	       4 B/op	       0 allocs/op
BenchmarkValidate_KnownBot_IPHit-8         	 2510436	       424.1 ns/op	       4 B/op	       0 allocs/op
BenchmarkValidate_Browser                  	--- FAIL: BenchmarkValidate_Browser
BenchmarkValidate_Browser-4                	  614590	      1980 ns/op	      20 B/op	       0 allocs/op
BenchmarkValidate_Browser-8                	  625826	      2110 ns/op	      21 B/op	       0 allocs/op
BenchmarkContainsWord                      	74156029	        16.48 ns/op	       0 B/op	       0 allocs/op
BenchmarkContainsWord-4                    	73674711	        16.18 ns/op	       0 B/op	       0 allocs/op
BenchmarkContainsWord-8                    	74529883	        16.14 ns/op	       0 B/op	       0 allocs/op
BenchmarkValidate_WithBotUA                	 1000000	      1178 ns/op	       5 B/op	       0 allocs/op
BenchmarkValidate_WithBotUA-4              	 2812981	       426.1 ns/op	       4 B/op	       0 allocs/op
BenchmarkValidate_WithBotUA-8              	 2779002	       434.3 ns/op	       4 B/op	       0 allocs/op
BenchmarkValidate_WithBotUA_IPMismatch     	  820406	      1523 ns/op	      12 B/op	       0 allocs/op
BenchmarkValidate_WithBotUA_IPMismatch-4   	 2264143	       535.7 ns/op	       5 B/op	       0 allocs/op
BenchmarkValidate_WithBotUA_IPMismatch-8   	 2066245	       567.0 ns/op	       4 B/op	       0 allocs/op
BenchmarkValidate_BrowserUA                	  292021	      4200 ns/op	      33 B/op	       0 allocs/op
BenchmarkValidate_BrowserUA-4              	  834610	      1465 ns/op	      17 B/op	       0 allocs/op
BenchmarkValidate_BrowserUA-8              	  824785	      1483 ns/op	      17 B/op	       0 allocs/op
BenchmarkValidate_UnknownBotUA             	 8026580	       158.1 ns/op	       1 B/op	       0 allocs/op
BenchmarkValidate_UnknownBotUA-4           	22066732	        54.51 ns/op	       0 B/op	       0 allocs/op
BenchmarkValidate_UnknownBotUA-8           	21730790	        56.60 ns/op	       0 B/op	       0 allocs/op
BenchmarkContainsIP                        	54882709	        21.54 ns/op	       0 B/op	       0 allocs/op
BenchmarkContainsIP-4                      	100000000	        11.08 ns/op	       0 B/op	       0 allocs/op
BenchmarkContainsIP-8                      	99841858	        11.18 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindBotByUA                       	  815642	      1505 ns/op	      15 B/op	       0 allocs/op
BenchmarkFindBotByUA-4                     	 2092381	       590.1 ns/op	       6 B/op	       0 allocs/op
BenchmarkFindBotByUA-8                     	 2089735	       569.7 ns/op	       3 B/op	       0 allocs/op
BenchmarkClassifyUA                        	 2277740	       527.8 ns/op	       2 B/op	       0 allocs/op
BenchmarkClassifyUA-4                      	 5044268	       239.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkClassifyUA-8                      	 5048629	       239.1 ns/op	       0 B/op	       0 allocs/op
Benchmark_MixedTraffic                     	--- FAIL: Benchmark_MixedTraffic
Benchmark_MixedTraffic-4                   	--- FAIL: Benchmark_MixedTraffic-4
Benchmark_MixedTraffic-8                   	 1313839	       921.8 ns/op	       6 B/op	       0 allocs/op
BenchmarkReload                            	     856	   1405276 ns/op	  665526 B/op	    6444 allocs/op
BenchmarkReload-4                          	     946	   1251887 ns/op	  667465 B/op	    6444 allocs/op
BenchmarkReload-8                          	     945	   1255166 ns/op	  668923 B/op	    6462 allocs/op

@cnlangzi cnlangzi merged commit 1c4877a into main Jan 11, 2026
3 checks passed
@cnlangzi cnlangzi deleted the fix/withschedulerinterval branch January 11, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants