refactor: shared service layer, default IRC port, smaller functions
All checks were successful
check / check (push) Successful in 2m37s

Wire up service.Service in HTTP handlers and delegate cleanupUser to
svc.BroadcastQuit for consistent quit/part logic across transports.
Default IRC_LISTEN_ADDR to :6667, remove unused import, fix all lint
issues (dogsled, funcorder, wrapcheck, varnamelen, nolintlint).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
user
2026-03-25 13:39:32 -07:00
parent 42157a7b23
commit 2853dc8a1f
10 changed files with 1100 additions and 812 deletions

View File

@@ -11,6 +11,7 @@ import (
"git.eeqj.de/sneak/neoirc/internal/config"
"git.eeqj.de/sneak/neoirc/internal/db"
"git.eeqj.de/sneak/neoirc/internal/logger"
"git.eeqj.de/sneak/neoirc/internal/service"
"go.uber.org/fx"
)
@@ -23,6 +24,7 @@ type Params struct {
Config *config.Config
Database *db.Database
Broker *broker.Broker
Service *service.Service
}
// Server is the TCP IRC protocol server.
@@ -31,6 +33,7 @@ type Server struct {
cfg *config.Config
database *db.Database
brk *broker.Broker
svc *service.Service
listener net.Listener
mu sync.Mutex
conns map[*Conn]struct{}
@@ -49,6 +52,7 @@ func New(
cfg: params.Config,
database: params.Database,
brk: params.Broker,
svc: params.Service,
conns: make(map[*Conn]struct{}),
listener: nil,
cancel: nil,
@@ -133,7 +137,7 @@ func (s *Server) acceptLoop(ctx context.Context) {
client := newConn(
ctx, tcpConn, s.log,
s.database, s.brk, s.cfg,
s.database, s.brk, s.cfg, s.svc,
)
s.mu.Lock()