You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced-guide/circuit-breaker/page.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Circuit Breaker in HTTP Communication
2
2
3
-
Calls to remote resources and services can fail due to temporary issues like slow network connections or timeouts, as well as longer-lasting problems such as service unavailability. While transient faults can be mitigated using the "Retry pattern," there are cases where continual retries are futile, such as during severe service failures.
3
+
Calls to remote resources and services can fail due to temporary issues like slow network connections or timeouts, service unavailability. While transient faults can be mitigated using the "Retry pattern", there are cases where continual retries are futile, such as during severe service failures.
4
4
5
5
In such scenarios, it's crucial for applications to recognize when an operation is unlikely to succeed and handle the failure appropriately rather than persistently retrying. Indiscriminate use of HTTP retries can even lead to unintentional denial-of-service attacks within the software itself, as multiple clients may flood a failing service with retry attempts.
Copy file name to clipboardExpand all lines: docs/advanced-guide/grpc/page.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# gRPC
2
2
We have already seen how GoFr can help ease the development of HTTP servers, but there are
3
3
cases where performance is primiraliy required sacrificing flexibility. In these types of
4
-
scenarios gRPC protocol comes into picture. gRPC is an open-source RPC(Remote Procedure Call)
5
-
framework initially developed by Google. {% new-tab-link title="Learn more" href="https://grpc.io/docs/what-is-grpc/introduction/" /%}
4
+
scenarios gRPC protocol comes into picture. {% new-tab-link title="gRPC" href="https://grpc.io/docs/what-is-grpc/introduction/" /%} is an open-source RPC(Remote Procedure Call)
5
+
framework initially developed by Google.
6
6
7
7
## Prerequisites
8
8
- Install the `protoc` protocol buffer compilation
@@ -30,7 +30,7 @@ framework initially developed by Google. {% new-tab-link title="Learn more" href
30
30
## Creating protocol buffers
31
31
For a detailed guide, please take a look at the {% new-tab-link title="Tutorial" href="https://grpc.io/docs/languages/go/basics/" /%} at official gRPC docs.
32
32
33
-
Fistly, we need to create a `customer.proto` file to define our service and the rpc methods that the service provides.
33
+
We need to create a `customer.proto` file to define our service and the rpc methods that the service provides.
34
34
```protobuf
35
35
// Indicates the protocol buffer version that is being used
36
36
syntax = "proto3";
@@ -67,7 +67,7 @@ message CustomerData {
67
67
}
68
68
```
69
69
70
-
Now run the following command to gegnerate go code using the Go gRPC plugins:
70
+
Now run the following command to generate go code using the Go gRPC plugins:
Migrations will run in ascending order of keys in this map.
70
+
Migrations run in ascending order of keys in this map.
71
71
72
72
### Initialisation from main.go
73
73
@@ -99,7 +99,6 @@ INFO [16:55:46] Migration 20240226153000 ran successfully
99
99
```
100
100
101
101
GoFr maintains the records in the database itself which helps in tracking which migrations have already been executed and ensures that only migrations that have never been run are executed.
102
-
This way, you only need to ensure that your migrations are properly in place. {% new-tab-link title="Learn more" href="https://cloud.google.com/architecture/database-migration-concepts-principles-part-1" /%}
Copy file name to clipboardExpand all lines: docs/advanced-guide/remote-log-level-change/page.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,13 @@
1
1
# Remote Log Level Change
2
2
3
-
Gofr makes it easy to adjust the detail captured in your application's logs, even while it's running!
3
+
Gofr makes it easy to adjust the details captured in the application's logs, even while it's running!
4
4
5
5
This feature allows users to effortlessly fine-tune logging levels without the need for redeployment, enhancing the monitoring and debugging experience.
6
6
It is facilitated through simple configuration settings.
7
7
8
8
## How it helps?
9
9
10
-
-**Effortless Adjustments:** Modify the level of detail in your logs anytime without restarting your application.
11
-
This is especially helpful during troubleshooting.
10
+
-**Effortless Adjustments:** Modify the log level anytime without restarting the application. This is especially helpful during troubleshooting.
12
11
-**Enhanced Visibility:** Easily switch to a more detailed log level (e.g., `DEBUG`) to gain deeper insights into specific issues,
13
12
and then switch back to a less detailed level (e.g., `INFO`) for regular operation.
14
13
-**Improved Performance:** Generating a large number of logs can overwhelm the logging system, leading to increased I/O operations and resource consumption,
@@ -19,7 +18,7 @@ It is facilitated through simple configuration settings.
19
18
To enable remote log level update, users need to specify the following configuration parameter:
20
19
21
20
```bash
22
-
REMOTE_LOG_URL=<URL to your remote log level endpoint> (e.g., https://your-service.com/log-levels)
21
+
REMOTE_LOG_URL=<URL to user's remote log level endpoint> (e.g., https://log-service.com/log-levels)
23
22
REMOTE_LOG_FETCH_INTERVAL=<Interval in seconds> (default: 15)
24
23
```
25
24
@@ -44,6 +43,6 @@ The remote log level endpoint should return a JSON response in the following for
44
43
```
45
44
46
45
- **serviceName:** Identifies the service for which log levels are configured.
47
-
-**logLevel:** The new log level you want to set for the specified service.
46
+
- **logLevel:** The new log level user want to set for the specified service.
48
47
49
48
GoFr parses this response and adjusts log levels based on the provided configurations.
Copy file name to clipboardExpand all lines: docs/quick-start/configuration/page.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,23 @@
1
1
# Configurations
2
2
3
-
GoFr reads configuration via environment variables. It provides an easy way to manage this. Application code is decoupled from how configuration is managed as per the {% new-tab-link title="12-factor" href="https://12factor.net/config" /%}.
4
-
Configs in GoFr can be used to initialise datasources, tracing. In doing so it abstract the logic and gives an easy interface to setup different things.
3
+
GoFr simplifies configuration management by reading configuration via environment variables.
4
+
Application code is decoupled from how configuration is managed as per the {%new-tab-link title="12-factor" href="https://12factor.net/config" %}.
5
+
Configs in GoFr can be used to initialise datasources, tracing , setting log levels, changing default http or metrics port.
6
+
This abstraction provides a user-friendly interface for configuring your application without modifying the code itself.
5
7
6
8
To set configs create a `configs` directory in the project's root and add `.env` file.
7
9
10
+
Follow this directory structure within your GoFr project:
11
+
```dotenv
12
+
my-gofr-app/
13
+
├── config/
14
+
│ ├── dev.env
15
+
│ ├── staging.env
16
+
│ └── prod.env
17
+
├── main.go
18
+
└── ...
19
+
```
20
+
8
21
By default, GoFr starts HTTP server at port 8000, in order to change that we can add the config `HTTP_PORT`
9
22
Similarly to Set the app-name you can add `APP_NAME`. For example:
Copy file name to clipboardExpand all lines: docs/quick-start/introduction/page.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,26 @@
1
1
# Prerequisite
2
2
3
3
- Go 1.20 or above.
4
-
To check the version use the following command `go version`.
4
+
To check Go version use the following command `go version`.
5
5
6
6
- Prior familiarity with Golang syntax is essential. {% new-tab-link title="Golang Tour" href="https://tour.golang.org/" /%} is highly recommended as it has an excellent guided tour.
7
7
8
8
## Write your first GoFr API
9
9
10
-
Let's start by initializing the go module by using the following command.
10
+
Let's start by initializing the {% new-tab-link title="go module" href="https://go.dev/ref/mod" /%} by using the following command.
11
11
12
12
```bash
13
13
go mod init github.com/example
14
14
```
15
15
16
-
To know more about go modules refer {% new-tab-link title="here" href="https://go.dev/ref/mod" /%}.
17
-
18
-
Add {% new-tab-link title="gofr" href="https://github.com/gofr-dev/gofr" /%} package to the project using the following command
16
+
Add {% new-tab-link title="gofr" href="https://github.com/gofr-dev/gofr" /%} package to the project using the following command.
19
17
20
18
```bash
21
19
go get gofr.dev
22
20
```
23
21
24
-
Now add the following code to _main.go_ file
22
+
This code snippet showcases the creation of a simple GoFr application that defines a route and serves a response.
23
+
You can add this code to your main.go file.
25
24
26
25
```go
27
26
package main
@@ -44,15 +43,15 @@ func main() {
44
43
}
45
44
```
46
45
47
-
Before running the server run the following go command to download and sync the required modules.
46
+
Before starting the server, run the following command in your terminal to ensure you have downloaded and synchronized all required dependencies for your project.
48
47
49
48
`go mod tidy`
50
49
51
-
To run the server, use the command
50
+
Once the dependencies are synchronized, start the GoFr server using the following command:
52
51
53
52
`go run main.go`
54
53
55
-
This would start the server at 8000 port, you can access {% new-tab-link title="http://localhost:8000/greet" href="http://localhost:8000/greet" /%} from your browser, you would be able to see the output as following with _Status Code 200_ as per REST Standard
54
+
This would start the server at 8000 port, `/greet` endpoint can be accessed from your browser at {% new-tab-link title="http://localhost:8000/greet" href="http://localhost:8000/greet" /%} , you would be able to see the output as following with _Status Code 200_ as per REST Standard.
56
55
57
56
```json
58
57
{ "data": "Hello World!" }
@@ -66,11 +65,11 @@ The `hello-world` server involves three essential steps:
66
65
67
66
When `gofr.New()` is called, it initializes the framework and handles various setup tasks like initialising logger, metrics, datasources etc based on the configs.
68
67
69
-
_This single line is a standard part of all gofr-based servers._
68
+
_This single line is a standard part of all gofr servers._
70
69
71
70
2.**Attaching a Handler to a Path:**
72
71
73
-
In this step, we instruct the server to associate an HTTP request with a specific handler function. This is achieved through `app.GET("/greet", HandlerFunction)`, where _GET /greet_ maps to HandlerFunction. Likewise, `app.POST("/todo", ToDoCreationHandler)` links a _POST_ request to the /todo endpoint with _ToDoCreationHandler_.
72
+
In this step, the server is instructed to associate an HTTP request with a specific handler function. This is achieved through `app.GET("/greet", HandlerFunction)`, where _GET /greet_ maps to HandlerFunction. Likewise, `app.POST("/todo", ToDoCreationHandler)` links a _POST_ request to the /todo endpoint with _ToDoCreationHandler_.
0 commit comments