server

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Kind is an optional string that describes the purpose of the server. It is used in logs to distinguish
	// among multiple servers.
	Kind string

	// Log is the logger used by the server. If not set, a logger will be derived from the context passed to Start.
	Log logr.Logger

	// Server is the HTTP server to run. It is required.
	Server *http.Server

	// Listener is an optional listener to use. If not set, the server start a listener using the server.Addr.
	// Using a listener is useful when the port reservation needs to happen in advance of this runnable starting.
	Listener net.Listener

	// OnlyServeWhenLeader is an optional bool that indicates that the server should only be started when the manager is the leader.
	OnlyServeWhenLeader bool

	// ShutdownTimeout is an optional duration that indicates how long to wait for the server to shutdown gracefully. If not set,
	// the server will wait indefinitely for all connections to close.
	ShutdownTimeout *time.Duration
}

Server is a general purpose HTTP server Runnable for a manager. It is used to serve some internal handlers for health probes and profiling, but it can also be used to run custom servers.

func (*Server) NeedLeaderElection

func (s *Server) NeedLeaderElection() bool

NeedLeaderElection returns true if the server should only be started when the manager is the leader.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the server. It will block until the server is stopped or an error occurs.

Jump to

Keyboard shortcuts

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