Release v1.33.0
🚀 Features
1. ArangoDB Support as a Datasource
Users can now integrate ArangoDB as a datasource within their GoFr applications. Supported Methods include :
type ArangoDB interface {
// CreateDocument creates a new document in the specified collection.
CreateDocument(ctx context.Context, dbName, collectionName string, document any) (string, error)
// GetDocument retrieves a document by its ID from the specified collection.
GetDocument(ctx context.Context, dbName, collectionName, documentID string, result any) error
// UpdateDocument updates an existing document in the specified collection.
UpdateDocument(ctx context.Context, dbName, collectionName, documentID string, document any) error
// DeleteDocument deletes a document by its ID from the specified collection.
DeleteDocument(ctx context.Context, dbName, collectionName, documentID string) error
// GetEdges retrieves all the edge documents connected to a specific vertex in an ArangoDB graph.
GetEdges(ctx context.Context, dbName, graphName, edgeCollection, vertexID string, resp any) error
// Query executes an AQL query and binds the results
Query(ctx context.Context, dbName string, query string, bindVars map[string]any, result any) error
HealthCheck(context.Context) (any, error)
}
Refer to our official documentation to know more.
2. Default HealthCheck Support for gRPC Servers and Clients
This release introduces built-in HealthCheck support for both gRPC servers and clients.
-
Prerequisites:
To use the new health check features, ensure that gofr-cli v0.5.0 is installed. Use it to generate your gRPC client and server templates. -
gRPC Servers
After running the existing command:gofr wrap grpc server -proto=path/to/your/proto/file
A new file named
health_gofr.go
will be generated. This file contains the health functionality for your gRPC server. The health methods are embedded within the GoFr gRPC server struct, which looks like this:type {serviceName}GoFrServer struct { health *healthServer }
Supported HealthCheck Methods:
// Check checks if the service is healthy. func (h *healthServer) Check(ctx *gofr.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) // Watch watches for any changes in the service’s health status. func (h *healthServer) Watch(ctx *gofr.Context, in *grpc_health_v1.HealthCheckRequest, stream grpc_health_v1.Health_WatchServer) error // SetServingStatus allows you to set the health status of the service (healthy, unhealthy, etc.). func (h *healthServer) SetServingStatus(ctx *gofr.Context, service string, status grpc_health_v1.HealthCheckResponse_ServingStatus) // Shutdown gracefully shuts down the service. func (h *healthServer) Shutdown(ctx *gofr.Context) // Resume resumes the service after it has been shut down. func (h *healthServer) Resume(ctx *gofr.Context)
To integrate these health features, register your gRPC server in
main.go
as follows:func main() { app := gofr.New() packageName.Register{serviceName}ServerWithGofr(app, &{packageName}.New{serviceName}GoFrServer()) app.Run() }
-
For gRPC Clients
HealthCheck calls are now supported on all gRPC clients generated through the gofr-cli command i.e :gofr wrap grpc client -proto=path/to/your/proto/file
Supported HealthCheck methods include :
// Check checks the service health. func (c *{serviceName}GoFrClient) Check(ctx *gofr.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) // Watch allows the client to watch for health status changes. func (c *{serviceName}GoFrClient) Watch(ctx *gofr.Context, in *grpc_health_v1.HealthCheckRequest) (grpc.ServerStreamingClient[grpc_health_v1.HealthCheckResponse], error)
For a deeper understanding, check out our official documentation and refer to our example repo.
🛠️ Fix
Resolved an issue with the AddRESTHandlers
support where PUT requests were not updating records in the database when we have autoincrement
tag added in our entity struct. The issue has now been fixed.