middleware

package
v1.9.14 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WriteTimeoutFieldName = "client.socket.timeout.write"
	ReadTimeoutFieldName  = "client.socket.timeout.read"

	WriteTimeoutDefault = 10 * time.Second
	ReadTimeoutDefault  = 10 * time.Second
)

Variables

View Source
var (
	ReadBytesLoggerComponent = &app.Component{
		Dependencies: app.Components{
			logger.Component,
			client.Component,
		},
		Run: app.Run(func(container container.Container) error {
			return container.Invoke(func(socketClient client.Client, logger logger.Logger) {
				socketClient.Use(ReadBytesLogger(logger))
			})
		}),
	}

	ReadBytesMetricComponent = &app.Component{
		Dependencies: app.Components{
			logger.Component,
			client.Component,
			metric.Component,
		},
		Run: app.Run(func(container container.Container) error {
			return container.Invoke(func(socketClient client.Client, logger logger.Logger, metric *metric.Metric) {
				socketClient.Use(ReadBytesMetric(logger, metric))
			})
		}),
	}

	ReadTimeoutComponent = &app.Component{
		Dependencies: app.Components{
			logger.Component,
			configurator.Component,
			client.Component,
		},
		Constructor: app.Constructor(func(container container.Container) error {
			return container.Provide(NewReadConfig)
		}),
		BindFlags: app.BindFlags(ReadTimeoutComponentBindFlags),
		Run: app.Run(func(container container.Container) error {
			return container.Invoke(func(socketClient client.Client, config *ReadConfig, logger logger.Logger, configurator configurator.Configurator) {
				socketClient.Use(ReadTimeout(ReadConfigConfiguration(config, configurator), logger))
			})
		}),
	}

	ReadComponent = &app.Component{
		Dependencies: app.Components{
			ReadBytesLoggerComponent,
			ReadBytesMetricComponent,
			ReadTimeoutComponent,
		},
	}

	WriteBytesLoggerComponent = &app.Component{
		Dependencies: app.Components{
			logger.Component,
			client.Component,
		},
		Run: app.Run(func(container container.Container) error {
			return container.Invoke(func(socketClient client.Client, logger logger.Logger) {
				socketClient.Use(WriteBytesLogger(logger))
			})
		}),
	}

	WriteBytesMetricComponent = &app.Component{
		Dependencies: app.Components{
			logger.Component,
			client.Component,
			metric.Component,
		},
		Run: app.Run(func(container container.Container) error {
			return container.Invoke(func(socketClient client.Client, logger logger.Logger, metric *metric.Metric) {
				socketClient.Use(WriteBytesMetric(logger, metric))
			})
		}),
	}

	WriteTimeoutComponent = &app.Component{
		Dependencies: app.Components{
			logger.Component,
			configurator.Component,
			client.Component,
		},
		Constructor: app.Constructor(func(container container.Container) error {
			return container.Provide(NewWriteConfig)
		}),
		BindFlags: app.BindFlags(WriteTimeoutComponentBindFlags),
		Run: app.Run(func(container container.Container) error {
			return container.Invoke(func(socketClient client.Client, config *WriteConfig, logger logger.Logger, configurator configurator.Configurator) {
				socketClient.Use(WriteTimeout(WriteConfigConfiguration(config, configurator), logger))
			})
		}),
	}

	WriteComponent = &app.Component{
		Dependencies: app.Components{
			WriteBytesLoggerComponent,
			WriteBytesMetricComponent,
			WriteTimeoutComponent,
		},
	}

	Component = &app.Component{Dependencies: app.Components{ReadComponent, WriteComponent}}
)

Functions

func ReadBytesLogger added in v1.8.12

func ReadBytesLogger(logger logger.Logger) client.MiddlewareFunc

func ReadBytesMetric added in v1.8.12

func ReadBytesMetric(informer logger.Informer, metric *metric.Metric) client.MiddlewareFunc

func ReadTimeout added in v1.8.12

func ReadTimeout(config *ReadConfig, informer logger.Informer) client.MiddlewareFunc

func ReadTimeoutComponentBindFlags added in v1.8.12

func ReadTimeoutComponentBindFlags(flagSet *pflag.FlagSet, container container.Container) error

func WriteBytesLogger added in v1.8.12

func WriteBytesLogger(logger logger.Logger) client.MiddlewareFunc

func WriteBytesMetric added in v1.8.12

func WriteBytesMetric(informer logger.Informer, metric *metric.Metric) client.MiddlewareFunc

func WriteTimeout added in v1.8.12

func WriteTimeout(config *WriteConfig, informer logger.Informer) client.MiddlewareFunc

func WriteTimeoutComponentBindFlags added in v1.8.12

func WriteTimeoutComponentBindFlags(flagSet *pflag.FlagSet, container container.Container) error

Types

type ReadConfig added in v1.8.12

type ReadConfig struct {
	Timeout time.Duration
}

func NewReadConfig added in v1.8.12

func NewReadConfig() *ReadConfig

func ReadConfigConfiguration added in v1.8.12

func ReadConfigConfiguration(config *ReadConfig, configurator configurator.Configurator) *ReadConfig

type WriteConfig added in v1.8.12

type WriteConfig struct {
	Timeout time.Duration
}

func NewWriteConfig added in v1.8.12

func NewWriteConfig() *WriteConfig

func WriteConfigConfiguration added in v1.8.12

func WriteConfigConfiguration(config *WriteConfig, configurator configurator.Configurator) *WriteConfig

Jump to

Keyboard shortcuts

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