server

package
v0.0.0-...-668d940 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package server assembles the ably-server process: flag/env/config parsing, storage/realtime/REST wiring, HTTP routing, and graceful shutdown. cmd/ably-server is a thin wrapper that calls Run; tests (including the //go:build integration SDK suites in internal/server/integrationtest) call Run directly so they can discover ephemeral listener addresses via Opts.Ready/DebugReady without shelling out to a built binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts Opts) int

Run executes the server and returns the process exit code. All inputs are passed via Opts so the function is testable without touching package-level state.

Types

type Opts

type Opts struct {
	// Args is the slice of CLI args (excluding os.Args[0]).
	Args []string

	// Getenv resolves an environment variable; tests pass a stub.
	Getenv func(string) string

	// Out is the writer used for logs and flag-parsing errors.
	Out io.Writer

	// Ready, when non-nil, receives the bound listener's address once
	// net.Listen returns — used by tests that pass --listen=:0 to
	// discover the ephemeral port. The send is bounded by ctx so a
	// missing receiver does not deadlock startup.
	Ready chan<- net.Addr

	// DebugReady, when non-nil, receives the bound debug listener's
	// address once it starts — used by tests that pass
	// --debug-listen=:0 to discover the ephemeral port. Only sent to
	// when --debug-listen is set; the send is bounded by ctx.
	DebugReady chan<- net.Addr
}

Opts bundles Run's inputs so the production main() and tests share one entry point. Args/Getenv/Out are required; Ready is an optional testing hook (see field doc).

Jump to

Keyboard shortcuts

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