From 8a5543396908fff3c1909df51065f8f6dabdc626 Mon Sep 17 00:00:00 2001 From: Nick Ficano Date: Sat, 23 May 2026 23:15:28 -0400 Subject: [PATCH] docs: clarify server options defaults --- server/options.go | 9 +++++---- server/options_test.go | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 server/options_test.go diff --git a/server/options.go b/server/options.go index 43cdbfa..66350e6 100644 --- a/server/options.go +++ b/server/options.go @@ -19,13 +19,14 @@ type Options struct { // Version is the runtime's advertised version. Version string // HeartbeatInterval seeds heartbeat_interval_sec in welcome. Zero - // disables heartbeats unless the client negotiates them; default - // is 30s. + // is replaced with the 30s default in withDefaults; omit the + // heartbeat feature if you need to suppress heartbeats entirely. HeartbeatInterval time.Duration // ResumeWindow seeds resume_window_sec; default 600s. ResumeWindow time.Duration - // Verifier authenticates session.hello tokens. nil accepts no - // tokens. + // Verifier authenticates session.hello tokens. When nil, the + // runtime accepts the session and uses hello.Client.Name as the + // principal for anonymous/local mode. Verifier auth.Verifier // Logger is the slog.Logger used by the runtime. nil uses // slog.Default(). diff --git a/server/options_test.go b/server/options_test.go new file mode 100644 index 0000000..334c1e5 --- /dev/null +++ b/server/options_test.go @@ -0,0 +1,20 @@ +package server + +import ( + "testing" + "time" +) + +func TestOptionsWithDefaults(t *testing.T) { + opts := Options{}.withDefaults() + + if got, want := opts.HeartbeatInterval, 30*time.Second; got != want { + t.Fatalf("HeartbeatInterval = %v, want %v", got, want) + } + if got, want := opts.ResumeWindow, 10*time.Minute; got != want { + t.Fatalf("ResumeWindow = %v, want %v", got, want) + } + if opts.Verifier != nil { + t.Fatalf("Verifier = %#v, want nil", opts.Verifier) + } +}