setenabled

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package setenabled implements the "enable or disable a rule" use case. It is the only mutation permitted on built-in rules. It toggles the disabled flag, reloads the registry snapshot, and returns the resulting rule view.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builtins

type Builtins interface {
	IsBuiltin(id string) bool
	Get(id string) (rule.Rule, bool)
}

Builtins reports and returns immutable built-in rules.

type Command

type Command struct {
	ID      string
	Enabled bool
}

Command is the input for the setenabled use case.

type CommandHandler

type CommandHandler interface {
	Handle(ctx context.Context, cmd Command) (CommandResponse, error)
}

CommandHandler handles the setenabled use case.

type CommandResponse

type CommandResponse struct {
	Rule    rule.Rule
	Builtin bool
	Enabled bool
}

CommandResponse is the output of the setenabled use case: the affected rule, whether it is built-in, and its resulting enabled state.

type Reloader

type Reloader interface {
	Reload(ctx context.Context) error
}

Reloader rebuilds and atomically swaps the compiled registry snapshot.

type RuleStore

type RuleStore interface {
	GetRule(ctx context.Context, id string) (rule.Rule, error)
	SetRuleDisabled(ctx context.Context, id string, disabled bool) error
}

RuleStore reads custom rules and toggles the disabled flag.

type UseCase

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

UseCase enables or disables guardrail rules (built-in or custom).

func NewUseCase

func NewUseCase(store RuleStore, builtins Builtins, reloader Reloader) *UseCase

NewUseCase creates a new UseCase.

func (*UseCase) Handle

func (uc *UseCase) Handle(ctx context.Context, cmd Command) (CommandResponse, error)

Handle enables or disables one rule (built-in or custom) and reloads the registry. Disabling is the only mutation permitted on built-in rules.

Jump to

Keyboard shortcuts

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