config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MPL-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxResponseSizeKb                 = 50    // in kilobytes
	MaxResponseSize                   = 51200 // in bytes
	DefaultHost                       = "localhost:5005"
	DefaultSearchTokenizationInterval = 1
)
View Source
const (
	RedisQueueProvider       QueueProvider           = "redis"
	DefaultSignatureHeader   SignatureHeaderProvider = "X-Convoy-Signature"
	NewRelicTracerProvider   TracerProvider          = "new_relic"
	PostgresDatabaseProvider DatabaseProvider        = "postgres"
	TypesenseSearchProvider  SearchProvider          = "typesense"
)
View Source
const (
	OSSEnvironment string = "oss"
)

Variables

View Source
var DefaultConfiguration = Configuration{
	Host:            DefaultHost,
	Environment:     OSSEnvironment,
	MaxResponseSize: MaxResponseSizeKb,
	Server: ServerConfiguration{
		HTTP: HTTPServerConfiguration{
			SSL:        false,
			Port:       5005,
			WorkerPort: 5006,
		},
	},
	Database: DatabaseConfiguration{
		Type:               PostgresDatabaseProvider,
		Scheme:             "postgres",
		Host:               "localhost",
		Username:           "postgres",
		Password:           "postgres",
		Database:           "convoy",
		Options:            "sslmode=disable&connect_timeout=30",
		Port:               5432,
		SetConnMaxLifetime: 3600,
	},
	Redis: RedisConfiguration{
		Scheme: "redis",
		Host:   "localhost",
		Port:   6379,
	},
	Logger: LoggerConfiguration{
		Level: "error",
	},
	Analytics: AnalyticsConfiguration{
		IsEnabled: true,
	},
	StoragePolicy: StoragePolicyConfiguration{
		Type: "on-prem",
		OnPrem: OnPremStorage{
			Path: convoy.DefaultOnPremDir,
		},
	},
	Auth: AuthConfiguration{
		IsSignupEnabled: true,
		Native: NativeRealmOptions{
			Enabled: true,
		},
		Jwt: JwtRealmOptions{
			Enabled: true,
		},
	},
}

Functions

func IsStringEmpty added in v0.5.0

func IsStringEmpty(s string) bool

IsStringEmpty checks if the given string s is empty or not

func LoadConfig

func LoadConfig(p string) error

LoadConfig is used to load the configuration from either the json config file or the environment variables.

func Override added in v0.6.2

func Override(newCfg *Configuration) error

Types

type APIKeyAuth

type APIKeyAuth struct {
	APIKey string    `json:"api_key"`
	Role   auth.Role `json:"role"`
}

type APIKeyAuthConfig added in v0.5.0

type APIKeyAuthConfig []APIKeyAuth

func (*APIKeyAuthConfig) Decode added in v0.5.0

func (a *APIKeyAuthConfig) Decode(value string) error

Decode loads in config from an env var named `CONVOY_API_KEY_CONFIG`

type AnalyticsConfiguration added in v0.8.1

type AnalyticsConfiguration struct {
	IsEnabled bool `json:"enabled" envconfig:"CONVOY_ANALYTICS_ENABLED"`
}

type AuthConfiguration

type AuthConfiguration struct {
	File            FileRealmOption    `json:"file"`
	Native          NativeRealmOptions `json:"native"`
	Jwt             JwtRealmOptions    `json:"jwt"`
	IsSignupEnabled bool               `json:"is_signup_enabled" envconfig:"CONVOY_SIGNUP_ENABLED"`
}

type AuthProvider

type AuthProvider string

type BasicAuth

type BasicAuth struct {
	Username string    `json:"username"`
	Password string    `json:"password"`
	Role     auth.Role `json:"role"`
}

type BasicAuthConfig added in v0.5.0

type BasicAuthConfig []BasicAuth

func (*BasicAuthConfig) Decode added in v0.5.0

func (b *BasicAuthConfig) Decode(value string) error

Decode loads in config from an env var named `CONVOY_BASIC_AUTH_CONFIG`

type CacheProvider added in v0.4.10

type CacheProvider string

type Configuration

type Configuration struct {
	Auth               AuthConfiguration          `json:"auth,omitempty"`
	Database           DatabaseConfiguration      `json:"database"`
	Redis              RedisConfiguration         `json:"redis"`
	Prometheus         PrometheusConfiguration    `json:"prometheus"`
	Server             ServerConfiguration        `json:"server"`
	MaxResponseSize    uint64                     `json:"max_response_size" envconfig:"CONVOY_MAX_RESPONSE_SIZE"`
	SMTP               SMTPConfiguration          `json:"smtp"`
	Environment        string                     `json:"env" envconfig:"CONVOY_ENV"`
	Logger             LoggerConfiguration        `json:"logger"`
	Tracer             TracerConfiguration        `json:"tracer"`
	Host               string                     `json:"host" envconfig:"CONVOY_HOST"`
	CustomDomainSuffix string                     `json:"custom_domain_suffix" envconfig:"CONVOY_CUSTOM_DOMAIN_SUFFIX"`
	Search             SearchConfiguration        `json:"search"`
	FeatureFlag        FeatureFlagConfiguration   `json:"feature_flag"`
	Analytics          AnalyticsConfiguration     `json:"analytics"`
	StoragePolicy      StoragePolicyConfiguration `json:"storage_policy"`
}

