listener

package
v0.7.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

+kubebuilder:validation:Optional

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module is an fx module that provides annotated Listener.

Types

type Constructor

type Constructor struct {
	ConfigKey     string
	Name          string
	DefaultConfig ListenerConfig
}

Constructor holds fields to create an annotated Listener.

func (Constructor) ProvideAnnotated

func (constructor Constructor) ProvideAnnotated() fx.Annotated

ProvideAnnotated provides an annotated instance of Listener.

type GMuxConstructor

type GMuxConstructor struct {
	// Name of HTTP Server instance
	HTTPServerName string
	// Name of GRPC listener instance
	ListenerName string
}

GMuxConstructor holds fields to create an annotated instance gmux Listener.

func (GMuxConstructor) Annotate

func (constructor GMuxConstructor) Annotate() fx.Option

Annotate creates an annotated instance of gmux Listener.

type Listener

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

Listener wraps net.Listener, that can be potentially not-yet-started.

func ProvideTestListener

func ProvideTestListener(lc fx.Lifecycle) *Listener

ProvideTestListener provides a listener which will choose the port to listen to on its own. Use fx.Populate an `port = lis.GetListener().Addr().(*net.TCPAddr).Port` to obtain actual port number

Note: This is a separate function, because Addr: ":0" fails hostname_port validation thus cannot go through Unmarshaller-based constructor.

func (*Listener) GetAddr added in v0.1.2

func (l *Listener) GetAddr() string

GetAddr returns the address of the listener.

func (*Listener) GetListener

func (l *Listener) GetListener() net.Listener

GetListener returns wrapped Listener

This function is supposed to only be called in the Start stage. Otherwise, this function will panic.

type ListenerConfig

type ListenerConfig struct {
	// Keep-alive period - 0 = enabled if supported by protocol or OS. If negative then keep-alive is disabled.
	KeepAlive config.Duration `json:"keep_alive" validate:"gte=0s" default:"180s"`

	// Address to bind to in the form of [host%zone]:port
	Addr string `json:"addr" validate:"hostname_port" default:":8080"`

	// TCP networks - "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only)
	Network string `json:"network" validate:"oneof=tcp tcp4 tcp6" default:"tcp"`
}

ListenerConfig holds configuration for socket listeners. swagger:model +kubebuilder:object:generate=true

func (*ListenerConfig) DeepCopy added in v0.1.2

func (in *ListenerConfig) DeepCopy() *ListenerConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ListenerConfig.

func (*ListenerConfig) DeepCopyInto added in v0.1.2

func (in *ListenerConfig) DeepCopyInto(out *ListenerConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ListenerIn

type ListenerIn struct {
	fx.In

	Unmarshaller config.Unmarshaller
	Lifecycle    fx.Lifecycle
}

ListenerIn is the input to Listener constructor.

Jump to

Keyboard shortcuts

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