Documentation
¶
Index ¶
- func LoadConfig(configPath string) (*gateway.Config, error)
- func StripColorCodes(input string) string
- type ColorManager
- func (cm *ColorManager) DisableColors()
- func (cm *ColorManager) FormatPrefix(prefix string, rule *gateway.Rule) string
- func (cm *ColorManager) GetColorForRule(rule *gateway.Rule) *color.Color
- func (cm *ColorManager) GetColoredString(text string, rule *gateway.Rule) string
- func (cm *ColorManager) IsEnabled() bool
- type ColoredPrefixWriter
- type LogManager
- type Orchestrator
- type OrchestratorV2
- func (o *OrchestratorV2) GetConfig() *gateway.Config
- func (o *OrchestratorV2) GetRuleStatus(ruleName string) (*gateway.RuleStatus, bool)
- func (o *OrchestratorV2) GetWatchedPaths() []string
- func (o *OrchestratorV2) ProjectRoot() string
- func (o *OrchestratorV2) ReadFileContent(path string) ([]byte, error)
- func (o *OrchestratorV2) SetGlobalDebounceDelay(duration time.Duration)
- func (o *OrchestratorV2) SetRuleDebounceDelay(ruleName string, duration time.Duration) error
- func (o *OrchestratorV2) SetRuleVerbose(ruleName string, verbose bool) error
- func (o *OrchestratorV2) SetVerbose(verbose bool)
- func (o *OrchestratorV2) Start() error
- func (o *OrchestratorV2) Stop() error
- func (o *OrchestratorV2) StreamLogs(ruleName string, filter string, ...) error
- func (o *OrchestratorV2) TriggerRule(ruleName string) error
- type PrefixWriter
- type RuleRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
LoadConfig reads and unmarshals the .devloop.yaml configuration file, resolving all relative watch paths to be absolute from the config file's location.
func StripColorCodes ¶ added in v0.0.27
StripColorCodes removes ANSI color codes from a string
Types ¶
type ColorManager ¶ added in v0.0.27
type ColorManager struct {
// contains filtered or unexported fields
}
ColorManager handles color assignment and formatting for rule output
func NewColorManager ¶ added in v0.0.27
func NewColorManager(settings *gateway.Settings) *ColorManager
NewColorManager creates a new color manager with the given settings
func (*ColorManager) DisableColors ¶ added in v0.0.27
func (cm *ColorManager) DisableColors()
DisableColors explicitly disables color output for this ColorManager only
func (*ColorManager) FormatPrefix ¶ added in v0.0.27
func (cm *ColorManager) FormatPrefix(prefix string, rule *gateway.Rule) string
FormatPrefix applies color formatting to a prefix string
func (*ColorManager) GetColorForRule ¶ added in v0.0.27
func (cm *ColorManager) GetColorForRule(rule *gateway.Rule) *color.Color
GetColorForRule returns the appropriate color for a given rule
func (*ColorManager) GetColoredString ¶ added in v0.0.27
func (cm *ColorManager) GetColoredString(text string, rule *gateway.Rule) string
GetColoredString returns a colored version of the input string for the given rule
func (*ColorManager) IsEnabled ¶ added in v0.0.27
func (cm *ColorManager) IsEnabled() bool
IsEnabled returns whether color formatting is enabled
type ColoredPrefixWriter ¶ added in v0.0.27
type ColoredPrefixWriter struct {
// contains filtered or unexported fields
}
ColoredPrefixWriter is an enhanced io.Writer that adds colored prefixes to each line of output It separates terminal output (with colors) from file output (without colors)
func NewColoredPrefixWriter ¶ added in v0.0.27
func NewColoredPrefixWriter(writers []io.Writer, prefix string, colorManager *ColorManager, rule *gateway.Rule) *ColoredPrefixWriter
NewColoredPrefixWriter creates a new ColoredPrefixWriter
func (*ColoredPrefixWriter) UpdatePrefix ¶ added in v0.0.27
func (cpw *ColoredPrefixWriter) UpdatePrefix(newPrefix string)
UpdatePrefix updates the prefix and regenerates the colored version
func (*ColoredPrefixWriter) Write ¶ added in v0.0.27
func (cpw *ColoredPrefixWriter) Write(p []byte) (n int, err error)
Write implements the io.Writer interface with color support
func (*ColoredPrefixWriter) WriteToFileOnly ¶ added in v0.0.27
func (cpw *ColoredPrefixWriter) WriteToFileOnly(p []byte) (n int, err error)
WriteToFileOnly writes output only to file writers (without colors)
func (*ColoredPrefixWriter) WriteToTerminalOnly ¶ added in v0.0.27
func (cpw *ColoredPrefixWriter) WriteToTerminalOnly(p []byte) (n int, err error)
WriteToTerminalOnly writes output only to terminal writers (with colors)
type LogManager ¶
type LogManager struct {
// contains filtered or unexported fields
}
LogManager manages log files and provides streaming capabilities.
func NewLogManager ¶
func NewLogManager(logDir string) (*LogManager, error)
NewLogManager creates a new LogManager instance.
func (*LogManager) Close ¶
func (lm *LogManager) Close() error
Close closes all open file handles managed by the LogManager.
func (*LogManager) GetWriter ¶
func (lm *LogManager) GetWriter(ruleName string) (io.Writer, error)
GetWriter returns an io.Writer for a specific rule's log file. It also signals that the rule's execution has started.
func (*LogManager) SignalFinished ¶
func (lm *LogManager) SignalFinished(ruleName string)
SignalFinished signals that a rule's execution has finished.
func (*LogManager) StreamLogs ¶
func (lm *LogManager) StreamLogs(ruleName, filter string, stream pb.GatewayClientService_StreamLogsClientServer) error
StreamLogs streams logs for a given rule to the provided gRPC stream.
type Orchestrator ¶
type Orchestrator interface {
Start() error
Stop() error
GetConfig() *gateway.Config
TriggerRule(ruleName string) error
GetRuleStatus(ruleName string) (*gateway.RuleStatus, bool)
GetWatchedPaths() []string
ReadFileContent(path string) ([]byte, error)
SetGlobalDebounceDelay(duration time.Duration)
SetVerbose(verbose bool)
}
Orchestrator interface defines the common methods for orchestrator implementations
func NewOrchestratorForTesting ¶
func NewOrchestratorForTesting(configPath, gatewayAddr string) (Orchestrator, error)
NewOrchestratorForTesting creates a new V2 orchestrator for testing
type OrchestratorV2 ¶
type OrchestratorV2 struct {
ConfigPath string
Config *gateway.Config
Verbose bool
Watcher *fsnotify.Watcher
LogManager *LogManager
ColorManager *ColorManager
// contains filtered or unexported fields
}
OrchestratorV2 manages file watching and delegates execution to RuleRunners
func NewOrchestratorV2 ¶
func NewOrchestratorV2(configPath string, gatewayAddr string) (*OrchestratorV2, error)
NewOrchestratorV2 creates a new orchestrator using RuleRunners
func (*OrchestratorV2) GetConfig ¶
func (o *OrchestratorV2) GetConfig() *gateway.Config
GetConfig returns the orchestrator's configuration.
func (*OrchestratorV2) GetRuleStatus ¶
func (o *OrchestratorV2) GetRuleStatus(ruleName string) (*gateway.RuleStatus, bool)
GetRuleStatus returns the status of a specific rule
func (*OrchestratorV2) GetWatchedPaths ¶
func (o *OrchestratorV2) GetWatchedPaths() []string
GetWatchedPaths returns a unique list of all paths being watched by any rule
func (*OrchestratorV2) ProjectRoot ¶
func (o *OrchestratorV2) ProjectRoot() string
ProjectRoot returns the project root directory
func (*OrchestratorV2) ReadFileContent ¶
func (o *OrchestratorV2) ReadFileContent(path string) ([]byte, error)
ReadFileContent reads and returns the content of a specified file
func (*OrchestratorV2) SetGlobalDebounceDelay ¶
func (o *OrchestratorV2) SetGlobalDebounceDelay(duration time.Duration)
SetGlobalDebounceDelay sets the default debounce delay for all rules
func (*OrchestratorV2) SetRuleDebounceDelay ¶
func (o *OrchestratorV2) SetRuleDebounceDelay(ruleName string, duration time.Duration) error
SetRuleDebounceDelay sets the debounce delay for a specific rule
func (*OrchestratorV2) SetRuleVerbose ¶
func (o *OrchestratorV2) SetRuleVerbose(ruleName string, verbose bool) error
SetRuleVerbose sets the verbose flag for a specific rule
func (*OrchestratorV2) SetVerbose ¶
func (o *OrchestratorV2) SetVerbose(verbose bool)
SetVerbose sets the global verbose flag
func (*OrchestratorV2) Start ¶
func (o *OrchestratorV2) Start() error
Start begins file watching and initializes all RuleRunners
func (*OrchestratorV2) Stop ¶
func (o *OrchestratorV2) Stop() error
Stop gracefully shuts down the orchestrator
func (*OrchestratorV2) StreamLogs ¶
func (o *OrchestratorV2) StreamLogs(ruleName string, filter string, stream pb.GatewayClientService_StreamLogsClientServer) error
StreamLogs streams the logs for a given rule to the provided gRPC stream
func (*OrchestratorV2) TriggerRule ¶
func (o *OrchestratorV2) TriggerRule(ruleName string) error
TriggerRule manually triggers the execution of a specific rule
type PrefixWriter ¶
type PrefixWriter struct {
// contains filtered or unexported fields
}
PrefixWriter is an io.Writer that adds a prefix to each line of output.
type RuleRunner ¶
type RuleRunner interface {
// Lifecycle management
Start() error // Start monitoring and execution
Stop() error // Stop all processes and cleanup
Restart() error // Restart all processes
Execute() error // Execute the rule's commands
// Status and state
IsRunning() bool
GetStatus() *gateway.RuleStatus
GetRule() gateway.Rule
// Debouncing
TriggerDebounced() // Called when a file change is detected
// Process management
TerminateProcesses() error
// Configuration
SetDebounceDelay(duration time.Duration)
SetVerbose(verbose bool)
}
RuleRunner manages the execution lifecycle of a single rule
func NewRuleRunner ¶
func NewRuleRunner(rule gateway.Rule, orchestrator *OrchestratorV2) RuleRunner
NewRuleRunner creates a new RuleRunner for the given rule