tcp

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

README

TCP Provider

The TCP Provider extends the platform-health server to enable monitoring the health and status of basic TCP services. It does this by establishing a TCP connection to the specified host and port, and reporting on the success or failure of this operation.

Usage

Once the TCP Provider is configured, any query to the platform health server will trigger validation of the configured TCP service(s). The server will attempt to establish a TCP connection to each service, and it will report each component as "healthy" if the connection is successful, or "unhealthy" otherwise.

Configuration

The TCP Provider is configured through the platform-health server's configuration file, with list of instances under the services.tcp key.

  • name (required): The name of the TCP service instance, used to identify the service in the health reports.
  • host (required): The hostname or IP address of the TCP service to monitor.
  • port (default: 80): The port number of the TCP service to monitor.
  • closed (default: false): Reverse logic to report "healthy" if port is closed and "unhealthy" if it is open.
  • timeout (default: 1s): The maximum time to wait for a connection to be established before timing out.
Example
tcp:
  - name: example
    host: example.com
    port: 80
    timeout: 1s

In this example, the TCP Provider will establish a TCP connection to example.com on port 80 and it will wait for 1s before timing out.

Documentation

Index

Constants

View Source
const TypeTCP = "tcp"

Variables

This section is empty.

Functions

This section is empty.

Types

type TCP

type TCP struct {
	Name    string        `mapstructure:"name"`
	Host    string        `mapstructure:"host"`
	Port    int           `mapstructure:"port" default:"80"`
	Closed  bool          `mapstructure:"closed" default:"false"`
	Timeout time.Duration `mapstructure:"timeout" default:"1s"`
}

func (*TCP) GetHealth

func (i *TCP) GetHealth(ctx context.Context) *ph.HealthCheckResponse

func (*TCP) GetName

func (i *TCP) GetName() string

func (*TCP) GetType

func (i *TCP) GetType() string

func (*TCP) LogValue

func (i *TCP) LogValue() slog.Value

func (*TCP) SetDefaults

func (i *TCP) SetDefaults()

Jump to

Keyboard shortcuts

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