server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(cfg *config.Config) error

ListenAndServe is a convenience function that creates and starts a server

func RunWithContext

func RunWithContext(ctx context.Context, opts *Options) error

RunWithContext runs the server with a custom context

Types

type CacheServer

type CacheServer interface {
	// Start starts the server (blocking)
	Start() error

	// Shutdown gracefully shuts down the server
	Shutdown(timeout time.Duration) error

	// Config returns the current configuration
	Config() *config.Config

	// Stats returns cache statistics
	Stats() map[string]interface{}
}

CacheServer is the main server interface that can be embedded in other applications

func New

func New(opts *Options) (CacheServer, error)

New creates a new cache server instance

type Handler

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

ServeHTTP allows embedding the cache server as an http.Handler

type Options

type Options struct {
	// Config is the server configuration
	Config *config.Config

	// Logger is the logger to use (if nil, creates a new one)
	Logger *logrus.Logger

	// AuthValidator is a custom authentication validator (optional)
	// If provided, overrides the default basic auth
	AuthValidator userpass.AuthenticateFunc

	// OnBlobAccess is called when a blob is accessed (optional)
	OnBlobAccess func(digest string, size int64)

	// OnBlobDelete is called when a blob is deleted (optional)
	OnBlobDelete func(digest string)
}

Options for creating a new server

Jump to

Keyboard shortcuts

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