cfg

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobConfig

type BlobConfig struct {
	ProjectURL string // Base project URL of the blob storage service
	APIKey     string // API key for authentication with the blob storage provider
	Bucket     string // Target bucket name for storing or retrieving objects
}

BlobConfig holds the configuration required to connect to a blob storage provider.

func LoadEnvBlobConfig

func LoadEnvBlobConfig() (*BlobConfig, error)

LoadEnvBlobConfig reads the BlobConfig values from environment variables: BLOB_PROJECT_URL, BLOB_API_KEY, and BLOB_BUCKET.

func NewBlobConfig

func NewBlobConfig(url, apiKey, bucket string) *BlobConfig

func (*BlobConfig) WithAPIKey

func (cfg *BlobConfig) WithAPIKey(apiKey string) *BlobConfig

WithAPIKey sets the APIKey and returns the updated BlobConfig.

func (*BlobConfig) WithBucket

func (cfg *BlobConfig) WithBucket(bucket string) *BlobConfig

WithBucket sets the Bucket and returns the updated BlobConfig.

func (*BlobConfig) WithProjectURL

func (cfg *BlobConfig) WithProjectURL(url string) *BlobConfig

WithProjectURL sets the ProjectURL and returns the updated BlobConfig.

type DBConfig

type DBConfig struct {
	Driver      string        // Driver is used to set db engine (postgres, mysql and so on)
	DSN         string        // DSN is used to connect to the database
	PoolSize    uint8         // Maximum number of open connections in the pool
	MaxIdle     uint8         // Maximum number of idle connections in the pool
	MaxLifetime time.Duration // Maximum lifetime of a connection before it's recycled
}

DBConfig holds the configuration parameters for a database connection.

func LoadEnvDBConfig

func LoadEnvDBConfig() (*DBConfig, error)

LoadEnvDBConfig loads the database configuration from environment variables. Required variables: DB_DSN, DB_POOL_SIZE, DB_MAX_IDLE, DB_MAX_LIFETIME.

func NewDBConfig

func NewDBConfig(driver, dsn string, size, maxIdle uint8, maxLT time.Duration) *DBConfig

func (*DBConfig) WithDSN

func (cfg *DBConfig) WithDSN(dsn string) *DBConfig

WithDSN sets the DSN string and returns the updated DBConfig.

func (*DBConfig) WithDriver added in v0.2.0

func (cfg *DBConfig) WithDriver(driver string) *DBConfig

WithDriver sets the Driver string and returns the updated DBConfig.

func (*DBConfig) WithIdle

func (cfg *DBConfig) WithIdle(idle uint8) *DBConfig

WithIdle sets the MaxIdle value and returns the updated DBConfig.

func (*DBConfig) WithMaxLifetime

func (cfg *DBConfig) WithMaxLifetime(maxTL time.Duration) *DBConfig

WithMaxLifetime sets the MaxLifetime value and returns the updated DBConfig.

func (*DBConfig) WithPoolSize

func (cfg *DBConfig) WithPoolSize(size uint8) *DBConfig

WithPoolSize sets the PoolSize and returns the updated DBConfig.

type JWTConfig

type JWTConfig struct {
	CookieName string        // Name of the cookie that stores the JWT
	Secret     string        // Secret key used to sign JWTs
	TokenTTL   time.Duration // Time-to-live duration of the token
}

JWTConfig holds the configuration related to JWT-based authentication.

func LoadEnvJWTConfig

func LoadEnvJWTConfig() (*JWTConfig, error)

LoadEnvJWTConfig loads the JWT configuration from environment variables: JWT_COOKIE_NAME, JWT_SECRET, and JWT_TOKEN_TTL.

func NewJWTConfig

func NewJWTConfig(name, secret string, ttl time.Duration) *JWTConfig

func (*JWTConfig) WithCookieName

func (cfg *JWTConfig) WithCookieName(name string) *JWTConfig

WithCookieName sets the cookie name for the JWTConfig.

func (*JWTConfig) WithSecret

func (cfg *JWTConfig) WithSecret(secret string) *JWTConfig

WithSecret sets the secret key for signing JWTs in the JWTConfig.

func (*JWTConfig) WithTokenTTL

func (cfg *JWTConfig) WithTokenTTL(ttl time.Duration) *JWTConfig

WithTokenTTL sets the token time-to-live for the JWTConfig.

type KVConfig

type KVConfig struct {
	KVStoreURL string // URL of the key-value store
}

KVConfig holds configuration details for connecting to a key-value store.

func LoadEnvKVConfig

func LoadEnvKVConfig() (*KVConfig, error)

LoadEnvKVConfig loads the key-value store configuration from the environment variable KV_STORE_URL.

func NewKVConfig

