Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// Core services — all exported for direct access
Router *router.VelocityRouterV2
DB *orm.Manager
Auth *auth.Manager
Log log.Logger
Cache *cache.Manager
Crypto crypto.Encryptor
CSRF *csrf.CSRF
Events events.Dispatcher
Queue queue.Driver
Storage *storage.Manager
View *view.Engine
Scheduler *scheduler.Scheduler
Mail mail.Mailer
// contains filtered or unexported fields
}
App represents the Velocity application container. It owns all framework subsystem instances and provides them to the consumer.
func Default ¶ added in v0.9.5
Default creates a pre-configured App from env vars and sets it as the default for all package-level convenience functions. This provides a migration path from global singletons to explicit DI.
func New ¶
New creates a new Velocity application with all services initialized. Services are initialized in dependency order. If any required service fails to initialize, New returns an error — it never panics.
func NewTestApp ¶ added in v0.9.5
NewTestApp creates an App with in-memory services suitable for testing. Uses memory cache, memory queue, and console logger.
func (*App) Serve ¶ added in v0.9.5
Serve starts the HTTP server with signal handling and graceful shutdown.
type AuthConfig ¶ added in v0.9.5
type AuthConfig struct {
DefaultGuard string // AUTH_GUARD
Guards map[string]GuardConfig // Guard definitions
Providers map[string]ProviderConfig // Provider definitions
BcryptCost int // HASH_BCRYPT_COST, default 10
}
AuthConfig holds authentication configuration.
type CacheConfig ¶ added in v0.9.5
type CacheConfig struct {
Driver string // CACHE_DRIVER: memory, file, redis, database
Prefix string // CACHE_PREFIX, default "velocity_cache"
Path string // CACHE_PATH (for file driver)
RedisHost string // REDIS_HOST, default "127.0.0.1"
RedisPort int // REDIS_PORT, default 6379
RedisPassword string // REDIS_PASSWORD
RedisDatabase int // REDIS_DATABASE, default 0
}
CacheConfig holds cache configuration.
type Config ¶ added in v0.9.5
type Config struct {
// App
Name string // APP_NAME, default "Velocity"
Env string // APP_ENV, default "development"
Debug bool // APP_DEBUG, default false
Port string // PORT, default "4000"
Key string // APP_KEY (used for crypto)
// Database
DB DBConfig
// Auth
Auth AuthConfig
// Cache
Cache CacheConfig
// Log
Log LogConfig
// Queue
Queue QueueConfig
// Storage
Storage StorageConfig
// Session
Session SessionConfig
// View
View ViewConfig
// Crypto
Crypto CryptoConfig
// Mail
Mail MailConfig
}
Config holds all configuration for a Velocity application. It replaces the scattered os.Getenv() calls across packages.
func ConfigFromEnv ¶ added in v0.9.5
func ConfigFromEnv() Config
ConfigFromEnv loads configuration from environment variables and .env file.
type CryptoConfig ¶ added in v0.9.5
type CryptoConfig struct {
Key string // APP_KEY or CRYPTO_KEY
Cipher string // CRYPTO_CIPHER, default "AES-256-GCM"
PreviousKeys []string // CRYPTO_OLD_KEYS (comma-separated)
}
CryptoConfig holds encryption configuration.
type DBConfig ¶ added in v0.9.5
type DBConfig struct {
Connection string // DB_CONNECTION: sqlite, postgres, mysql
Host string // DB_HOST, default "127.0.0.1"
Port string // DB_PORT, default per driver
Database string // DB_DATABASE
Username string // DB_USERNAME
Password string // DB_PASSWORD
Charset string // DB_CHARSET
Collation string // DB_COLLATION
Prefix string // DB_PREFIX
Schema string // DB_SCHEMA
SSLMode string // DB_SSL_MODE
Timezone string // DB_TIMEZONE
MaxIdleConns int // DB_MAX_IDLE_CONNS, default 10
MaxOpenConns int // DB_MAX_OPEN_CONNS, default 100
ConnMaxLifetime time.Duration // DB_CONN_MAX_LIFETIME, default 3600s
LogQueries bool // DB_LOG_QUERIES
SlowThreshold time.Duration // DB_SLOW_QUERY_THRESHOLD
}
DBConfig holds database configuration.
type DiskConfig ¶ added in v0.9.5
type DiskConfig struct {
Driver string // "local", "s3", "memory"
Root string // Root path for local driver
// S3 fields
Bucket string
Region string
Key string
Secret string
Endpoint string
URL string
}
DiskConfig holds configuration for a single storage disk.
type GuardConfig ¶ added in v0.9.5
type GuardConfig struct {
Driver string // "session" or "jwt"
Provider string // Provider name
Options map[string]interface{} // Guard-specific options
}
GuardConfig holds configuration for an auth guard.
type JWTConfig ¶ added in v0.9.5
type JWTConfig struct {
Secret string // JWT_SECRET
Algorithm string // JWT_ALGO, default "HS256"
TTL int // JWT_TTL in minutes, default 60
RefreshTTL int // JWT_REFRESH_TTL in minutes, default 20160
BlacklistEnabled bool // JWT_BLACKLIST_ENABLED, default true
}
JWTConfig holds JWT guard configuration.
type LogConfig ¶ added in v0.9.5
type LogConfig struct {
Driver string // LOG_DRIVER: console, file
Config map[string]any // Driver-specific config (e.g., "path" for file driver)
}
LogConfig holds logging configuration.
type MailConfig ¶ added in v0.9.5
type MailConfig struct {
Driver string // MAIL_DRIVER: postmark, mailgun, log
}
MailConfig holds mail configuration.
type Option ¶ added in v0.9.5
type Option func(*App)
Option is a function that configures the App.
func WithConfig ¶ added in v0.9.5
WithConfig sets a custom configuration.
type ProviderConfig ¶ added in v0.9.5
type ProviderConfig struct {
Driver string // "orm"
Model string // AUTH_MODEL, default "User"
Options map[string]interface{}
}
ProviderConfig holds configuration for an auth user provider.
type QueueConfig ¶ added in v0.9.5
type QueueConfig struct {
Driver string // QUEUE_DRIVER: memory, redis, database
RedisHost string // QUEUE_REDIS_HOST, default "localhost"
RedisPort string // QUEUE_REDIS_PORT, default "6379"
RedisPassword string // QUEUE_REDIS_PASSWORD
RedisDB string // QUEUE_REDIS_DB, default "0"
}
QueueConfig holds queue configuration.
type SessionConfig ¶ added in v0.9.5
type SessionConfig struct {
Driver string // SESSION_DRIVER, default "cookie"
Name string // SESSION_NAME, default "velocity_session"
Lifetime int // SESSION_LIFETIME in minutes, default 120
Path string // SESSION_PATH, default "/"
Domain string // SESSION_DOMAIN
Secure bool // SESSION_SECURE, default true
HttpOnly bool // SESSION_HTTP_ONLY, default true
SameSite http.SameSite // SESSION_SAME_SITE, default Lax
}
SessionConfig holds session configuration.
type StorageConfig ¶ added in v0.9.5
type StorageConfig struct {
Default string // STORAGE_DRIVER, default "local"
Disks map[string]DiskConfig // Disk configurations
}
StorageConfig holds storage configuration.
Directories
¶
| Path | Synopsis |
|---|---|
|
broadcast
Package broadcast provides a high-level broadcasting system for real-time communication built on top of the WebSocket package and supporting multiple drivers
|
Package broadcast provides a high-level broadcasting system for real-time communication built on top of the WebSocket package and supporting multiple drivers |
|
cache/testing
Package testing provides test helpers for the cache package.
|
Package testing provides test helpers for the cache package. |
|
exceptions
Package exceptions provides Laravel-style exception handling for Velocity.
|
Package exceptions provides Laravel-style exception handling for Velocity. |
|
grpc
Package grpc provides a fluent API for building gRPC servers and HTTP gateways.
|
Package grpc provides a fluent API for building gRPC servers and HTTP gateways. |
|
grpc/converters
Package converters provides utilities for converting between Go types and protobuf types.
|
Package converters provides utilities for converting between Go types and protobuf types. |
|
grpc/grpcevents
Package grpcevents provides event types for gRPC operations.
|
Package grpcevents provides event types for gRPC operations. |
|
grpc/interceptors
Package interceptors provides gRPC interceptors for Velocity applications.
|
Package interceptors provides gRPC interceptors for Velocity applications. |
|
httpclient
Package httpclient provides an instrumented HTTP client for APM monitoring.
|
Package httpclient provides an instrumented HTTP client for APM monitoring. |
|
mail/alldrivers
Package alldrivers imports all mail drivers to register them Import this package with _ to ensure all drivers are registered
|
Package alldrivers imports all mail drivers to register them Import this package with _ to ensure all drivers are registered |
|
router
Package router provides HTTP routing functionality for the Velocity framework.
|
Package router provides HTTP routing functionality for the Velocity framework. |
|
trace
Package trace provides distributed tracing context helpers for APM instrumentation.
|
Package trace provides distributed tracing context helpers for APM instrumentation. |