config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config holds the echo server configuration utilities

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfigRefresh sets the default interval to refresh the config.
	DefaultConfigRefresh = 10 * time.Minute
	// DefaultTLSConfig is the default TLS config used when HTTPS is enabled
	DefaultTLSConfig = &tls.Config{
		MinVersion:               tls.VersionTLS12,
		CurvePreferences:         []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
		PreferServerCipherSuites: true,
		CipherSuites: []uint16{
			tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
			tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
		},
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// add all the configuration settings for the datum server
	Settings config.Config

	// Logger contains the logger used by echo functions
	Logger *zap.SugaredLogger
	// Routes contains the handler functions
	Routes []http.Handler
	// DefaultMiddleware to enable on the echo server used on all requests
	DefaultMiddleware []echo.MiddlewareFunc
	// GraphMiddleware to enable on the echo server used on graph requests
	GraphMiddleware []echo.MiddlewareFunc
	// Handler contains the required settings for REST handlers including ready checks and JWT keys
	Handler handlers.Handler
	// SessionConfig manages sessions for users
	SessionConfig *sessions.SessionConfig
}

Config contains the configuration for the datum server

func (*Config) GetConfig

func (c *Config) GetConfig() (*Config, error)

GetConfig implements ConfigProvider.

func (*Config) WithAutoCert

func (c *Config) WithAutoCert(host string) *Config

WithAutoCert generates a letsencrypt certificate, a valid host must be provided

func (Config) WithDefaultTLSConfig

func (c Config) WithDefaultTLSConfig() Config

WithDefaultTLSConfig sets the default TLS Configuration

func (*Config) WithTLSCerts

func (c *Config) WithTLSCerts(certFile, certKey string) *Config

WithTLSCerts sets the TLS Cert and Key locations

func (Config) WithTLSDefaults

func (c Config) WithTLSDefaults() Config

WithTLSDefaults sets tls default settings assuming a default cert and key file location.

type ConfigProvider

type ConfigProvider interface {
	// GetConfig returns the server configuration
	GetConfig() (*Config, error)
}

ConfigProvider serves as a common interface to read echo server configuration

type ConfigProviderWithRefresh

type ConfigProviderWithRefresh struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConfigProviderWithRefresh shows a config provider with automatic refresh; it contains fields and methods to manage the configuration, and refresh it periodically based on a specified interval

func NewConfigProviderWithRefresh

func NewConfigProviderWithRefresh(cfgProvider ConfigProvider) (*ConfigProviderWithRefresh, error)

NewConfigProviderWithRefresh function is a constructor function that creates a new instance of ConfigProviderWithRefresh

func (*ConfigProviderWithRefresh) Close

func (s *ConfigProviderWithRefresh) Close()

Close function is used to stop the automatic refresh of the configuration. It stops the ticker that triggers the refresh and closes the stop channel, which signals the goroutine to stop refreshing the configuration

func (*ConfigProviderWithRefresh) GetConfig

func (s *ConfigProviderWithRefresh) GetConfig() (*Config, error)

GetConfig retrieves the current echo server configuration; it acquires a read lock to ensure thread safety and returns the `config` field

Jump to

Keyboard shortcuts

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