proxy

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package proxy contains the implementation of the oauthproxy service.

Index

Constants

View Source
const (
	// CacheTTLMinValue is the smallest time permitted by the service for cached tokens.
	CacheTTLMinValue = 10 * time.Minute

	// RequestTimeoutMinValue is the smallest time permitted for request timeouts to down stream systems.
	RequestTimeoutMinValue = 10 * time.Second

	// ShutdownGracePeriodMinValue is the smallest period of time the service can be configured to wait for a graceful exit.
	ShutdownGracePeriodMinValue = 5 * time.Second
)

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, settings Settings) error

Run will setup and run the server until the passed context is cancelled. If the server cannot be run, or fails to shut gracefully an error will be returned.

Types

type LoggerFunc

type LoggerFunc func(bool, string, ...interface{})

LoggerFunc logging function.

type Settings

type Settings struct {
	// CacheTTL how long a item remains valid in the cache
	CacheTTL time.Duration

	// RequestTimeout timeout period for a down sstream request
	RequestTimeout time.Duration

	// ShutdownGracePeriod how long to wait for shutdown
	ShutdownGracePeriod time.Duration

	// HTTPListenAddr address and port to listen on
	HTTPListenAddr string

	// Downstream endpoint
	Endpoint string

	// Logger recices bogging messages from the service
	Logger LoggerFunc

	// PoolSize is the number of go routines servicing downstream requests
	PoolSize int
}

Settings contains the proxy services settings.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the default settings for the service.

func (Settings) WithEndpoint

func (settings Settings) WithEndpoint(endpoint string) Settings

WithEndpoint sets the down stream oauth services endpoint, the request path is appended to this setting.

func (Settings) WithHTTPPort

func (settings Settings) WithHTTPPort(port uint) Settings

WithHTTPPort creates a new settings with the HTTP port set to the passed value.

func (Settings) WithLogger

func (settings Settings) WithLogger(logger LoggerFunc) Settings

WithLogger creates anew settings with the passed logger function used for logging.

Jump to

Keyboard shortcuts

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