func Get

func Get() (Configuration, error)

Get fetches the application configuration. LoadConfig must have been called previously for this to work. Use this when you need to get access to the config object at runtime

type DatabaseConfiguration

type DatabaseConfiguration struct {
	Type DatabaseProvider `json:"type" envconfig:"CONVOY_DB_TYPE"`

	Scheme   string `json:"scheme" envconfig:"CONVOY_DB_SCHEME"`
	Host     string `json:"host" envconfig:"CONVOY_DB_HOST"`
	Username string `json:"username" envconfig:"CONVOY_DB_USERNAME"`
	Password string `json:"password" envconfig:"CONVOY_DB_PASSWORD"`
	Database string `json:"database" envconfig:"CONVOY_DB_DATABASE"`
	Options  string `json:"options" envconfig:"CONVOY_DB_OPTIONS"`
	Port     int    `json:"port" envconfig:"CONVOY_DB_PORT"`

	SetMaxOpenConnections int `json:"max_open_conn" envconfig:"CONVOY_DB_MAX_OPEN_CONN"`
	SetMaxIdleConnections int `json:"max_idle_conn" envconfig:"CONVOY_DB_MAX_IDLE_CONN"`
	SetConnMaxLifetime    int `json:"conn_max_lifetime" envconfig:"CONVOY_DB_CONN_MAX_LIFETIME"`
}

func (DatabaseConfiguration) BuildDsn added in v1.1.6

func (dc DatabaseConfiguration) BuildDsn() string

type DatabaseProvider added in v0.5.0

type DatabaseProvider string

type FeatureFlagConfiguration added in v0.7.0

type FeatureFlagConfiguration struct {
	Type  FeatureFlagProvider `json:"type" envconfig:"CONVOY_FEATURE_FLAG_TYPE"`
	Flipt FliptConfiguration  `json:"flipt"`
}

type FeatureFlagProvider added in v0.7.0

type FeatureFlagProvider string

type FileRealmOption

type FileRealmOption struct {
	Basic  BasicAuthConfig  `json:"basic" bson:"basic" envconfig:"CONVOY_BASIC_AUTH_CONFIG"`
	APIKey APIKeyAuthConfig `json:"api_key" envconfig:"CONVOY_API_KEY_CONFIG"`
}

type FliptConfiguration added in v0.7.0

type FliptConfiguration struct {
	Host string `json:"host" envconfig:"CONVOY_FLIPT_HOST"`
}

type HTTPServerConfiguration

type HTTPServerConfiguration struct {
	SSL         bool   `json:"ssl" envconfig:"SSL"`
	SSLCertFile string `json:"ssl_cert_file" envconfig:"CONVOY_SSL_CERT_FILE"`
	SSLKeyFile  string `json:"ssl_key_file" envconfig:"CONVOY_SSL_KEY_FILE"`
	Port        uint32 `json:"port" envconfig:"PORT"`
	IngestPort  uint32 `json:"ingest_port" envconfig:"INGEST_PORT"`
	WorkerPort  uint32 `json:"worker_port" envconfig:"WORKER_PORT"`
	SocketPort  uint32 `json:"socket_port" envconfig:"SOCKET_PORT"`
	DomainPort  uint32 `json:"domain_port" envconfig:"DOMAIN_PORT"`
	HttpProxy   string `json:"proxy" envconfig:"HTTP_PROXY"`
}

type JwtRealmOptions added in v0.6.0

type JwtRealmOptions struct {
	Enabled       bool   `json:"enabled" envconfig:"CONVOY_JWT_REALM_ENABLED"`
	Secret        string `json:"secret" envconfig:"CONVOY_JWT_SECRET"`
	Expiry        int    `json:"expiry" envconfig:"CONVOY_JWT_EXPIRY"`
	RefreshSecret string `json:"refresh_secret" envconfig:"CONVOY_JWT_REFRESH_SECRET"`
	RefreshExpiry int    `json:"refresh_expiry" envconfig:"CONVOY_JWT_REFRESH_EXPIRY"`
}

type LimiterProvider added in v0.5.0

type LimiterProvider string

type LoggerConfiguration

type LoggerConfiguration struct {
	Level string `json:"level" envconfig:"CONVOY_LOGGER_LEVEL"`
}

type NativeRealmOptions

type NativeRealmOptions struct {
	Enabled bool `json:"enabled" envconfig:"CONVOY_NATIVE_REALM_ENABLED"`
}

type NewRelicConfiguration

