Documentation
¶
Index ¶
- Constants
- type BufferReader
- type Detection
- type Detector
- func (d *Detector) GetResetTime() time.Time
- func (d *Detector) GetState() RateLimitState
- func (d *Detector) ProcessOutput(data []byte)
- func (d *Detector) SetCooldown(cooldown time.Duration)
- func (d *Detector) SetDetectionCallback(callback func(Detection))
- func (d *Detector) SetResetBuffer(seconds int)
- func (d *Detector) SetState(state RateLimitState)
- type EventBus
- type Integration
- type Manager
- func (m *Manager) GetDetector() *Detector
- func (m *Manager) GetEventBus() *EventBus
- func (m *Manager) GetResetTime() time.Time
- func (m *Manager) GetScheduler() *Scheduler
- func (m *Manager) GetState() RateLimitState
- func (m *Manager) IsEnabled() bool
- func (m *Manager) ProcessOutput(data []byte)
- func (m *Manager) SetCooldown(cooldown time.Duration)
- func (m *Manager) SetDetectionCallback(fn func(Detection))
- func (m *Manager) SetEnabled(enabled bool)
- func (m *Manager) SetRecoveryCallback(fn func(success bool, det Detection))
- func (m *Manager) SetResetBuffer(seconds int)
- func (m *Manager) Start()
- func (m *Manager) Stop()
- type PTYConsumer
- func (pc *PTYConsumer) GetManager() *Manager
- func (pc *PTYConsumer) GetRateLimitState() RateLimitState
- func (pc *PTYConsumer) GetResetTime() time.Time
- func (pc *PTYConsumer) IsEnabled() bool
- func (pc *PTYConsumer) NotifyOutput()
- func (pc *PTYConsumer) SetEnabled(enabled bool)
- func (pc *PTYConsumer) Start()
- func (pc *PTYConsumer) Stop()
- type Provider
- type RateLimitEvent
- type RateLimitState
- type RecoveryHandler
- type Scheduler
- func (s *Scheduler) CancelRecovery()
- func (s *Scheduler) GetFireTime() (time.Time, bool)
- func (s *Scheduler) GetScheduledTime() (time.Time, bool)
- func (s *Scheduler) IsScheduled() bool
- func (s *Scheduler) ScheduleRecovery(resetTime time.Time)
- func (s *Scheduler) SetBuffer(seconds int)
- func (s *Scheduler) SetRecoveryCallback(callback func() error)
- func (s *Scheduler) SetSessionStatusCheck(callback func() bool)
- type SessionAccessor
- type SessionStatus
Constants ¶
const ( DefaultCooldown = 30 * time.Second DefaultResetBuffer = 5 DefaultRecoveryInput = "1\n" // DefaultFallbackWait is how long to wait before retrying when no reset time is known. DefaultFallbackWait = 30 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferReader ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
func NewDetector ¶
func (*Detector) GetResetTime ¶
func (*Detector) GetState ¶
func (d *Detector) GetState() RateLimitState
func (*Detector) ProcessOutput ¶
func (*Detector) SetCooldown ¶
func (*Detector) SetDetectionCallback ¶
func (*Detector) SetResetBuffer ¶
func (*Detector) SetState ¶
func (d *Detector) SetState(state RateLimitState)
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
func NewEventBus ¶
func NewEventBus() *EventBus
func (*EventBus) Publish ¶
func (eb *EventBus) Publish(event RateLimitEvent)
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(eventType eventType) <-chan RateLimitEvent
type Integration ¶
type Integration struct {
// contains filtered or unexported fields
}
func NewIntegrationWithAccessor ¶
func NewIntegrationWithAccessor(sessionID string, session SessionAccessor, buffer BufferReader) *Integration
func (*Integration) GetManager ¶
func (i *Integration) GetManager() *Manager
func (*Integration) IsEnabled ¶
func (i *Integration) IsEnabled() bool
func (*Integration) SetEnabled ¶
func (i *Integration) SetEnabled(enabled bool)
func (*Integration) Start ¶
func (i *Integration) Start()
func (*Integration) Stop ¶
func (i *Integration) Stop()
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(sessionID string, instance SessionAccessor) *Manager
func (*Manager) GetDetector ¶
func (*Manager) GetEventBus ¶
func (*Manager) GetResetTime ¶ added in v1.35.0
GetResetTime returns the current rate limit reset time, delegating to the detector.
func (*Manager) GetScheduler ¶
func (*Manager) GetState ¶
func (m *Manager) GetState() RateLimitState
func (*Manager) ProcessOutput ¶
func (*Manager) SetCooldown ¶
func (*Manager) SetDetectionCallback ¶ added in v1.35.0
SetDetectionCallback registers an external callback to fire when a rate limit is detected. Called in addition to the internal event bus publish. Safe to call with nil to clear.
func (*Manager) SetEnabled ¶
func (*Manager) SetRecoveryCallback ¶ added in v1.35.0
SetRecoveryCallback registers an external callback to fire when recovery completes. success=true means recovery input was sent successfully; false means it failed.
func (*Manager) SetResetBuffer ¶
type PTYConsumer ¶
type PTYConsumer struct {
// contains filtered or unexported fields
}
func NewPTYConsumer ¶
func NewPTYConsumer(buffer BufferReader, manager *Manager) *PTYConsumer
func (*PTYConsumer) GetManager ¶ added in v1.35.0
func (pc *PTYConsumer) GetManager() *Manager
GetManager returns the underlying Manager for advanced callback wiring.
func (*PTYConsumer) GetRateLimitState ¶
func (pc *PTYConsumer) GetRateLimitState() RateLimitState
func (*PTYConsumer) GetResetTime ¶ added in v1.35.0
func (pc *PTYConsumer) GetResetTime() time.Time
GetResetTime returns the current rate limit reset time from the underlying manager.
func (*PTYConsumer) IsEnabled ¶
func (pc *PTYConsumer) IsEnabled() bool
func (*PTYConsumer) NotifyOutput ¶ added in v1.35.0
func (pc *PTYConsumer) NotifyOutput()
NotifyOutput signals the poll loop that new data is available, avoiding the 500ms polling delay. The send is non-blocking: if a notification is already pending, the extra signal is dropped rather than blocking the caller.
func (*PTYConsumer) SetEnabled ¶
func (pc *PTYConsumer) SetEnabled(enabled bool)
func (*PTYConsumer) Start ¶
func (pc *PTYConsumer) Start()
func (*PTYConsumer) Stop ¶
func (pc *PTYConsumer) Stop()
type RateLimitEvent ¶
type RateLimitState ¶
type RateLimitState int
const ( StateNone RateLimitState = iota StateWaiting StateRecovering StateRecovered StateFailed )
type RecoveryHandler ¶
type RecoveryHandler struct {
// contains filtered or unexported fields
}
func NewRecoveryHandler ¶
func NewRecoveryHandler(sessionID string, sendInput func([]byte) error) *RecoveryHandler
func (*RecoveryHandler) Execute ¶
func (h *RecoveryHandler) Execute(input []byte) error
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) CancelRecovery ¶
func (s *Scheduler) CancelRecovery()
func (*Scheduler) GetFireTime ¶ added in v1.35.0
GetFireTime returns the actual time the scheduled timer will fire. Returns zero time and false when no timer is scheduled. Useful for testing the fallback wait duration.
func (*Scheduler) IsScheduled ¶
func (*Scheduler) ScheduleRecovery ¶
func (*Scheduler) SetRecoveryCallback ¶
func (*Scheduler) SetSessionStatusCheck ¶
type SessionAccessor ¶
type SessionStatus ¶
type SessionStatus int
const ( SessionStatusRunning SessionStatus = iota SessionStatusReady SessionStatusPaused SessionStatusStopped )
func StatusToSessionStatus ¶
func StatusToSessionStatus(s int) SessionStatus