server

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package server provides the HTTP server for the content cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address to listen on (e.g., ":8080")
	Address string

	// StoragePath is the root path for storage
	StoragePath string

	// AuthToken is the bearer token for inbound authentication.
	// When empty, authentication is disabled.
	AuthToken string

	// Credentials holds resolved upstream credentials from the credentials file.
	// When nil, all protocols use their default upstreams with no auth.
	Credentials *credentials.Credentials

	// UpstreamGoProxy is the upstream Go module proxy URL
	UpstreamGoProxy string

	// UpstreamNPMRegistry is the upstream NPM registry URL
	UpstreamNPMRegistry string

	// UpstreamOCIRegistry is the upstream OCI registry URL
	UpstreamOCIRegistry string

	// OCIPrefix is the routing prefix for the OCI registry.
	// Default: "docker-hub"
	OCIPrefix string

	// OCITagTTL is how long to cache tag->digest mappings.
	// Default: 5 minutes (tags can change, unlike digests)
	OCITagTTL time.Duration

	// UpstreamPyPI is the upstream PyPI Simple API URL
	UpstreamPyPI string

	// PyPIMetadataTTL is how long to cache project metadata.
	// Default: 5 minutes (new versions may be published)
	PyPIMetadataTTL time.Duration

	// UpstreamMaven is the upstream Maven repository URL
	UpstreamMaven string

	// MavenMetadataTTL is how long to cache maven-metadata.xml.
	// Default: 5 minutes (new versions may be published)
	MavenMetadataTTL time.Duration

	// UpstreamRubyGems is the upstream RubyGems registry URL
	UpstreamRubyGems string

	// RubyGemsMetadataTTL is how long to cache versions/info/specs files.
	// Default: 5 minutes (new versions may be published)
	RubyGemsMetadataTTL time.Duration

	// GitAllowedHosts is the allowlist of permitted upstream Git hosts.
	GitAllowedHosts []string

	// GitMaxRequestBodySize is the maximum upload-pack request body size in bytes.
	// Default: 100MB
	GitMaxRequestBodySize int64

	// SumDBName is the name of the checksum database to proxy.
	// Default: sum.golang.org
	SumDBName string

	// UpstreamSumDB is the upstream sumdb URL.
	// Default: https://sum.golang.org
	UpstreamSumDB string

	// CacheTTL is the time-to-live for cached content.
	// Content not accessed within this duration is expired.
	// Zero disables TTL-based expiration.
	CacheTTL time.Duration

	// CacheMaxSize is the maximum size of the cache in bytes.
	// When exceeded, least-recently-used content is evicted.
	// Zero disables size-based eviction.
	CacheMaxSize int64

	// ExpiryCheckInterval is how often to check for expired content.
	// Default is 1 hour.
	ExpiryCheckInterval time.Duration

	// GCInterval is how often to run garbage collection.
	GCInterval time.Duration

	// GCStartupDelay is the delay before first GC run.
	GCStartupDelay time.Duration

	// TLSCertFile is the path to the TLS certificate file.
	// When both TLSCertFile and TLSKeyFile are set, the server starts with TLS.
	TLSCertFile string

	// TLSKeyFile is the path to the TLS private key file.
	TLSKeyFile string

	// Logger for the server
	Logger *slog.Logger
}

Config holds server configuration.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the HTTP server for the content cache.

func New

func New(cfg Config) (*Server, error)

New creates a new server with the given configuration.

func (*Server) Address

func (s *Server) Address() string

Address returns the server's listen address.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server.

func (*Server) Start

func (s *Server) Start() error

Start starts the server.

Jump to

Keyboard shortcuts

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