type NewRelicConfiguration struct {
	AppName                  string `json:"app_name" envconfig:"CONVOY_NEWRELIC_APP_NAME"`
	LicenseKey               string `json:"license_key" envconfig:"CONVOY_NEWRELIC_LICENSE_KEY"`
	ConfigEnabled            bool   `json:"config_enabled" envconfig:"CONVOY_NEWRELIC_CONFIG_ENABLED"`
	DistributedTracerEnabled bool   `json:"distributed_tracer_enabled" envconfig:"CONVOY_NEWRELIC_DISTRIBUTED_TRACER_ENABLED"`
}

type OnPremStorage added in v0.8.1

type OnPremStorage struct {
	Path string `json:"path" envconfig:"CONVOY_STORAGE_PREM_PATH"`
}

type PrometheusConfiguration added in v0.6.0

type PrometheusConfiguration struct {
	Dsn string `json:"dsn" envconfig:"CONVOY_PROM_DSN"`
}

type QueueProvider

type QueueProvider string

type RedisConfiguration added in v1.1.6

type RedisConfiguration struct {
	Scheme    string `json:"scheme" envconfig:"CONVOY_REDIS_SCHEME"`
	Host      string `json:"host" envconfig:"CONVOY_REDIS_HOST"`
	Username  string `json:"username" envconfig:"CONVOY_REDIS_USERNAME"`
	Password  string `json:"password" envconfig:"CONVOY_REDIS_PASSWORD"`
	Database  string `json:"database" envconfig:"CONVOY_REDIS_DATABASE"`
	Port      int    `json:"port" envconfig:"CONVOY_REDIS_PORT"`
	Addresses string `json:"addresses" envconfig:"CONVOY_REDIS_CLUSTER_ADDRESSES"`
}

func (RedisConfiguration) BuildDsn added in v1.1.6

func (rc RedisConfiguration) BuildDsn() []string

type S3Storage added in v0.8.1

type S3Storage struct {
	Bucket       string `json:"bucket" envconfig:"CONVOY_STORAGE_AWS_BUCKET"`
	AccessKey    string `json:"access_key" envconfig:"CONVOY_STORAGE_AWS_ACCESS_KEY"`
	SecretKey    string `json:"secret_key" envconfig:"CONVOY_STORAGE_AWS_SECRET_KEY"`
	Region       string `json:"region" envconfig:"CONVOY_STORAGE_AWS_REGION"`
	SessionToken string `json:"session_token" envconfig:"CONVOY_STORAGE_AWS_SESSION_TOKEN"`
	Endpoint     string `json:"endpoint" envconfig:"CONVOY_STORAGE_AWS_ENDPOINT"`
}

type SMTPConfiguration

type SMTPConfiguration struct {
	SSL      bool   `json:"ssl" envconfig:"CONVOY_SMTP_SSL"`
	Provider string `json:"provider" envconfig:"CONVOY_SMTP_PROVIDER"`
	URL      string `json:"url" envconfig:"CONVOY_SMTP_URL"`
	Port     uint32 `json:"port" envconfig:"CONVOY_SMTP_PORT"`
	Username string `json:"username" envconfig:"CONVOY_SMTP_USERNAME"`
	Password string `json:"password" envconfig:"CONVOY_SMTP_PASSWORD"`
	From     string `json:"from" envconfig:"CONVOY_SMTP_FROM"`
	ReplyTo  string `json:"reply-to" envconfig:"CONVOY_SMTP_REPLY_TO"`
}

type SearchConfiguration added in v0.6.0

type SearchConfiguration struct {
	Type      SearchProvider         `json:"type" envconfig:"CONVOY_SEARCH_TYPE"`
	Typesense TypesenseConfiguration `json:"typesense"`
}

type SearchProvider added in v0.6.0

type SearchProvider string

type ServerConfiguration

type ServerConfiguration struct {
	HTTP HTTPServerConfiguration `json:"http"`
}

type SignatureHeaderProvider

type SignatureHeaderProvider string

func (SignatureHeaderProvider) String

func (s SignatureHeaderProvider) String() string

type StoragePolicyConfiguration added in v0.8.1

type StoragePolicyConfiguration struct {
	Type   string        `json:"type" envconfig:"CONVOY_STORAGE_POLICY_TYPE"`
	S3     S3Storage     `json:"s3"`
	OnPrem OnPremStorage `json:"on_prem"`
}

type TracerConfiguration

type TracerConfiguration struct {
	Type     TracerProvider        `json:"type" envconfig:"CONVOY_TRACER_PROVIDER"`
	NewRelic NewRelicConfiguration `json:"new_relic"`
}

type TracerProvider

type TracerProvider string

type TypesenseConfiguration added in v0.6.0

type TypesenseConfiguration struct {
	Host   string `json:"host" envconfig:"CONVOY_TYPESENSE_HOST"`
	ApiKey string `json:"api_key" envconfig:"CONVOY_TYPESENSE_API_KEY"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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