model

package
v0.0.0-...-ce1098a Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Absent   time.Duration = math.MinInt64
	Eternity time.Duration = math.MaxInt64
)
View Source
const TamalaControl = "Tamala-Control"

Variables

View Source
var DefaultSettings = Settings{
	CacheableMethods:   []string{"GET", "HEAD"},
	HeuristicFreshness: 60 * time.Second,
	IgnoreVary:         []string{},
	MaxCacheEntrySize:  4 * 1024 * 1024,
	ReqVia:             NewVia("proxy"),
	ResVia:             NewVia("tamala"),
	Retain:             retention.Policy{Latest: 1},
}
View Source
var Product = "Tamala"

Functions

func ParseDate

func ParseDate(s string) (time.Time, error)

Types

type Request

type Request struct {
	*http.Request

	Received time.Time
	Settings
	CacheableMethod bool

	// Request cache directives
	MaxAge       time.Duration // may be Absent
	MaxStale     time.Duration // may be Eternity
	MinFresh     time.Duration // may be Absent
	NoCache      bool
	NoStore      bool
	OnlyIfCached bool

	KeyPath string

	Err         error
	Response    *http.Response
	Bump, Probe bool
	// contains filtered or unexported fields
}

func ErectRequest

func ErectRequest(t testing.TB, opts ...any) *Request

func Retrieve

func Retrieve(r *http.Request) *Request

func WrapRequest

func WrapRequest(r *http.Request, logger *slog.Logger) *Request

func (*Request) CheckProcessed

func (req *Request) CheckProcessed() time.Time

func (*Request) Debug

func (req *Request) Debug(msg string, args ...any)

func (*Request) Error

func (req *Request) Error(msg string, args ...any)

func (*Request) Info

func (req *Request) Info(msg string, args ...any)

func (*Request) LocalAddr

func (req *Request) LocalAddr() net.Addr

func (*Request) ParseBool

func (req *Request) ParseBool(s string, x *bool, where string) bool

func (*Request) ParseDate

func (req *Request) ParseDate(s string, x *time.Time, where string) bool

func (*Request) ParseInt

func (req *Request) ParseInt(s string, x *int, where string) bool

func (*Request) ParseSeconds

func (req *Request) ParseSeconds(s string, x *time.Duration, where string) bool

func (*Request) ParseSecondsOrEternity

func (req *Request) ParseSecondsOrEternity(s string, x *time.Duration, where string) bool

func (*Request) ParseSettings

func (req *Request) ParseSettings()

func (*Request) ParseTime

func (req *Request) ParseTime(s string, x *time.Time, where string) bool

func (*Request) Processed

func (req *Request) Processed()

func (*Request) Warn

func (req *Request) Warn(msg string, args ...any)

type Settings

type Settings struct {
	CacheableMethods     []string
	Cutoff               time.Time
	ForceDisconnected    bool
	HeuristicFreshness   time.Duration
	IgnoreMustRevalidate bool
	IgnoreNoCache        bool
	IgnoreNoStore        bool
	IgnoreVary           []string
	MaxCacheEntrySize    int
	MinFreshness         time.Duration
	NextProxy            *url.URL
	ReqVia               Via
	ResVia               Via
	Retain               retention.Policy
	Shared               bool
	StaleIfError         time.Duration
}

type Via

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

func NewVia

func NewVia(v string) Via

func (Via) Apply

func (via Via) Apply(h http.Header, proto string)

func (Via) Unapply

func (via Via) Unapply(h http.Header)

Jump to

Keyboard shortcuts

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