config

package
v0.0.0-...-85cd7ee Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasicAuthType   = "basic"
	AccessTokenType = "accessToken"
)
View Source
const (
	CacheInMemory = CacheType("inmemory")
	CacheRedis    = CacheType("redis")
)

Variables

This section is empty.

Functions

func NewLoadYaml

func NewLoadYaml(r io.Reader, v any) error

func NewLoadYamlWithFile

func NewLoadYamlWithFile(filename string, v any) error

Types

type AccessTokenAuth

type AccessTokenAuth struct {
	AccessToken string `yaml:"accessToken"`
}

func (*AccessTokenAuth) Token

func (c *AccessTokenAuth) Token() string

func (*AccessTokenAuth) Valid

func (c *AccessTokenAuth) Valid(header map[string][]string) bool

func (*AccessTokenAuth) Validate

func (c *AccessTokenAuth) Validate() error

type Auth

type Auth struct {
	Type            AuthType         `yaml:"authType"`
	BasicAuth       *BasicAuth       `yaml:"basicAuth"`
	AccessTokenAuth *AccessTokenAuth `yaml:"accessToken"`
}

func (*Auth) Token

func (a *Auth) Token() string

func (*Auth) Valid

func (a *Auth) Valid(header map[string][]string) bool

type AuthType

type AuthType string

type BasicAuth

type BasicAuth struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

func (*BasicAuth) Token

func (c *BasicAuth) Token() string

func (*BasicAuth) Valid

func (c *BasicAuth) Valid(header map[string][]string) bool

func (*BasicAuth) Validate

func (c *BasicAuth) Validate() error

type CSRFToken

type CSRFToken struct {
	Domain string `yaml:"domain"`
	Secure bool   `yaml:"secure" default:"true"`
}

func (CSRFToken) Validate

func (s CSRFToken) Validate() error

type Cache

type Cache struct {
	Type     CacheType `yaml:"type" default:"inmemory"`
	Redis    *Redis    `yaml:"redis"`
	InMemory *InMemory `yaml:"inmemory"`
}

func (Cache) Validate

func (c Cache) Validate() error

type CacheType

type CacheType string

type Config

type Config struct {
	AppEnv          string                `yaml:"appEnv" default:"stg"`
	Retrievers      []retriever.Retriever `yaml:"retrievers"`
	PollingInterval time.Duration         `yaml:"pollingInterval" default:"1m"`
	Gateway         *Gateway              `yaml:"gateway"`
	Grpc            Grpc                  `yaml:"grpc,alias"`
	Raft            *Raft                 `yaml:"raft"`

	Tracking Tracking  `yaml:"tracking"`
	Logging  Logging   `yaml:"logging"`
	CSRF     CSRFToken `yaml:"csrf"`
}

func DefaultConfig

func DefaultConfig() *Config

func (Config) IsLocal

func (c Config) IsLocal() bool

func (Config) IsProduction

func (c Config) IsProduction() bool

func (*Config) IsRaftCluster

func (c *Config) IsRaftCluster() bool

func (Config) IsStaging

func (c Config) IsStaging() bool

func (Config) OTEL

func (c Config) OTEL() Tracking

func (*Config) SetupLog

func (c *Config) SetupLog()

func (*Config) Shutdown

func (c *Config) Shutdown() error

func (Config) Validate

func (c Config) Validate() error

type ConfigLoader

type ConfigLoader interface {
	IsProduction() bool
	IsStaging() bool
	IsLocal() bool
	OTEL() Tracking
}

type Gateway

type Gateway struct {
	Port int  `yaml:"port" default:"8080"`
	Grpc Grpc `yaml:"grpc,alias"`
}

func (*Gateway) GrpcCredentials

func (c *Gateway) GrpcCredentials() credentials.TransportCredentials

type Grpc

type Grpc struct {
	Host        string `yaml:"endpoint"`
	Port        int    `yaml:"port"`
	Credentials *TLS   `yaml:"tls"`
	Auth        *Auth  `yaml:"auth"`
}

func (*Grpc) Endpoint

func (c *Grpc) Endpoint() string

func (*Grpc) GrpcCredentials

func (c *Grpc) GrpcCredentials() credentials.TransportCredentials

type Logging

type Logging struct {
	Level   slog.Level             `yaml:"level"`
	Handler interface{}            `yaml:"handler" default:"text"`
	Sentry  *logging.SentryConfig  `yaml:"sentry"`
	Rollbar *logging.RollbarConfig `yaml:"rollbar"`
	// contains filtered or unexported fields
}

func (Logging) Close

func (l Logging) Close()

func (*Logging) SetupLog

func (l *Logging) SetupLog(tracking Tracking)

func (*Logging) UnmarshalYAML

func (l *Logging) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Logging) Validate

func (l Logging) Validate() error

type Raft

type Raft struct {
	Id           string        `yaml:"id" default:"local-1"`
	Dir          string        `yaml:"directory" default:"/tmp/raft"`
	ApplyTimeout time.Duration `yaml:"applyTimeout" default:"10s"`
	JoinAddress  string        `yaml:"join" default:"localhost:40001"`
}

type SetupLogger

type SetupLogger interface {
	SetupLog()
}

type Tracking

type Tracking struct {
	Enabled     bool   `yaml:"enabled" default:"false"`
	AgentAddr   string `yaml:"agentAddr"`
	ServiceName string `yaml:"serviceName" default:"user-flex-feature"`
	Environment string `yaml:"environment" default:"prod"`
}

func (Tracking) Datadog

func (t Tracking) Datadog() logging.Service

func (Tracking) Validate

func (t Tracking) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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