Files
oxkerclone/internal/utils/ratelimiter.go
T
Niko Syring d41761d6e9 feat: complete Rust-to-Go rewrite with Bubbletea v2
Rewrites oxker from Rust/ratatui to Go/Bubbletea, migrated to the
Bubbletea v2 API (charm.land/bubbletea/v2). Removes all original Rust
source files and legacy Go modules (internal/ui, internal/input, bubbles).

Key changes:
- View() returns tea.View with declarative AltScreen and MouseMode
- KeyMsg → KeyPressMsg, MouseMsg → MouseClickMsg/WheelMsg/MotionMsg/ReleaseMsg
- execWriteKey rewritten for v2 key fields (Code/Mod/Text)
- Mouse toggle via View field instead of imperative commands
- Filter/search text input uses msg.Text for v2 space key compat

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 03:41:14 +01:00

30 lines
438 B
Go

package utils
import (
"time"
)
type RateLimiter struct {
lastTime time.Time
minInterval time.Duration
}
func NewRateLimiter(interval time.Duration) *RateLimiter {
return &RateLimiter{
minInterval: interval,
}
}
func (r *RateLimiter) Allow() bool {
now := time.Now()
if now.Sub(r.lastTime) >= r.minInterval {
r.lastTime = now
return true
}
return false
}
func (r *RateLimiter) Reset() {
r.lastTime = time.Time{}
}