integrations

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package integrations provides coordination between external tool integrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartGlobalCoordinator

func StartGlobalCoordinator() error

StartGlobalCoordinator starts the global coordinator if not already running.

func StopGlobalCoordinator

func StopGlobalCoordinator()

StopGlobalCoordinator stops the global coordinator if running.

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator manages interactions between caut and CAAM integrations. It monitors caut alerts for high usage and proactively triggers CAAM account switches before hitting actual rate limits.

func GetGlobalCoordinator

func GetGlobalCoordinator() *Coordinator

GetGlobalCoordinator returns the global coordinator singleton.

func InitGlobalCoordinator

func InitGlobalCoordinator(cfg *CoordinatorConfig) *Coordinator

InitGlobalCoordinator initializes the global coordinator with specific config.

func NewCoordinator

func NewCoordinator(cfg *CoordinatorConfig) *Coordinator

NewCoordinator creates a new integration coordinator.

func NewCoordinatorFromConfig

func NewCoordinatorFromConfig(intCfg *config.IntegrationsConfig) *Coordinator

NewCoordinatorFromConfig creates a coordinator from NTM config.

func (*Coordinator) GetLastSwitchTime

func (c *Coordinator) GetLastSwitchTime(provider string) (time.Time, bool)

GetLastSwitchTime returns when the last switch occurred for a provider.

func (*Coordinator) IsRunning

func (c *Coordinator) IsRunning() bool

IsRunning returns true if the coordinator is active.

func (*Coordinator) OnCautAlert

func (c *Coordinator) OnCautAlert(provider string, usagePercent float64)

OnCautAlert handles alerts from the caut poller. This is the main entry point for proactive switching.

func (*Coordinator) ResetCooldown

func (c *Coordinator) ResetCooldown(provider string)

ResetCooldown clears the cooldown for a provider (for testing or manual override).

func (*Coordinator) SetSwitchCallback

func (c *Coordinator) SetSwitchCallback(cb SwitchCallback)

SetSwitchCallback sets a callback to be invoked on account switches.

func (*Coordinator) Start

func (c *Coordinator) Start() error

Start begins monitoring for proactive switching opportunities.

func (*Coordinator) Stop

func (c *Coordinator) Stop()

Stop halts the coordinator.

type CoordinatorConfig

type CoordinatorConfig struct {
	// CAAMEnabled indicates if CAAM integration is available
	CAAMEnabled bool
	// CautEnabled indicates if caut integration is available
	CautEnabled bool
	// AutoRotate enables automatic CAAM rotation on high caut usage
	AutoRotate bool
	// ProactiveThreshold is the usage percentage to trigger pre-emptive switch (0-100)
	ProactiveThreshold float64
	// SwitchCooldown is minimum time between switches for the same provider
	SwitchCooldown time.Duration
	// CheckInterval is how often to check for alerts
	CheckInterval time.Duration
}

CoordinatorConfig holds configuration for the coordinator.

func DefaultCoordinatorConfig

func DefaultCoordinatorConfig() CoordinatorConfig

DefaultCoordinatorConfig returns sensible defaults.

type SwitchCallback

type SwitchCallback func(event SwitchEvent)

SwitchCallback is called when an account switch occurs.

type SwitchEvent

type SwitchEvent struct {
	Provider          string    `json:"provider"`
	UsagePercent      float64   `json:"usage_percent"`
	Reason            string    `json:"reason"` // "proactive" or "rate_limit"
	PreviousAccount   string    `json:"previous_account,omitempty"`
	NewAccount        string    `json:"new_account,omitempty"`
	Success           bool      `json:"success"`
	Error             string    `json:"error,omitempty"`
	Timestamp         time.Time `json:"timestamp"`
	AccountsRemaining int       `json:"accounts_remaining,omitempty"`
}

SwitchEvent contains details about a proactive account switch.

Directories

Path Synopsis
Package caut provides integration with the caut (Cloud API Usage Tracker) tool.
Package caut provides integration with the caut (Cloud API Usage Tracker) tool.
Package dcg provides integration with the Destructive Command Guard (DCG) tool, including audit logging for blocked commands.
Package dcg provides integration with the Destructive Command Guard (DCG) tool, including audit logging for blocked commands.
Package pt provides integration with process_triage (pt) for Bayesian agent health monitoring.
Package pt provides integration with process_triage (pt) for Bayesian agent health monitoring.
Package rano provides integration with the rano network observer for per-agent API tracking.
Package rano provides integration with the rano network observer for per-agent API tracking.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL