Skip to content

Releases: gofr-dev/gofr

v1.22.1

03 Oct 07:22
71858f3
Compare
Choose a tag to compare

Release v1.22.1

✨ Fixes

  • Fix clickhouse Import
    Importing clickhouse import was failing in version 1.22.0, due to otel tracer package present as indirect dependency.

v1.22.0

01 Oct 11:00
f463335
Compare
Choose a tag to compare

Release v1.22.0

✨ Features

  • Support for tracing in clickhouse.
    Clickhouse Traces are now added and sent along with the respective request traces.

  • Support for sampling traces.
    Traces can now be sampled based on the env config TRACER_RATIO
    It refers to the proportion of traces that are exported through sampling. It ranges between 0 to 1. By default, this ratio is set to 1, meaning all traces are exported.

  • Support Azure Eventhub as external pub-sub datasource.
    Eventhub

    • Eventhub can be used similar to how messages are published and subscribed to KAFKA, MQTT and Google Pubsub.
    • To inject Eventhub import it using the following command.
      go get gofr.dev/pkg/gofr/datasources/pubsub/eventhub
      
    • Setup Eventhub by calling the AddPubSub method of gofr.
      app.AddPubSub(eventhub.New(eventhub.Config{  
       ConnectionString: "",  
       ContainerConnectionString: "",  
       StorageServiceURL: "",  
       StorageContainerName: "",  
       EventhubName: "",  
       ConsumerGroup: "",  
       }))
      

    Refer documentation to know how to get these values.

  • Support to enable HTTPS in the HTTP server
    You can now secure your servers with SSL/TLS certificates by adding the certificates through following configs - CERT_FILE and KEY_FILE.

✨ Fixes

  • Fix SQLite logs.
    Empty strings were coming due to difference in configuration parameters required in SQLite vs other SQL datasource when connecting which has been fixed.

v1.21.0

23 Sep 12:21
8c27cc1
Compare
Choose a tag to compare

Release v1.21.0

✨ Features

  • Support for DGraph

    Dgraph can be added using the method on gofrApp AddDgraph.
    Following methods are supported:
// Dgraph defines the methods for interacting with a Dgraph database.

type Dgraph interface {
// Query executes a read-only query in the Dgraph database and returns the result.
Query(ctx context.Context, query string) (interface{}, error)

// QueryWithVars executes a read-only query with variables in the Dgraph database.
QueryWithVars(ctx context.Context, query string, vars map[string]string) (interface{}, error)

// Mutate executes a write operation (mutation) in the Dgraph database and returns the result.
Mutate(ctx context.Context, mu interface{}) (interface{}, error)

// Alter applies schema or other changes to the Dgraph database.
Alter(ctx context.Context, op interface{}) error

// NewTxn creates a new transaction (read-write) for interacting with the Dgraph database.
NewTxn() interface{}

// NewReadOnlyTxn creates a new read-only transaction for querying the Dgraph database.
NewReadOnlyTxn() interface{}

// HealthChecker checks the health of the Dgraph instance.
HealthChecker
}

To use Dgraph in your GoFr application, follow the steps given below:

Step 1

go get gofr.dev/pkg/gofr/datasource/dgraph

Step 2

app.AddDgraph(dgraph.New(dgraph.Config{
Host: "localhost",
Port: "8080",
}))

GoFr supports both queries and mutations in Dgraph. To know more: Read the Docs

🛠 Enhancements

  • Migrations in Cassandra

    Users can now add migrations while using Cassandra as the datasource. This enhancement assumes that user has already created the KEYSPACE in cassandra. A KEYSPACE in Cassandra is a container for tables that defines data replication settings across the cluster. Visit the Docs to know more.
type Cassandra interface {
    Exec(query string, args ...interface{}) error
    NewBatch(name string, batchType int) error
    BatchQuery(name, stmt string, values ...any) error
    ExecuteBatch(name string) error
        HealthCheck(ctx context.Context) (any, error)
}

To achieve atomicity during migrations, users can leverage batch operations using the NewBatch, BatchQuery, and ExecuteBatch methods. These methods allow multiple queries to be executed as a single atomic operation.

When using batch operations, consider using batchType: LoggedBatch i.e. 0 for atomicity or an UnloggedBatch i.e. 1 for improved performance where atomicity isn't required. This approach provides a way to maintain data consistency during complex migrations.

  • Added mocks for Metrics

    MockContainer can be used to set expectation for metrics in the application while writing test.

    Usage:

        // GoFr's mockContainer
        _, mock := NewMockContainer(t)  
      
        // Set mock expectations using the mocks from NewMockContainer
        mock.Metrics.EXPECT().IncrementCounter(context.Background(), "name")
      
        // Call to your function where metrics has to be mocked
        .
        .
        .
    
    

v1.20.0

16 Sep 11:34
343d135
Compare
Choose a tag to compare

Release v1.20.0

✨ Features

  • Support for Solr
    Solr can now be used as a datasource, for adding Solr use AddSolr(cfg Solr.Config) method of gofrApp.
    Refer documentation for detailed info.
    Supported Functionalities are:
     Search(ctx context.Context, collection string, params map[string]any) (any, error)  
     Create(ctx context.Context, collection string, document *bytes.Buffer, params map[string]any) (any, error)  
     Update(ctx context.Context, collection string, document *bytes.Buffer, params map[string]any) (any, error)  
     Delete(ctx context.Context, collection string, document *bytes.Buffer, params map[string]any) (any, error)  
       
     Retrieve(ctx context.Context, collection string, params map[string]any) (any, error)  
     ListFields(ctx context.Context, collection string, params map[string]any) (any, error)  
     AddField(ctx context.Context, collection string, document *bytes.Buffer) (any, error)  
     UpdateField(ctx context.Context, collection string, document *bytes.Buffer) (any, error)  
     DeleteField(ctx context.Context, collection string, document *bytes.Buffer) (any, error)
    

🛠 Enhancements

  • Added mocks for HTTP Service
    Mocks to test GoFr HTTP client had to be generated manually. Now, mocks for the HTTP service has been added in GoFr's MockContainer.

    Usage:

        // register HTTP services to be mocked
        httpservices := []string{"cat-facts", "cat-facts1", "cat-facts2"}  
      
        // pass the httpservices in NewMockContainer
        _, mock := NewMockContainer(t, WithMockHTTPService(httpservices...))  
      
        // Set mock expectations using the mocks from NewMockContainer
        mock.HTTPService.EXPECT().Get(context.Background(), "fact",map[string]interface{}{  
        "max_length": 20,  
        }).Return(result, nil)  
      
        // Call to your function where HTTPService has to be mocked
        .
        .
        .
    

v1.19.1

09 Sep 12:20
5b2314f
Compare
Choose a tag to compare

Release v1.19.1

🛠 Enhancements

  • Support for S3 operations
    FileStore can now be initialised as S3 with the AddFileStore method.
    Since, S3 is an external datasource, it can be imported by:
    go get gofr.dev/pkg/gofr/datasource/file/s3

    Example:
    app.AddFileStore(s3.New(&s3.Config{EndPoint: "http://localhost:4566", BucketName: "gofr-bucket-2", Region: "us-east-1", AccessKeyID: "test", SecretAccessKey: "test"}))

    Supported functionalities are:

      Create(name string) (File, error)
      Mkdir(name string, perm os.FileMode) error
      MkdirAll(path string, perm os.FileMode) error
      Open(name string) (File, error)
      OpenFile(name string, flag int, perm os.FileMode) (File, error)
      Remove(name string) error
      RemoveAll(path string) error
      Rename(oldname, newname string) error
      ReadDir(dir string) ([]FileInfo, error)
      Stat(name string) (FileInfo, error)
      Getwd() (string, error)
    

🐞 Fixes

  • Resolved SQL mocks
    Previously the mock was not able to mock Query, QueryRow, Select, Dialect, HealthCheck methods. Hence, replaced mock-gen generated SQL mocks with go-mock-sql package in the mock container.

v1.19.0

02 Sep 11:48
78dcc62
Compare
Choose a tag to compare

Release v1.19.0

✨ Features

  • Support for second in cron format
    Cron job schedules can now be more precise with an optional addition field for seconds.
    Format can now be either 5 part or 6 part, denoting second (optional), minute, hour, day_of_month, month, day_of_week.

    Example:

    // Cron job to run every 10 second
    app.AddCronJob("*/10 * * * * *", "counter", count)
    // Cron job to run every 5 minute
    app.AddCronJob("*/5 * * * *", "counter", count)
    
  • Support for SFTP operations
    FileStore can now be initialised as SFTP with the AddFileStore method.
    Since, SFTP is an external datasource, it can be imported by:
    go get gofr.dev/pkg/gofr/datasource/file/sftp

    Example:
    app.AddFileStore(sftp.New(&sftp.Config{Host: "127.0.0.1", User: "user", Password: "password", Port: 22}))

    Supported functionalities are:

     Create(name string) (File, error)
     Mkdir(name string, perm os.FileMode) error
     MkdirAll(path string, perm os.FileMode) error
     Open(name string) (File, error)
     OpenFile(name string, flag int, perm os.FileMode) (File, error)
     Remove(name string) error
     RemoveAll(path string) error
     Rename(oldname, newname string) error
     ReadDir(dir string) ([]FileInfo, error)
     Stat(name string) (FileInfo, error)
     Getwd() (string, error)
    

🛠 Enhancements

  • Response with Partial Content status code
    If the handler returns both data as well as error, then the status code would now be Partial Content 206

  • Enhance Observability for FTP
    Logs formatting and structuring have been improved.
    A new histogram metric app_ftp_stats has been introduced to populate data for execution duration with labels as type and status.
    Image

  • Logger mock methods for testing purpose
    To help test the logging methods, mocks have now been generated with mockgen, instead of manually creating for every datasource.

🐞 Fixes

  • Resolved permission issues in directories
    While creating new directory, the permissions were missing for the directory. Fixed that by providing ModePerm (777) permissions.

v1.18.0

26 Aug 07:49
6ae3322
Compare
Choose a tag to compare

Release v1.18.0

✨ Features

  • SQL Tags in AddRESTHandlers
    The AddRESTHandlers function now supports the following SQL tags for enhanced data integrity and database handling:

    • auto_increment:
      When this tag is applied to a struct field, any provided ID value will be ignored. Instead, the ID returned by the database after insertion will be used.
    • not_null:
      This tag enforces a non-null constraint at the service level, ensuring that no nil value can be sent for the specified field.
      Incase nil value is sent, error will be returned.

    Example:

    type user struct {
        ID 		int 	`json:"id" 	sql:"auto_increment"`
        Name 	string 	`json:"name" 	sql:"not_null"`
        Age 	int 	`json:"age"`
        IsEmployed 	bool 	`json:"isEmployed"`
    }
  • Added support for directory operations in FileSystem
    Supported functionalities are:
    ChDir(dirname string) error - ChDir changes the current directory.
    Getwd() (string, error) - Getwd returns the path of the current directory.
    ReadDir(dir string) ([]FileInfo, error) - ReadDir returns a list of files/directories present in the directory.
    Stat(name string) (FileInfo, error) - Stat returns the file/directory information in the directory.

🛠 Enhancements

  • Error logs for invalid configs
    Added validations for REQUEST_TIMEOUT and REMOTE_LOG_FETCH_INTERVAL configs and log error if invalid.

  • Error logs for internal server errors
    Previously, if any occurred then there was a log with just status code and correlationID.
    Hence, added an error log with correlationID and error message.
    image

  • FileSystem mock methods for testing purpose
    To help test the FileSystem methods, mocks have now been added to mock container struct which can be generated from NewMockContainer method.

🐞 Fixes

  • Resolved application status in case of migration failure
    If any occurs while running the migrations, the application will now gracefully shutdown.

  • Resolved response for error case
    For an error case, where the response consists of error message only and has no data to return, then also the data field was present in output as null.
    This has been removed now, so only error struct will be returned with respective status code.

v1.17.0

12 Aug 09:23
f78d8c7
Compare
Choose a tag to compare

Release v1.17.0

✨ Features

  • Added support for FTP as an external datasource
    FTP can be added using the method on gofrApp AddFTP(fs file.FileSystemProvider)
    Supported functionalities are:
    Create(name string) (File, error)
    Mkdir(name string, perm os.FileMode) error
    MkdirAll(path string, perm os.FileMode) error
    Open(name string) (File, error)
    OpenFile(name string, flag int, perm os.FileMode) (File, error)
    Remove(name string) error
    RemoveAll(path string) error
    Rename(oldName, newName string) error

  • Cassandra now supports Batching
    Added Batch functionality with newly introduced methods:
    NewBatch(batchType int) error
    BatchQuery(stmt string, values ...interface{})
    ExecuteBatch() error

  • Automated injection of gofr.Context in the gRPC server during registering of the gRPC service
    gRPC can now inject gofr container to the Server struct, to access logger, datasources, and other functionalities provided by gofr.
    Refer to example for detailed info.

🛠 Enhancements

  • Messages can now be written to WebSocket without returning
    Added method on gofrContext WriteMessageToSocket(data any) error to write a message.

🐞 Fixes

  • Resolved panic for EnableBasicAuth
    If an odd no. of arguments (user, password) were passed to the EnableBasicAuth method, the app panicked. Fixed this issue, user and password can be passed in the method as comma-separated pairs like:
    EnableBasicAuth(user1, pass1, user2, pass2)

  • Resolved authentication for EnableBasicAuth
    Even if the credentials were correct, the app was returning the 401 status Unauthorised instead of the expected 200.

  • Fixed unstructured log in Mongo
    Debug query logs were not properly formatted for Mongo, fixed the formatting.
    The message field in logs was string type, updated it to object

v1.16.1

06 Aug 15:17
cb21d5b
Compare
Choose a tag to compare

Release v1.16.1

🐞 Fixes

  • Resolved DB migrations panic in logging
    App was panicking while logging with migrations datasource, as the logger was nil. Now, populated the logger, hence fixing the panic.
  • Removed unexpected error log for tracing when it was not enabled from configs
    {"level":"ERROR","time":"2024-08-06T17:47:56.714963+05:30","message":"unsupported TRACE_EXPORTER: ","gofrVersion":"v1.16.0"}
    The above log was printed when tracing configs (TRACE_EXPORTER, TRACER_URL) weren't provided, and since tracing is optional feature, removed error log if configs aren't given.

v1.16.0

05 Aug 07:01
a51f573
Compare
Choose a tag to compare

Release v1.16.0

✨ Features

  • Application will now gracefully shutdown to prevent data loss during application termination
    All the processes (go-routines) will be awaited to finish before shutting down. Currently, the timeout for shutdown is 30 seconds. Will be making it configurable in upcoming release.

  • Enhanced query parameter handling to support multiple values
    Previously, only a single value was supported for query params with Param(key string) string method. Now, added another method Params(key string) []string which returns array of values passed for given query param.
    Example:

    If URL is 
     - http://order-service/orders?id=123,234
     - http://order-service/orders?id=123&id=234
     
    Then ctx.Params("id") will return ["123", "234"]
    
  • Enhanced security with SSL support for PostgreSQL connections
    Default certificates can now be used as SSL, by configuring DB_SSL_MODE as require.
    Currently this is only supported with PostgreSQL. Custom certificates and other DBs will be supported in future releases.

🛠 Enhancements

  • Improved logging for tracer configs validation
    Tracing is only enabled when both TRACE_EXPORTER and TRACER_URL are provided, so added error logs if any one of them is provided and the other is missing.

    Screenshot 2024-08-05 at 12 24 53 PM Screenshot 2024-08-05 at 12 27 58 PM
  • Improved tracing with OpenTelemetry protocol integration
    Tracing can now be configured as otel protocol by configuring TRACE_EXPORTER as otlp, and providing TRACER_URL.

🐞 Fixes

  • Resolved panic caused by passing non-pointer objects in AddRESTHandlers method
    App was panicking while initialising if the argument is passed by value to AddRESTHandlers method. Since, the method only accepts arguments passed by reference, added validations and error log instead of panic.