server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server exposes the FPGA gzip pipeline as a small HTTP service.

The service is intentionally a separate process boundary from FUSE or an application using the SDK. A request supplies Content-Length because the FPGA shell must know the complete input size before H2C starts. The response body is a standard gzip stream and is written as the FPGA produces it.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBusy means the bounded request queue is full.
	ErrBusy = errors.New("fpga-gzip service queue is full")
	// ErrContentLength means the client used chunked/unknown-length input.
	// The FPGA shell cannot start a transaction without an exact input length.
	ErrContentLength = errors.New("Content-Length is required")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	HardwareFactory func(context.Context) (pipeline.Hardware, error)
	Options         pipeline.Options

	// MaxConcurrent is normally one for a single XDMA H2C/C2H pair. It may be
	// raised when HardwareFactory selects independent FPGA streams.
	MaxConcurrent int
	// QueueDepth bounds requests waiting for a worker. A full queue returns
	// HTTP 503 instead of buffering request bodies in the daemon.
	QueueDepth int
	// MaxInputBytes limits request bodies. Zero disables the limit.
	MaxInputBytes int64
}

Config controls one service instance. HardwareFactory is called once for each admitted request and must return a fresh hardware handle. A Device's streaming descriptors are closed when a transaction ends, so sharing one handle across requests is not supported.

type Option

type Option func(*Server) error

Option customizes a Server without changing the transport or pipeline configuration. Options are applied at construction time.

func WithAlgorithms added in v0.0.3

func WithAlgorithms(algorithms ...firmware.Algorithm) Option

WithAlgorithms enables request algorithms for a multi-image daemon. An image still contains one algorithm. A mismatch returns HTTP 409 before reset/DMA. Without this option the service accepts only gzip.

func WithAuth

func WithAuth(token string) Option

WithAuth enables Bearer-token authentication for /compress and /metrics. Authentication is disabled by default. /healthz remains public for load balancer and service-manager probes.

type Server

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

Server is an HTTP handler and listener lifecycle for the compression daemon.

func New

func New(cfg Config, options ...Option) (*Server, error)

New validates config and creates a service. A zero Options value selects the SDK defaults; non-zero options are passed to pipeline.RunReader unchanged.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the service's net/http handler. It can be mounted below a reverse proxy or used with httptest without opening a socket.

func (*Server) ListenAndServeTCP

func (s *Server) ListenAndServeTCP(ctx context.Context, addr string) error

ListenAndServeTCP listens on addr and serves HTTP until ctx is canceled.

func (*Server) ListenAndServeUnix

func (s *Server) ListenAndServeUnix(ctx context.Context, path string, mode os.FileMode) error

ListenAndServeUnix listens on a Unix-domain socket. A stale socket left by a crashed daemon is removed; an active listener is never replaced.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) error

Serve runs an HTTP server on l until ctx is canceled or the listener fails.

Jump to

Keyboard shortcuts

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