Documentation
¶
Index ¶
Constants ¶
const ( // PidFile specifies the location of the PID file for the Nginx process. PidFile = "/var/run/nginx/nginx.pid" // PidFileTimeout defines the timeout duration for accessing the PID file. PidFileTimeout = 10000 * time.Millisecond // NginxReloadTimeout sets the timeout duration for reloading the Nginx configuration. NginxReloadTimeout = 60000 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func CreatePlusClient ¶ added in v1.2.0
func CreatePlusClient() (*client.NginxClient, error)
CreatePlusClient returns a client for communicating with the NGINX Plus API.
func GetSocketClient ¶ added in v1.2.0
GetSocketClient gets an http.Client with a unix socket transport.
Types ¶
type Manager ¶
type Manager interface { // Reload reloads NGINX configuration. It is a blocking operation. Reload(ctx context.Context, configVersion int) error // IsPlus returns whether or not we are running NGINX plus. IsPlus() bool // UpdateHTTPServers uses the NGINX Plus API to update HTTP servers. // Only usable if running NGINX Plus. UpdateHTTPServers(string, []ngxclient.UpstreamServer) error // GetUpstreams uses the NGINX Plus API to get the upstreams. // Only usable if running NGINX Plus. GetUpstreams() (ngxclient.Upstreams, error) }
Manager manages the runtime of NGINX.
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl implements Manager.
func NewManagerImpl ¶
func NewManagerImpl( ngxPlusClient NginxPlusClient, collector MetricsCollector, logger logr.Logger, processHandler ProcessHandler, verifyClient nginxConfigVerifier, ) *ManagerImpl
NewManagerImpl creates a new ManagerImpl.
func (*ManagerImpl) GetUpstreams ¶ added in v1.2.0
func (m *ManagerImpl) GetUpstreams() (ngxclient.Upstreams, error)
GetUpstreams uses the NGINX Plus API to get the upstreams. Only usable if running NGINX Plus.
func (*ManagerImpl) IsPlus ¶ added in v1.2.0
func (m *ManagerImpl) IsPlus() bool
IsPlus returns whether or not we are running NGINX plus.
func (*ManagerImpl) Reload ¶
func (m *ManagerImpl) Reload(ctx context.Context, configVersion int) error
func (*ManagerImpl) UpdateHTTPServers ¶ added in v1.2.0
func (m *ManagerImpl) UpdateHTTPServers(upstream string, servers []ngxclient.UpstreamServer) error
UpdateHTTPServers uses the NGINX Plus API to update HTTP upstream servers. Only usable if running NGINX Plus.
type MetricsCollector ¶
type MetricsCollector interface { IncReloadCount() IncReloadErrors() ObserveLastReloadTime(ms time.Duration) }
MetricsCollector is an interface for the metrics of the NGINX runtime manager.
type NginxPlusClient ¶ added in v1.5.0
type NginxPlusClient interface { UpdateHTTPServers( upstream string, servers []ngxclient.UpstreamServer, ) ( added []ngxclient.UpstreamServer, deleted []ngxclient.UpstreamServer, updated []ngxclient.UpstreamServer, err error, ) GetUpstreams() (*ngxclient.Upstreams, error) }
type ProcessHandler ¶ added in v1.5.0
type ProcessHandlerImpl ¶ added in v1.5.0
type ProcessHandlerImpl struct {
// contains filtered or unexported fields
}
func NewProcessHandlerImpl ¶ added in v1.5.0
func NewProcessHandlerImpl(readFile ReadFileFunc, checkFile CheckFileFunc) *ProcessHandlerImpl
func (*ProcessHandlerImpl) FindMainProcess ¶ added in v1.5.0
func (*ProcessHandlerImpl) Kill ¶ added in v1.5.0
func (p *ProcessHandlerImpl) Kill(pid int) error
type ReadFileFunc ¶ added in v1.5.0
type VerifyClient ¶ added in v1.5.0
type VerifyClient struct {
// contains filtered or unexported fields
}
VerifyClient is a client for verifying the config version.
func NewVerifyClient ¶ added in v1.5.0
func NewVerifyClient(timeout time.Duration) *VerifyClient
NewVerifyClient returns a new client pointed at the config version socket.
func (*VerifyClient) EnsureConfigVersion ¶ added in v1.5.0
func (c *VerifyClient) EnsureConfigVersion(ctx context.Context, expectedVersion int) error
func (*VerifyClient) GetConfigVersion ¶ added in v1.5.0
func (c *VerifyClient) GetConfigVersion() (int, error)
GetConfigVersion gets the version number that we put in the nginx config to verify that we're using the correct config.
func (*VerifyClient) WaitForCorrectVersion ¶ added in v1.5.0
func (c *VerifyClient) WaitForCorrectVersion( ctx context.Context, expectedVersion int, childProcFile string, previousChildProcesses []byte, readFile ReadFileFunc, ) error
WaitForCorrectVersion first ensures any new worker processes have been started, and then calls the config version endpoint until it gets the expectedVersion, which ensures that a new worker process has been started for that config version.