Botica (Botica v2.0.0)

Copy Markdown View Source

Botica provides environment diagnostics, health checks, and feature flags.

Modules

  • Botica.Doctor — run health checks, summarise, fix failures
  • Botica.Flags — feature flags with ETS backend and per-entity rollouts
  • Botica.Flags.Store — GenServer that owns the ETS table
  • Botica.Flags.Flag — struct for a single flag
  • Botica.Runner.*, Botica.Check.*, Botica.Batteries.* — internal pieces

Feature flags quick start

Botica.Flags.define(:new_dashboard, default: false)
Botica.Flags.define(:beta_search, default: true)
Botica.Flags.define(:rate_limiting, default: false, rollout: 25)

Botica.Flags.enabled?(:new_dashboard)               # false
Botica.Flags.enabled?(:rate_limiting, for: user)    # deterministic per user
Botica.Flags.enable(:new_dashboard)

See Botica.Flags for full API.

Diagnostics quick start

Define a config with checks and use the Doctor module to run diagnostics:

config = %{
  app_name: "myapp",
  checks: [
    %{
      id: :postgresql,
      name: "PostgreSQL",
      description: "Database is accessible",
      priority: 1,
      check: fn -> {:ok, "connected"} end,
      fix: fn -> {:ok, "restarted"} end,
      fix_command: "sudo systemctl start postgresql"
    }
  ]
}

# Run health checks
{:ok, results} = Botica.run(config)

# Run fixes for failed checks
{:ok, report} = Botica.fix(config)

# Quick health check
result = Botica.health_check(config)

# Snapshot of feature flags
summary = Botica.Doctor.flags_summary()
banner = Botica.Doctor.format_flags_summary()

Predefined Checks (Batteries)

Botica includes predefined checks for common services:

config = %{
  app_name: "myapp",
  checks: [
    Botica.Batteries.PostgreSQL.check(),
    Botica.Batteries.Redis.check(),
    Botica.Batteries.Memory.check(),
    Botica.Batteries.Disk.check()
  ]
}

API

Summary

Functions

Returns a list of available predefined checks (batteries).

Runs fixes for all checks that returned an error.

Runs a quick health check and returns a simple status map.

Runs all health checks in parallel and returns structured results.

Runs all health checks in parallel with custom options.

Validates a configuration map.

Functions

all()

See Botica.Flags.all/0.

batteries()

Returns a list of available predefined checks (batteries).

See Botica.Doctor.batteries/0 for full documentation.

count()

See Botica.Flags.count/0.

define(name, opts \\ [])

See Botica.Flags.define/2.

delete(name)

See Botica.Flags.delete/1.

disable(name)

See Botica.Flags.disable/1.

enable(name)

See Botica.Flags.enable/1.

enabled?(name)

See Botica.Flags.enabled?/1.

enabled?(name, opts)

See Botica.Flags.enabled?/2.

fix(config)

Runs fixes for all checks that returned an error.

Returns a detailed report of what was applied, failed, or skipped.

See Botica.Doctor.fix/1 for full documentation.

get(name)

See Botica.Flags.get/1.

health_check(config)

Runs a quick health check and returns a simple status map.

See Botica.Doctor.health_check/1 for full documentation.

run(config)

Runs all health checks in parallel and returns structured results.

See Botica.Doctor.run/1 for full documentation.

run(config, opts)

Runs all health checks in parallel with custom options.

See Botica.Doctor.run/2 for available options.

set(name, opts)

See Botica.Flags.set/2.

validate(config)

Validates a configuration map.

See Botica.Doctor.validate/1 for full documentation.