deadline

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package deadline provides deadline enforcement for Connect RPC handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInterceptor

func NewInterceptor(cfg Config) connect.Interceptor

NewInterceptor creates a Connect RPC interceptor that enforces deadlines. It applies DefaultTimeout when no deadline exists on the incoming context, and caps existing deadlines to MaxTimeout if configured.

Panics if:

  • DefaultTimeout <= 0
  • MaxTimeout > 0 && MaxTimeout < DefaultTimeout

Types

type Config

type Config struct {
	// DefaultTimeout is applied when the incoming context has no deadline.
	// Must be positive (> 0).
	DefaultTimeout time.Duration `koanf:"default_timeout"`

	// MaxTimeout caps existing deadlines to min(existingDeadline, MaxTimeout).
	// Zero means no cap is applied (only DefaultTimeout is used).
	// If positive, must be >= DefaultTimeout.
	MaxTimeout time.Duration `koanf:"max_timeout"`
}

Config holds configuration for the deadline interceptor.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible default values.

Jump to

Keyboard shortcuts

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