Releases: gofr-dev/gofr
v1.43.0
v1.43.0
🚀 Features
- Startup Hooks Support (
OnStart
)
GoFr now allows registering synchronous startup jobs using the OnStart
method.
This enables actions like:
-
Warming up Redis or in-memory caches
-
Seeding databases
-
Validating configuration before traffic is served
The method receives a fully initialized *gofr.Context
with access to SQL, Redis, and Logger instances. If any hook fails, the app will gracefully shut down with clear logs.
🛠️ Example usage:
a.OnStart(func(ctx *gofr.Context) error {
return ctx.Redis.Set(ctx, "key", "value", 0).Err()
})
This ensures critical setup steps are completed before your app starts accepting traffic.
🛠️ Fixes
- PubSub Migrator Chain Fix
Previously incorrect migration state visibility was seen when PubSub was connected. This has been resolved. Now it retrieves correct version from PubSub and continues chain to next migrator. Handles query failures without skipping downstream migrators
v1.42.5
v1.42.5
🚀 Enhancements
🔹 ScyllaDB Migrator Support
GoFr now includes native support for ScyllaDB migrations.
🧩 Supported Migration Interface:
type ScyllaDB interface {
Query(dest any, stmt string, values ...any) error
QueryWithCtx(ctx context.Context, dest any, stmt string, values ...any) error
Exec(stmt string, values ...any) error
ExecWithCtx(ctx context.Context, stmt string, values ...any) error
ExecCAS(dest any, stmt string, values ...any) (bool, error)
NewBatch(name string, batchType int) error
NewBatchWithCtx(ctx context.Context, name string, batchType int) error
BatchQuery(name, stmt string, values ...any) error
BatchQueryWithCtx(ctx context.Context, name, stmt string, values ...any) error
ExecuteBatchWithCtx(ctx context.Context, name string) error
}
🔹 OpenTSDB Migrator Support
Support for OpenTSDB migration operations, enable you to pre-seed metrics and manage annotations.
✅ Key Features:
-
Versioned JSON-based migration files
-
Integrated directly into GoFr's migration interface
🧩 Supported Migration Interface:
type OpenTSDB interface {
// PutDataPoints can be used for seeding initial metrics during migration
PutDataPoints(ctx context.Context, data any, queryParam string, res any) error
// PostAnnotation creates or updates an annotation in OpenTSDB using the 'POST /api/annotation' endpoint.
PostAnnotation(ctx context.Context, annotation any, res any) error
// PutAnnotation creates or replaces an annotation in OpenTSDB using the 'PUT /api/annotation' endpoint.
PutAnnotation(ctx context.Context, annotation any, res any) error
// DeleteAnnotation removes an annotation from OpenTSDB using the 'DELETE /api/annotation' endpoint.
DeleteAnnotation(ctx context.Context, annotation any, res any) error
}
📚 Documentation
See gofr.dev/migrations for full examples, best practices, and schema layouts for ScyllaDB and OpenTSDB migrations.
v1.42.4
v1.42.4
🛠️ Improvements
-
Elasticsearch Migrator for Versioned Changes
GoFr now includes a dedicated Elasticsearch migrator under
pkg/migration
for managing version-controlled changes like index creation, mapping updates, and analyzer definitions.
Key Features:- Seamless integration with GoFr’s internal migrator interface.
- Uses Elasticsearch’s REST API for all operations.
- Maintains migration state for reliable deployments.
Refer to gofr.dev/migrations for more details and examples.
🐞 Bug Fixes
-
Fixed Panic in Context Logging in GoFr CMD Apps
A bug that caused a panic when using
ctx.Warnf
instead ofctx.Logger.Warnf
has been fixed.Behavior Before:
Calling
ctx.Warnf
in GoFr CMD Apps resulted in:panic: runtime error: invalid memory address or nil pointer dereference
Now:
ctx.Warnf
functions correctly and logs without causing runtime crashes.
v1.42.3
v1.42.3
🛡️ Security Fix
- Resolved weak RSA key generation in
mock_oauth_server.go
. - Previously, a 1024-bit RSA key was being generated in the mock OAuth server (rsa.GenerateKey).
- Increased the key size to 2048 bits, aligning with modern cryptographic standards and addressing CodeQL alert #73.
v1.42.2
v1.42.2
🛠️ Improvements
1. Versioned Migrations Support Extended to NATS and EventHub
Following up on versioned migration support for Kafka, MQTT, and Google PubSub in the previous release, GoFr now officially adds:
- NATS
- Azure EventHub
Both now support versioned migrations, allowing event streaming systems to be schema-evolvable and compatible with data migration needs.
2. Cleaner AuthConfig APIs for External Services
You can now configure external services like catfact.ninja
using streamlined constructors:
Old Way:
app.AddHTTPService("cat-facts", "https://catfact.ninja",
&service.APIKeyConfig{APIKey: "some-random-key"},
&service.BasicAuthConfig{UserName: "gofr", Password: "gofr"})
New Way:
app.AddHTTPService("cat-facts", "https://catfact.ninja",
service.NewAPIKeyConfig("some-random-key"),
service.NewBasicAuthConfig("username", "password"),
)
NewBasicAuthConfig(username, password)
:
- Trims values
- Validates presence of both fields
- Ensures password is base64 encoded, preventing unsafe plaintext usage
- Returns clear errors for invalid formats
NewAPIKeyConfig(apiKey)
:
- Simplified usage
- Validated internally
- Adds cleaner abstraction with automatic header injection
v1.42.1
v1.42.1
🛠️ Improvements
1. NewOAuthConfig()
for Safer OAuth Setup
GoFr now includes a dedicated constructor to validate OAuth configurations for interservice HTTP calls, ensuring secure and consistent authentication setup. Refer to the official documentation to know more :
NewOAuthConfig(
clientID, // string: OAuth2 client ID (required)
secret, // string: OAuth2 client secret (required)
tokenURL, // string: Token exchange endpoint (required & validated)
scopes, // []string: Optional OAuth2 scopes
params, // url.Values: Optional additional endpoint parameters
authStyle, // oauth2.AuthStyle: Credential passing style (header/body/auto)
)
🔍 Why this matters:
-
Prevents common misconfigurations like missing
tokenURL
, which previously caused vague errors such as:Post "": unsupported protocol scheme ""
-
Performs validation on required fields and returns clear error messages.
-
Encourages safe and standardized OAuth client setup.
✅ Example Usage:
config, err := NewOAuthConfig(
"my-client-id", // clientID
"my-client-secret", // secret
"https://provider.com/oauth/token", // tokenURL
[]string{"read", "write"}, // scopes
nil, // params
oauth2.AuthStyleAutoDetect, // authStyle
)
if err != nil {
log.Fatal(err)
}
Refer to the official documentation to know more.
2. Configurable AuthStyle
in OAuth
The AuthStyle
field in OAuth2 configuration is now configurable by the user.
🔧 Behavior:
-
Previously hardcoded to
oauth2.AuthStyleInHeader
-
Now allows values such as:
oauth2.AuthStyleAutoDetect
(default)oauth2.AuthStyleInHeader
oauth2.AuthStyleInParams
This makes GoFr's OAuth integration more flexible and compatible with diverse OAuth providers.
3. Versioned Migrations in Kafka, MQTT, and Google PubSub
GoFr now supports versioned migrations for the following data sources:
- ✅ Kafka
- ✅ MQTT
- ✅ Google PubSub
🧩 Additional Config (MQTT only):
To support retained message fetching for versioned migrations in MQTT, enable:
MQTT_RETRIEVE_RETAINED=true
By default, this is set to false
to maintain backward compatibility. When set to true, this actually retains the latest message for each topics in the connected MQTT host, hence aiding in versioned migrations.
v1.42.0
v1.42.0
🚀 Features
1. CockroachDB Support
GoFr now supports CockroachDB, a distributed cloud-native SQL database.
Developers can now configure GoFr services to connect to CockroachDB using simple environment variables.
🔧 Configuration:
DB_DIALECT=cockroachdb
DB_HOST=localhost
DB_PORT=26257
DB_USER=root
DB_PASSWORD=your-password
DB_NAME=defaultdb
DB_SSL_MODE=require
For more details, refer to the SQL usage guide.
🛠️ Improvements
1. gRPC Reflection Toggle via Config
GoFr now supports enabling/disabling gRPC server reflection using a simple config flag:
GRPC_ENABLE_REFLECTION=true
🔍 When to enable:
-
Development & Debugging: Use with tools like grpcurl, Postman, or Evans.
-
Internal Networks: Safe in private, trusted environments.
-
CI/CD Pipelines: Ideal for service discovery in automated setups.
This allows dynamic inspection of gRPC services while maintaining control over exposure.
🛠️ Fixes
1. Supabase Healthcheck Issue Resolved
Resolved an issue where Supabase-backed services were not responding properly to health checks due to incorrect handling of internal pings.
2. Fixed Data Race in Metrics Gauges
Addressed a concurrency bug where the internal float64Gauge
map was accessed without synchronization. Proper locking is now in place around map access to avoid data races during concurrent SetGauge
and metric reads.
3. App Name & Version Initialization Bug
Fixed a configuration issue where AppName
and AppVersion
were incorrectly defaulting to gofr-app
and dev
, even when explicitly provided by the user. These values now correctly reflect user-specified configuration during startup.
v1.41.0
v1.41.0
🔧 Improvements
1. New HTTP Error Type: ErrorRecordNotFound
A new standardized error type http.ErrorRecordNotFound
has been introduced to gracefully handle scenarios where no records are found in the database.
Example:
return nil, http.ErrorRecordNotFound{
Message: "User not found with the given ID",
}
This improves semantic clarity and enables better client-side handling for empty-query results.
2. Improved Cron Job Observability
All cron jobs in GoFr now come with built-in logger and tracing support.
-
Logs from scheduled tasks are now clearly visible.
-
Each recurring job run is automatically tagged with a unique trace ID, making it easier to trace, debug, and monitor scheduled executions across your system.
This ensures better observability for background tasks without requiring additional instrumentation.
🐛 Fixes
1. Supabase Connection Issue Resolved
Previously, Supabase connections were not initializing correctly in GoFr due to a missing dialect registration. Supabase-backed services will now connect without issues—no manual fixes required.
v1.40.1
v1.40.1
🔧 Dependency Updates
Upgraded all externalized datasource dependencies to their latest stable versions for improved performance, security, and compatibility across supported services.
v1.40.0
v1.40.0
🚀 Features
Support for Supabase Database
Users can now connect their GoFr services to a Supabase database using environment variables. This feature supports both direct and pooled connections, enabling secure and scalable Postgres usage via Supabase.
🔧 Environment Variable Setup:
DB_DIALECT=supabase
DB_HOST=db.[PROJECT_REF].supabase.co # Optional, derived from PROJECT_REF
DB_USER=postgres # Or database user name
DB_PASSWORD=password
DB_NAME=postgres # Or your database name
DB_PORT=5432 # Optional, defaults based on connection type
DB_SSL_MODE=require # Optional, forced to "require" for Supabase
# Supabase-specific configs
SUPABASE_PROJECT_REF=your_project_ref
SUPABASE_CONNECTION_TYPE=direct # Options: direct, session, transaction
SUPABASE_REGION=us-east-1 # Required for pooled connections
# Alternatively, can provide full connection string
DATABASE_URL=postgresql://postgres:password@db.your_project_ref.supabase.co:5432/postgres
Inter-Service WebSocket Communication
GoFr now supports Inter-Service WebSocket Communication, enabling services to exchange real-time messages over WebSocket connections. Ideal for microservices needing live updates or event-driven communication.
🔑 Key Methods:
-
AddWSService
: Register a persistent WebSocket connection to another service with optional auto-reconnect. -
WriteMessageToService
: Send messages to any registered service.
✅ Example Usage:
func main(){
app := gofr.New()
err := app.AddWSService("notification-service", "ws://notifications.example.com/ws", nil, true, 5*time.Second)
if err != nil {
app.Logger.Errorf("Failed to add WebSocket service: %v", err)
return
}
app.POST("/send-notification", func(ctx *gofr.Context) (any, error) {
message := map[string]string{
"title": "New Message",
"content": "You have a new notification!",
}
err := ctx.WriteMessageToService("notification-service", message)
if err != nil {
return nil, err
}
return "Notification sent successfully!", nil
})
app.Run()
}
This enables resilient, real-time service communication with minimal configuration.
🔧 Improvements
1. New HTTP Error Type: ServiceUnavailable
A new standardized error type ErrorServiceUnavailable
has been introduced for representing service unavailability due to dependency issues like database failures or third-party service outages.
⚙️ Use Case Example:
err := http.ErrorServiceUnavailable{
Dependency: "PostgreSQL",
ErrorMessage: "Connection timeout",
}
This improvement enhances observability and clarity when dealing with critical external failures.