Documentation
¶
Index ¶
- Constants
- Variables
- func IsNumeric(s string) bool
- type AuditEntry
- type Config
- type KillResult
- type KillStats
- type Killer
- type PortInfo
- type ProcessInfo
- type TargetMode
- type Theme
- type UI
- func (u *UI) ConfirmKill(infos []*ProcessInfo, force bool) bool
- func (u *UI) Debug(format string, args ...interface{})
- func (u *UI) PrintError(format string, args ...interface{})
- func (u *UI) PrintInfo(format string, args ...interface{})
- func (u *UI) PrintPrimary(format string, args ...interface{})
- func (u *UI) PrintSuccess(format string, args ...interface{})
- func (u *UI) PrintUsage()
- func (u *UI) PrintWarning(format string, args ...interface{})
- func (u *UI) Println(args ...interface{})
- func (u *UI) RenderKillResult(result *KillResult)
- func (u *UI) RenderPortsJSON(ports []PortInfo)
- func (u *UI) RenderPortsTable(ports []PortInfo)
- func (u *UI) RenderProcessTable(infos []*ProcessInfo, target string, mode TargetMode)
- func (u *UI) RenderProcessTree(infos []*ProcessInfo)
- func (u *UI) SetOutput(w io.Writer)
- func (u *UI) Verbose(format string, args ...interface{})
- type UIOption
- type Watcher
- type WatcherConfig
Constants ¶
const ( DefaultTimeout = 5 * time.Second DefaultParallelism = 0 // resolved at runtime to GOMAXPROCS AutoConfirmLimit = 5 // prompt user when matching more than this many processes )
Default configuration values
Variables ¶
var ( BuildTime = "unknown" GitCommit = "unknown" )
Build info
var Version = "dev"
Version is set at build time via ldflags
Functions ¶
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Timestamp time.Time `json:"timestamp"`
Action string `json:"action"`
Target string `json:"target"`
Mode string `json:"mode"`
PIDs []int32 `json:"pids"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
User string `json:"user"`
DryRun bool `json:"dry_run"`
Force bool `json:"force"`
Tree bool `json:"tree"`
DurationMs int64 `json:"duration_ms"`
Version string `json:"version"`
}
AuditEntry represents a structured audit log entry
type Config ¶
type Config struct {
Force bool
Timeout time.Duration
Verbose bool
DryRun bool // explicit --dry flag; redundant when KillEnabled is false
KillEnabled bool // must be explicitly true to perform actual kills; false = dry-run always
Interactive bool
Quiet bool
Tree bool
All bool
Regex bool
AuditLog string
Parallelism int
}
Config holds all kill operation parameters
func (Config) IsDryRun ¶
IsDryRun reports whether this config will result in a preview-only run. Killing is live only when KillEnabled is explicitly true and DryRun is false.
func (Config) WithDefaults ¶
WithDefaults returns a Config with safe zero-value defaults applied.
type KillResult ¶
type KillResult struct {
Killed int
Failed int
Skipped int
DryRun bool // true when the run was preview-only
Duration time.Duration
PIDs []int32
Error error
}
KillResult represents the outcome of a kill operation
type Killer ¶
type Killer struct {
// contains filtered or unexported fields
}
Killer executes process termination operations
func (*Killer) GetProcesses ¶
func (k *Killer) GetProcesses(ctx context.Context, target string, mode TargetMode) ([]*ProcessInfo, error)
GetProcesses returns process info without killing (for discovery)
func (*Killer) Kill ¶
func (k *Killer) Kill(ctx context.Context, target string, mode TargetMode) (*KillResult, error)
Kill performs the kill operation and returns structured results
type PortInfo ¶
type PortInfo struct {
Protocol string `json:"protocol"`
Port int `json:"port"`
PID int32 `json:"pid"`
Name string `json:"name"`
Cmdline string `json:"cmdline,omitempty"`
}
PortInfo represents a listening port
type ProcessInfo ¶
type ProcessInfo struct {
PID int32
PPID int32
Name string
Cmdline string
User string
CPU float64
Mem float32
MemRSS uint64
Status string
Ports []int
Cgroup string
Threads int32
StartTime int64
Children []*ProcessInfo
}
ProcessInfo holds enriched process metadata
type TargetMode ¶
type TargetMode int
TargetMode defines how to interpret the target
const ( ModeAuto TargetMode = iota ModePort ModeName ModePID ModeCgroup ModeCPUAbove ModeMemAbove )
func (TargetMode) String ¶
func (m TargetMode) String() string
type Theme ¶
type Theme struct {
Primary *color.Color
Success *color.Color
Error *color.Color
Warning *color.Color
Info *color.Color
Highlight *color.Color
}
Theme defines colors for UI elements
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI handles all user interface rendering
func (*UI) ConfirmKill ¶
func (u *UI) ConfirmKill(infos []*ProcessInfo, force bool) bool
ConfirmKill prompts for user confirmation before a destructive operation. It accepts the infos slice as returned by Kill (may be a forest in --tree mode) and flattens it internally so totals include all descendants.
func (*UI) PrintError ¶
PrintError prints with error color
func (*UI) PrintPrimary ¶
PrintPrimary prints with primary color
func (*UI) PrintSuccess ¶
PrintSuccess prints with success color
func (*UI) PrintWarning ¶
PrintWarning prints with warning color
func (*UI) RenderKillResult ¶
func (u *UI) RenderKillResult(result *KillResult)
RenderKillResult displays kill operation results.
When the run was a dry-run (preview), it prints a clear banner showing what would have been killed and how to proceed. When live, it prints the outcome.
func (*UI) RenderPortsJSON ¶
RenderPortsJSON outputs ports as JSON
func (*UI) RenderPortsTable ¶
RenderPortsTable displays listening ports
func (*UI) RenderProcessTable ¶
func (u *UI) RenderProcessTable(infos []*ProcessInfo, target string, mode TargetMode)
RenderProcessTable displays processes in a table
func (*UI) RenderProcessTree ¶
func (u *UI) RenderProcessTree(infos []*ProcessInfo)
RenderProcessTree displays hierarchical process structure
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher continuously monitors and kills processes
func NewWatcher ¶
func NewWatcher(killer *Killer, config WatcherConfig) *Watcher
NewWatcher creates a new watcher
type WatcherConfig ¶
type WatcherConfig struct {
Interval time.Duration
OnKill func(*KillResult)
}
WatcherConfig holds watcher configuration