feat: initial project structure

This commit is contained in:
Olivier 2026-04-14 13:29:24 +00:00
commit cf4957010f
10 changed files with 621 additions and 0 deletions

View file

@ -0,0 +1,58 @@
// Package main is the entrypoint for the claude-failover daemon.
//
// Scope of this stub: load the YAML config from disk, log startup
// information, and block until a termination signal. The real runtime
// (dispatcher, quota-monitor, session-watcher, checkpoint, janitor,
// notifier, account-switcher goroutines) is not implemented yet — see
// docs/architecture.md.
package main
import (
"context"
"flag"
"log"
"os"
"os/signal"
"syscall"
)
// Config mirrors config.example.yaml at a high level. We keep it loose
// here because this stub does not wire real YAML parsing yet; the full
// schema will live in internal/config once implementation starts.
type Config struct {
Path string
}
func loadConfig(path string) (*Config, error) {
// TODO(claude-failover): parse YAML via gopkg.in/yaml.v3 and validate.
if _, err := os.Stat(path); err != nil {
return nil, err
}
return &Config{Path: path}, nil
}
func main() {
var cfgPath string
flag.StringVar(&cfgPath, "config", "config.yaml", "path to YAML config")
flag.Parse()
log.SetFlags(log.LstdFlags | log.Lmicroseconds | log.LUTC)
log.Printf("claude-failover starting (config=%s)", cfgPath)
cfg, err := loadConfig(cfgPath)
if err != nil {
log.Fatalf("config load failed: %v", err)
}
log.Printf("config loaded: %s", cfg.Path)
// TODO: spawn goroutines — dispatcher, quota-monitor, session-watcher,
// checkpoint, janitor, notifier, account-switcher.
ctx, cancel := signal.NotifyContext(context.Background(),
syscall.SIGINT, syscall.SIGTERM)
defer cancel()
log.Printf("claude-failover ready (stub — no workers running)")
<-ctx.Done()
log.Printf("shutdown signal received, exiting")
}