Skip to content

Commit

Permalink
Merge pull request #861 from gofr-dev/release/v1.15.0
Browse files Browse the repository at this point in the history
Release v1.15.0
  • Loading branch information
srijan-27 authored Jul 22, 2024
2 parents 3637485 + d4e66b3 commit e76a4ac
Show file tree
Hide file tree
Showing 31 changed files with 1,847 additions and 129 deletions.
Binary file added .github/banner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 74 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# GoFr
<p align="center">
<img align="center" width="300" alt="logo" src="https://github.com/gofr-dev/gofr/assets/44036979/916fe7b1-42fb-4af1-9e0b-4a7a064c243c">
</p>
<p align="center"><b>
GoFr is an opinionated microservice development framework.</b></p>

<div align=center>
<a href="https://pkg.go.dev/gofr.dev"><img src="https://img.shields.io/badge/%F0%9F%93%9A%20godoc-pkg-00ACD7.svg?color=00ACD7&style=flat-square"></a>
Expand All @@ -13,30 +14,88 @@
<a href="https://discord.gg/wsaSkQTdgq"><img src="https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat" /></a>
</div>


<br>

GoFr is an opinionated microservice development framework. Listed in [CNCF Landscape](https://landscape.cncf.io/?selected=go-fr).

Visit <a href="https://gofr.dev"/>https://gofr.dev</a> for more details and documentation.
Listed in [CNCF Landscape](https://landscape.cncf.io/?selected=go-fr).

## 🎯 Goal
Even though generic applications can be written using GoFr, our main focus is to simplify the development of microservices.
We will focus ourselves towards deployment in Kubernetes and aspire to provide out-of-the-box observability.
We will focus on deployment in Kubernetes and aspire to provide out-of-the-box observability.

## 💡 Advantages/Features
## 💡 Key Features

1. Simple API syntax
2. REST Standards by default
3. Configuration management
4. Inbuilt Middlewares
5. [gRPC support](https://gofr.dev/docs/advanced-guide/grpc)
6. [HTTP service](https://gofr.dev/docs/advanced-guide/http-communication) with support for [Circuit Breaker](https://gofr.dev/docs/advanced-guide/circuit-breaker) and
[Health Check](https://gofr.dev/docs/advanced-guide/monitoring-service-health)
4. [Observability](https://gofr.dev/docs/quick-start/observability) (Logs, Traces, Metrics)
5. Inbuilt [Auth Middleware](https://gofr.dev/docs/advanced-guide/http-authentication) & Support for [Custom Middleware](https://gofr.dev/docs/advanced-guide/middlewares)
6. [gRPC support](https://gofr.dev/docs/advanced-guide/grpc)
7. [HTTP service](https://gofr.dev/docs/advanced-guide/http-communication) with support for [Circuit Breaker](https://gofr.dev/docs/advanced-guide/circuit-breaker)
8. [Pub/Sub](https://gofr.dev/docs/advanced-guide/using-publisher-subscriber)
9. [Health Check](https://gofr.dev/docs/advanced-guide/monitoring-service-health) by default for all datasources.
10. [Database Migration](https://gofr.dev/docs/advanced-guide/handling-data-migrations)
11. [Cron Jobs](https://gofr.dev/docs/advanced-guide/using-cron)
12. Support for [changing Log Level](https://gofr.dev/docs/advanced-guide/remote-log-level-change) without restarting the application.
13. [Swagger Rendering](https://gofr.dev/docs/advanced-guide/swagger-documentation)
14. [Abstracted File Systems](https://gofr.dev/docs/advanced-guide/handling-file)
15. [Websockets](https://gofr.dev/docs/advanced-guide/handling-file)

![banner.gif](.github/banner.gif)

## Getting started
### Prerequisites
GoFr requires [Go](https://go.dev/) version [1.21](https://go.dev/doc/devel/release#go1.21.0) or above.

### Getting GoFr
With [Go's module support](https://go.dev/wiki/Modules#how-to-use-modules), `go [build|run|test]` automatically fetches the necessary dependencies when you add the import in your code:

```sh
import "github.com/gofr-dev/gofr"
```

Alternatively, use `go get`:

```sh
go get -u github.com/gofr-dev/gofr
```
### Running GoFr
A basic example:
```go
package main

import "gofr.dev/pkg/gofr"

func main() {
app := gofr.New()

app.GET("/greet", func(ctx *gofr.Context) (interface{}, error) {

return "Hello World!", nil
})

app.Run() // listen and serve on localhost:8080
}
```

To run the code, use the `go run` command, like:

```sh
$ go run main.go
```

Then visit [`localhost:8080/greet`](http://localhost:8080/greet) in your browser to see the response!

### See more examples
A number of ready-to-run examples demonstrating various use cases of GoFr are available in the [GoFr examples](https://github.com/gofr-dev/gofr/tree/development/examples) directory.

## 👩‍💻Documentation
See the [godocs](https://pkg.go.dev/gofr.dev).

The documentation is also available on [gofr.dev](https://gofr.dev/docs).

## 👍 Contribute
If you want to say thank you and/or support the active development of GoFr:

1. Add a [GitHub Star](https://github.com/gofr-dev/gofr/stargazers) to the project.
1. [Star](https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars) the repo.
2. Write a review or tutorial on [Medium](https://medium.com/), [Dev.to](https://dev.to/) or personal blog.
3. Visit [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow. After your PR is merged to the repo, fill the [Google Form](https://forms.gle/R1Yz7ZzY3U5WWTgy5), and we will send you a GoFr T-Shirt and Stickers as a token of appreciation.
3. Visit [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.

If your PR is merged or you have written an article or contributed in someway to development or spreading the word about GoFr, fill the [Google Form](https://forms.gle/R1Yz7ZzY3U5WWTgy5), and we will send you a <b>GoFr T-Shirt and Stickers</b> as a token of appreciation.
80 changes: 80 additions & 0 deletions docs/advanced-guide/key-value-store/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Key Value Store

A key-value store is a type of NoSQL database that uses a simple data model: each item is stored as a pair consisting of a unique key and a value.
This simplicity offers high performance and scalability, making key-value stores ideal for applications requiring fast and efficient data retrieval and storage.

GoFr supports BadgerDB as a key value store. Support for other key-value store will be added in the future.

Keeping in mind the size of the application in the final build, it felt counter-productive to keep the drivers within
the framework itself. GoFr provide the following functionalities for its key-value store.

```go
type KVStore interface {
Get(ctx context.Context, key string) (string, error)
Set(ctx context.Context, key, value string) error
Delete(ctx context.Context, key string) error
}
```

## BadgerDB
GoFr supports injecting BadgerDB that supports the following interface. Any driver that implements the interface can be added
using `app.AddKVStore()` method, and user's can use BadgerDB across application with `gofr.Context`.

User's can easily inject a driver that supports this interface, this provides usability without
compromising the extensibility to use multiple databases.
### Example
```go
package main

import (
"fmt"

"gofr.dev/pkg/gofr"
"gofr.dev/pkg/gofr/datasource/kv-store/badger"
)

type User struct {
ID string
Name string
Age string
}

func main() {
app := gofr.New()

app.AddKVStore(badger.New(badger.Configs{DirPath: "badger-example"}))

app.POST("/user", Post)
app.GET("/user", Get)
app.DELETE("/user", Delete)

app.Run()
}

func Post(ctx *gofr.Context) (interface{}, error) {
err := ctx.KVStore.Set(ctx, "name", "gofr")
if err != nil {
return nil, err
}

return "Insertion to Key Value Store Successful", nil
}

func Get(ctx *gofr.Context) (interface{}, error) {
value, err := ctx.KVStore.Get(ctx, "name")
if err != nil {
return nil, err
}

return value, nil
}

func Delete(ctx *gofr.Context) (interface{}, error) {
err := ctx.KVStore.Delete(ctx, "name")
if err != nil {
return nil, err
}

return fmt.Sprintf("Deleted Successfully key %v from Key-Value Store", "name"), nil
}
```
1 change: 1 addition & 0 deletions docs/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const navigation = [
{ title: 'Writing gRPC Server', href: '/docs/advanced-guide/grpc' },
{ title: 'Using Pub/Sub', href: '/docs/advanced-guide/using-publisher-subscriber' },
{ title: 'Injecting Databases', href: '/docs/advanced-guide/injecting-databases-drivers' },
{ title: 'Key Value Store', href: '/docs/advanced-guide/key-value-store' },
{ title: 'Dealing with SQL', href: '/docs/advanced-guide/dealing-with-sql' },
{ title: 'Automatic SwaggerUI Rendering', href: '/docs/advanced-guide/swagger-documentation' },
{ title: 'Error Handling',href: '/docs/advanced-guide/gofr-errors'},
Expand Down
6 changes: 2 additions & 4 deletions docs/quick-start/observability/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ DB_PORT=3306
# tracing configs
TRACE_EXPORTER=zipkin
TRACER_HOST=localhost
TRACER_PORT=2005
TRACER_URL=http://localhost:2005/api/v2/spans
LOG_LEVEL=DEBUG
```
Expand Down Expand Up @@ -220,8 +219,7 @@ Add Jaeger Tracer configs in `.env` file, your .env will be updated to
# tracing configs
TRACE_EXPORTER=jaeger
TRACER_HOST=localhost
TRACER_PORT=14317
TRACER_URL=localhost:14317
```

Open {% new-tab-link title="zipkin" href="http://localhost:16686/trace/" /%} and search by TraceID (correlationID) to see the trace.
Expand Down
3 changes: 1 addition & 2 deletions examples/using-add-rest-handlers/configs/.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ DB_PORT=2001
DB_DIALECT=mysql

TRACE_EXPORTER=zipkin
TRACER_HOST=localhost
TRACER_PORT=2005
TRACER_URL=http://localhost:2005/api/v2/spans
3 changes: 1 addition & 2 deletions examples/using-migrations/configs/.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ PUBSUB_BROKER=localhost:9092
CONSUMER_ID=test

TRACE_EXPORTER=zipkin
TRACER_HOST=localhost
TRACER_PORT=2005
TRACER_URL=http://localhost:2005/api/v2/spans
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
github.com/redis/go-redis/extra/redisotel/v9 v9.0.5
github.com/redis/go-redis/v9 v9.5.1
github.com/redis/go-redis/v9 v9.5.4
github.com/segmentio/kafka-go v0.4.47
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.53.0
Expand All @@ -38,18 +38,18 @@ require (
golang.org/x/oauth2 v0.21.0
golang.org/x/term v0.22.0
golang.org/x/text v0.16.0
google.golang.org/api v0.187.0
google.golang.org/api v0.188.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
modernc.org/sqlite v1.30.1
modernc.org/sqlite v1.30.2
)

require (
cloud.google.com/go v0.115.0 // indirect
cloud.google.com/go/auth v0.6.1 // indirect
cloud.google.com/go/auth v0.7.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.8 // indirect
cloud.google.com/go/compute/metadata v0.4.0 // indirect
cloud.google.com/go/iam v1.1.10 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -88,14 +88,14 @@ require (
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.2.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.52.1 // indirect
Expand Down
Loading

0 comments on commit e76a4ac

Please sign in to comment.