Documentation
¶
Index ¶
- Constants
- Variables
- func LoggingRequestContext(r *http.Request) *loggingRequestContext
- func NewBufferedReadCloser(r io.ReadCloser, maxBytes, maxMemBytes int64) (io.ReadCloser, error)
- func PerformConcurrently(fns ...func())
- func SetErrorResponse(w http.ResponseWriter, r *http.Request, statusCode int, templateArguments any)
- func WithErrorPageMiddleware(pages fs.FS, root bool, next http.Handler) (http.Handler, error)
- func WithLoggingMiddleware(logger *slog.Logger, httpPort, httpsPort int, next http.Handler) http.Handler
- func WithRequestBufferMiddleware(maxMemBytes, maxBytes int64, next http.Handler) http.Handler
- func WithRequestIDMiddleware(next http.Handler) http.Handler
- func WithRequestStartMiddleware(next http.Handler) http.Handler
- func WithResponseBufferMiddleware(maxMemBytes, maxBytes int64, next http.Handler) http.Handler
- type Buffer
- type BufferPool
- type CertManager
- type CommandHandler
- func (h *CommandHandler) Close() error
- func (h *CommandHandler) Deploy(args DeployArgs, reply *bool) error
- func (h *CommandHandler) List(args bool, reply *ListResponse) error
- func (h *CommandHandler) Pause(args PauseArgs, reply *bool) error
- func (h *CommandHandler) Remove(args RemoveArgs, reply *bool) error
- func (h *CommandHandler) Resume(args ResumeArgs, reply *bool) error
- func (h *CommandHandler) RolloutDeploy(args RolloutDeployArgs, reply *bool) error
- func (h *CommandHandler) RolloutSet(args RolloutSetArgs, reply *bool) error
- func (h *CommandHandler) RolloutStop(args RolloutStopArgs, reply *bool) error
- func (h *CommandHandler) Start(socketPath string) error
- func (h *CommandHandler) Stop(args StopArgs, reply *bool) error
- type Config
- type DeployArgs
- type ErrorPageMiddleware
- type HealthCheck
- type HealthCheckConfig
- type HealthCheckConsumer
- type HostServiceMap
- type ListResponse
- type LoggingMiddleware
- type PauseArgs
- type PauseController
- func (p *PauseController) GetState() PauseState
- func (p *PauseController) GetStopMessage() string
- func (p *PauseController) Pause(failAfter time.Duration) error
- func (p *PauseController) Resume() error
- func (p *PauseController) Stop(message string) error
- func (p *PauseController) UnmarshalJSON(data []byte) error
- func (p *PauseController) Wait() (PauseWaitAction, string)
- type PauseState
- type PauseWaitAction
- type RemoveArgs
- type RequestBufferMiddleware
- type RequestIDMiddleware
- type RequestStartMiddleware
- type ResponseBufferMiddleware
- type ResumeArgs
- type RolloutController
- type RolloutDeployArgs
- type RolloutSetArgs
- type RolloutStopArgs
- type Router
- func (r *Router) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (r *Router) ListActiveServices() ServiceDescriptionMap
- func (r *Router) PauseService(name string, drainTimeout time.Duration, pauseTimeout time.Duration) error
- func (r *Router) RemoveService(name string) error
- func (r *Router) RestoreLastSavedState() error
- func (r *Router) ResumeService(name string) error
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) SetRolloutSplit(name string, percent int, allowList []string) error
- func (r *Router) SetRolloutTarget(name string, targetURL string, deployTimeout time.Duration, ...) error
- func (r *Router) SetServiceTarget(name string, hosts []string, targetURL string, options ServiceOptions, ...) error
- func (r *Router) StopRollout(name string) error
- func (r *Router) StopService(name string, drainTimeout time.Duration, message string) error
- type Server
- type Service
- func (s *Service) ActiveTarget() *Target
- func (s *Service) ClaimTarget(req *http.Request) (*Target, *http.Request, error)
- func (s *Service) MarshalJSON() ([]byte, error)
- func (s *Service) Pause(drainTimeout time.Duration, pauseTimeout time.Duration) error
- func (s *Service) Resume() error
- func (s *Service) RolloutTarget() *Target
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) SetRolloutSplit(percentage int, allowlist []string) error
- func (s *Service) SetTarget(slot TargetSlot, target *Target) *Target
- func (s *Service) Stop(drainTimeout time.Duration, message string) error
- func (s *Service) StopRollout() error
- func (s *Service) UnmarshalJSON(data []byte) error
- func (s *Service) UpdateOptions(hosts []string, options ServiceOptions) error
- type ServiceDescription
- type ServiceDescriptionMap
- type ServiceMap
- type ServiceOptions
- type StaticCertManager
- type StopArgs
- type Target
- func (t *Target) BeginHealthChecks()
- func (t *Target) Drain(timeout time.Duration)
- func (t *Target) HealthCheckCompleted(success bool)
- func (t *Target) IsHealthCheckRequest(r *http.Request) bool
- func (t *Target) SendRequest(w http.ResponseWriter, req *http.Request)
- func (t *Target) StartRequest(req *http.Request) (*http.Request, error)
- func (t *Target) StopHealthChecks()
- func (t *Target) Target() string
- func (t *Target) WaitUntilHealthy(timeout time.Duration) bool
- type TargetOptions
- type TargetSlot
- type TargetState
Constants ¶
View Source
const ( DefaultHttpPort = 80 DefaultHttpsPort = 443 )
View Source
const ( B int64 = 1 KB = B << 10 MB = KB << 10 GB = MB << 10 )
View Source
const ( DefaultDeployTimeout = time.Second * 30 DefaultDrainTimeout = time.Second * 30 DefaultPauseTimeout = time.Second * 30 DefaultHealthCheckPath = "/up" DefaultHealthCheckInterval = time.Second DefaultHealthCheckTimeout = time.Second * 5 MaxIdleConnsPerHost = 100 ProxyBufferSize = 32 * KB DefaultTargetTimeout = time.Second * 30 DefaultMaxMemoryBufferSize = 1 * MB DefaultMaxRequestBodySize = 0 DefaultMaxResponseBodySize = 0 DefaultStopMessage = "" )
View Source
const (
ACMEStagingDirectoryURL = "https://acme-staging-v02.api.letsencrypt.org/directory"
)
View Source
const RolloutCookieName = "kamal-rollout"
View Source
const (
StatusClientClosedRequest = 499
)
Variables ¶
View Source
var ( ErrMaximumSizeExceeded = errors.New("maximum size exceeded") ErrWriteAfterRead = errors.New("write after read") )
View Source
var ( ErrorHealthCheckRequestTimedOut = errors.New("Request timed out") ErrorHealthCheckUnexpectedStatus = errors.New("Unexpected status") )
View Source
var ( ErrorServiceNotFound = errors.New("service not found") ErrorTargetFailedToBecomeHealthy = errors.New("target failed to become healthy within configured timeout") ErrorHostInUse = errors.New("host settings conflict with another service") ErrorNoServerName = errors.New("no server name provided") ErrorUnknownServerName = errors.New("unknown server name") )
View Source
var ( ErrorRolloutTargetNotSet = errors.New("rollout target not set") ErrorUnableToLoadErrorPages = errors.New("unable to load error pages") ErrorAutomaticTLSDoesNotSupportWildcards = errors.New("automatic TLS does not support wildcards") )
View Source
var ( ErrorInvalidHostPattern = errors.New("invalid host pattern") ErrorDraining = errors.New("target is draining") )
View Source
var ErrorUnableToLoadCertificate = errors.New("unable to load certificate")
Functions ¶
func LoggingRequestContext ¶
func NewBufferedReadCloser ¶
func NewBufferedReadCloser(r io.ReadCloser, maxBytes, maxMemBytes int64) (io.ReadCloser, error)
func PerformConcurrently ¶ added in v0.8.5
func PerformConcurrently(fns ...func())
func SetErrorResponse ¶
func WithErrorPageMiddleware ¶
func WithLoggingMiddleware ¶
func WithRequestStartMiddleware ¶ added in v0.8.3
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func NewBufferedWriteCloser ¶
func (*Buffer) Overflowed ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
func NewBufferPool ¶
func NewBufferPool(bufferSize int64) *BufferPool
func (*BufferPool) Get ¶
func (b *BufferPool) Get() []byte
func (*BufferPool) Put ¶
func (b *BufferPool) Put(content []byte)
type CertManager ¶ added in v0.8.0
type CertManager interface { GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error) HTTPHandler(handler http.Handler) http.Handler }
type CommandHandler ¶
type CommandHandler struct {
// contains filtered or unexported fields
}
func NewCommandHandler ¶
func NewCommandHandler(router *Router) *CommandHandler
func (*CommandHandler) Close ¶
func (h *CommandHandler) Close() error
func (*CommandHandler) Deploy ¶
func (h *CommandHandler) Deploy(args DeployArgs, reply *bool) error
func (*CommandHandler) List ¶
func (h *CommandHandler) List(args bool, reply *ListResponse) error
func (*CommandHandler) Remove ¶
func (h *CommandHandler) Remove(args RemoveArgs, reply *bool) error
func (*CommandHandler) Resume ¶
func (h *CommandHandler) Resume(args ResumeArgs, reply *bool) error
func (*CommandHandler) RolloutDeploy ¶
func (h *CommandHandler) RolloutDeploy(args RolloutDeployArgs, reply *bool) error
func (*CommandHandler) RolloutSet ¶
func (h *CommandHandler) RolloutSet(args RolloutSetArgs, reply *bool) error
func (*CommandHandler) RolloutStop ¶
func (h *CommandHandler) RolloutStop(args RolloutStopArgs, reply *bool) error
func (*CommandHandler) Start ¶
func (h *CommandHandler) Start(socketPath string) error
type DeployArgs ¶
type DeployArgs struct { Service string TargetURL string Hosts []string DeployTimeout time.Duration DrainTimeout time.Duration ServiceOptions ServiceOptions TargetOptions TargetOptions }
type ErrorPageMiddleware ¶
type ErrorPageMiddleware struct {
// contains filtered or unexported fields
}
func (*ErrorPageMiddleware) ServeHTTP ¶
func (h *ErrorPageMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HealthCheck ¶
type HealthCheck struct {
// contains filtered or unexported fields
}
func NewHealthCheck ¶
func NewHealthCheck(consumer HealthCheckConsumer, endpoint *url.URL, interval time.Duration, timeout time.Duration) *HealthCheck
func (*HealthCheck) Close ¶
func (hc *HealthCheck) Close()
type HealthCheckConfig ¶
type HealthCheckConsumer ¶
type HealthCheckConsumer interface {
HealthCheckCompleted(success bool)
}
type HostServiceMap ¶
func (HostServiceMap) CheckHostAvailability ¶ added in v0.6.0
func (m HostServiceMap) CheckHostAvailability(name string, hosts []string) *Service
func (HostServiceMap) ServiceForHost ¶ added in v0.8.0
func (m HostServiceMap) ServiceForHost(host string) *Service
type ListResponse ¶
type ListResponse struct {
Targets ServiceDescriptionMap `json:"services"`
}
type LoggingMiddleware ¶
type LoggingMiddleware struct {
// contains filtered or unexported fields
}
func (*LoggingMiddleware) ServeHTTP ¶
func (h *LoggingMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PauseController ¶
type PauseController struct { State PauseState `json:"state"` StopMessage string `json:"stop_message"` FailAfter time.Duration `json:"fail_after"` // contains filtered or unexported fields }
func NewPauseController ¶
func NewPauseController() *PauseController
func (*PauseController) GetState ¶
func (p *PauseController) GetState() PauseState
func (*PauseController) GetStopMessage ¶
func (p *PauseController) GetStopMessage() string
func (*PauseController) Resume ¶
func (p *PauseController) Resume() error
func (*PauseController) Stop ¶
func (p *PauseController) Stop(message string) error
func (*PauseController) UnmarshalJSON ¶
func (p *PauseController) UnmarshalJSON(data []byte) error
func (*PauseController) Wait ¶
func (p *PauseController) Wait() (PauseWaitAction, string)
type PauseState ¶
type PauseState int
const ( PauseStateRunning PauseState = iota PauseStatePaused PauseStateStopped )
func (PauseState) String ¶
func (ps PauseState) String() string
type PauseWaitAction ¶
type PauseWaitAction int
const ( PauseWaitActionProceed PauseWaitAction = iota PauseWaitActionTimedOut PauseWaitActionStopped )
type RemoveArgs ¶
type RemoveArgs struct {
Service string
}
type RequestBufferMiddleware ¶
type RequestBufferMiddleware struct {
// contains filtered or unexported fields
}
func (*RequestBufferMiddleware) ServeHTTP ¶
func (h *RequestBufferMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RequestIDMiddleware ¶
type RequestIDMiddleware struct {
// contains filtered or unexported fields
}
func (*RequestIDMiddleware) ServeHTTP ¶
func (h *RequestIDMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RequestStartMiddleware ¶ added in v0.8.3
type RequestStartMiddleware struct {
// contains filtered or unexported fields
}
func (*RequestStartMiddleware) ServeHTTP ¶ added in v0.8.3
func (h *RequestStartMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ResponseBufferMiddleware ¶
type ResponseBufferMiddleware struct {
// contains filtered or unexported fields
}
func (*ResponseBufferMiddleware) ServeHTTP ¶
func (h *ResponseBufferMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ResumeArgs ¶
type ResumeArgs struct {
Service string
}
type RolloutController ¶
type RolloutController struct { Percentage int `json:"percentage"` PercentageSplitPoint float64 `json:"percentage_split_point"` Allowlist []string `json:"allowlist"` }
func NewRolloutController ¶
func NewRolloutController(percentage int, allowlist []string) *RolloutController
func (*RolloutController) RequestUsesRolloutGroup ¶
func (rc *RolloutController) RequestUsesRolloutGroup(r *http.Request) bool
type RolloutDeployArgs ¶
type RolloutSetArgs ¶
type RolloutStopArgs ¶
type RolloutStopArgs struct {
Service string
}
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) GetCertificate ¶
func (r *Router) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
func (*Router) ListActiveServices ¶
func (r *Router) ListActiveServices() ServiceDescriptionMap
func (*Router) PauseService ¶
func (*Router) RemoveService ¶
func (*Router) RestoreLastSavedState ¶
func (*Router) ResumeService ¶
func (*Router) SetRolloutSplit ¶
func (*Router) SetRolloutTarget ¶
func (*Router) SetServiceTarget ¶
func (*Router) StopRollout ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(name string, hosts []string, options ServiceOptions) (*Service, error)
func (*Service) ActiveTarget ¶
func (*Service) ClaimTarget ¶
func (*Service) MarshalJSON ¶
func (*Service) RolloutTarget ¶
func (*Service) SetRolloutSplit ¶
func (*Service) StopRollout ¶
func (*Service) UnmarshalJSON ¶
func (*Service) UpdateOptions ¶
func (s *Service) UpdateOptions(hosts []string, options ServiceOptions) error
type ServiceDescription ¶
type ServiceDescriptionMap ¶
type ServiceDescriptionMap map[string]ServiceDescription
type ServiceMap ¶ added in v0.6.0
func (ServiceMap) HostServices ¶ added in v0.6.0
func (m ServiceMap) HostServices() HostServiceMap
type ServiceOptions ¶
type ServiceOptions struct { TLSEnabled bool `json:"tls_enabled"` TLSCertificatePath string `json:"tls_certificate_path"` TLSPrivateKeyPath string `json:"tls_private_key_path"` TLSRedirect bool `json:"tls_redirect"` ACMEDirectory string `json:"acme_directory"` ACMECachePath string `json:"acme_cache_path"` ErrorPagePath string `json:"error_page_path"` }
func (ServiceOptions) ScopedCachePath ¶
func (so ServiceOptions) ScopedCachePath() string
type StaticCertManager ¶ added in v0.8.0
type StaticCertManager struct {
// contains filtered or unexported fields
}
StaticCertManager is a certificate manager that loads certificates from disk.
func NewStaticCertManager ¶ added in v0.8.0
func NewStaticCertManager(tlsCertificateFilePath, tlsPrivateKeyFilePath string) (*StaticCertManager, error)
func (*StaticCertManager) GetCertificate ¶ added in v0.8.0
func (m *StaticCertManager) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
func (*StaticCertManager) HTTPHandler ¶ added in v0.8.0
func (m *StaticCertManager) HTTPHandler(handler http.Handler) http.Handler
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
func (*Target) BeginHealthChecks ¶
func (t *Target) BeginHealthChecks()
func (*Target) HealthCheckCompleted ¶
func (*Target) SendRequest ¶
func (t *Target) SendRequest(w http.ResponseWriter, req *http.Request)
func (*Target) StartRequest ¶
func (*Target) StopHealthChecks ¶
func (t *Target) StopHealthChecks()
type TargetOptions ¶
type TargetOptions struct { HealthCheckConfig HealthCheckConfig `json:"health_check_config"` ResponseTimeout time.Duration `json:"response_timeout"` BufferRequests bool `json:"buffer_requests"` BufferResponses bool `json:"buffer_responses"` MaxMemoryBufferSize int64 `json:"max_memory_buffer_size"` MaxRequestBodySize int64 `json:"max_request_body_size"` MaxResponseBodySize int64 `json:"max_response_body_size"` LogRequestHeaders []string `json:"log_request_headers"` LogResponseHeaders []string `json:"log_response_headers"` ForwardHeaders bool `json:"forward_headers"` }
type TargetSlot ¶
type TargetSlot int
const ( TargetSlotActive TargetSlot = iota TargetSlotRollout )
type TargetState ¶
type TargetState int
const ( TargetStateAdding TargetState = iota TargetStateDraining TargetStateHealthy )
func (TargetState) String ¶
func (ts TargetState) String() string
Source Files
¶
- buffer.go
- cert.go
- commands.go
- config.go
- error_page_middleware.go
- health_check.go
- logging_middleware.go
- pause_controller.go
- proxy_buffer_pool.go
- request_buffer_middleware.go
- request_id_middleware.go
- request_start_middleware.go
- response_buffer_middleware.go
- rollout_controller.go
- router.go
- server.go
- service.go
- target.go
- testing.go
- util.go
Click to show internal directories.
Click to hide internal directories.