func NewKVConfig(kvStoreURL string) *KVConfig

func (*KVConfig) WithKVStoreURL

func (cfg *KVConfig) WithKVStoreURL(url string) *KVConfig

WithKVStoreURL sets a new key-value store URL and returns the updated KVConfig.

type MailerConfig

type MailerConfig struct {
	Host     string // SMTP server host
	Port     string // SMTP server port
	Username string // SMTP username for authentication
	Password string // SMTP password or token for authentication
	From     string // Default "From" email address
}

MailerConfig holds SMTP configuration for sending emails.

func LoadEnvMailerConfig

func LoadEnvMailerConfig() (*MailerConfig, error)

LoadEnvMailerConfig loads MailerConfig values from environment variables: MAILER_HOST, MAILER_PORT, MAILER_USERNAME, MAILER_PASSWORD, MAILER_FROM.

func NewMailerConfig

func NewMailerConfig(host, port, username, password, from string) *MailerConfig

func (*MailerConfig) WithFrom

func (cfg *MailerConfig) WithFrom(from string) *MailerConfig

WithFrom sets the default "From" email address and returns the updated MailerConfig.

func (*MailerConfig) WithHost

func (cfg *MailerConfig) WithHost(host string) *MailerConfig

WithHost sets the SMTP host and returns the updated MailerConfig.

func (*MailerConfig) WithPassword

func (cfg *MailerConfig) WithPassword(password string) *MailerConfig

WithPassword sets the SMTP password and returns the updated MailerConfig.

func (*MailerConfig) WithPort

func (cfg *MailerConfig) WithPort(port string) *MailerConfig

WithPort sets the SMTP port and returns the updated MailerConfig.

func (*MailerConfig) WithUsername

func (cfg *MailerConfig) WithUsername(username string) *MailerConfig

WithUsername sets the SMTP username and returns the updated MailerConfig.

type OAuthConfig

type OAuthConfig struct {
	ClientID     string // OAuth client ID
	ClientSecret string // OAuth client secret
	RedirectURL  string // OAuth redirect URL after authentication
}

OAuthConfig holds OAuth 2.0 client credentials and redirect URL.

func LoadEnvOAuthConfig

func LoadEnvOAuthConfig() (*OAuthConfig, error)

LoadEnvOAuthConfig loads OAuthConfig from environment variables: OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, and OAUTH_REDIRECT_URL.

func NewOAuthConfig

func NewOAuthConfig(clientID, clientSecret, redirectURL string) *OAuthConfig

func (*OAuthConfig) WithClientID

func (cfg *OAuthConfig) WithClientID(clientID string) *OAuthConfig

WithClientID sets the OAuth client ID and returns the updated config.

func (*OAuthConfig) WithClientSecret

func (cfg *OAuthConfig) WithClientSecret(clientSecret string) *OAuthConfig

WithClientSecret sets the OAuth client secret and returns the updated config.

func (*OAuthConfig) WithRedirectURL

func (cfg *OAuthConfig) WithRedirectURL(redirectURL string) *OAuthConfig

WithRedirectURL sets the OAuth redirect URL and returns the updated config.

type PaymentConfig

type PaymentConfig struct {
	APIKey        string // Public API key for the payment provider
	SecretKey     string // Secret key for authenticating requests
	WebhookURL    string // URL to receive payment provider webhook callbacks
	WebhookSecret string // Secret used to verify webhook authenticity
}

PaymentConfig holds configuration details for payment processing.

func LoadEnvPaymentConfig

func LoadEnvPaymentConfig() (*PaymentConfig, error)

LoadEnvPaymentConfig loads PaymentConfig from environment variables: PAYMENT_API_KEY, PAYMENT_SECRET_KEY, PAYMENT_WEBHOOK_URL, PAYMENT_WEBHOOK_SECRET.

func NewPaymentConfig

func NewPaymentConfig(apiKey, secretKey, url, webhookSecret string) *PaymentConfig

func (*PaymentConfig) WithAPIKey

func (cfg *PaymentConfig) WithAPIKey(key string) *PaymentConfig

WithAPIKey sets the API key and returns the updated config.

func (*PaymentConfig) WithSecretKey

func (cfg *PaymentConfig) WithSecretKey(secret string) *PaymentConfig

WithSecretKey sets the secret key and returns the updated config.

func (*PaymentConfig) WithWebhookSecret

func (cfg *PaymentConfig) WithWebhookSecret(secret string) *PaymentConfig

WithWebhookSecret sets the webhook secret and returns the updated config.

func (*PaymentConfig) WithWebhookURL

func (cfg *PaymentConfig) WithWebhookURL(url string) *PaymentConfig

WithWebhookURL sets the webhook URL and returns the updated config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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