Skip to content

Commit 0940a65

Browse files
Refactor Docs (#334)
--------- Co-authored-by: umang01-hash <[email protected]>
1 parent 670ec10 commit 0940a65

File tree

11 files changed

+74
-48
lines changed

11 files changed

+74
-48
lines changed

docs/advanced-guide/custom-spans-in-tracing/page.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ By adding custom spans in traces to your requests, you can:
1313
- **Improve debugging:** Custom spans enhance your ability to debug issues by providing visibility into the execution
1414
flow of your application.
1515

16-
## Adding Custom Spans:
16+
## Usage
1717

1818
To add a custom trace to a request, you can use the `Trace()` method of GoFr context, which takes the name of the span as an argument
1919
and returns a trace.Span.
2020

21-
### Usage
22-
2321
```go
2422
func MyHandler(c context.Context) error {
2523
span := c.Trace("my-custom-span")

docs/advanced-guide/interservice-http-call/page.md renamed to docs/advanced-guide/http-communication/page.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Interservice HTTP Calls
2-
GoFr promotes microservice architechure and to facilitate the same, it provides the support
2+
GoFr promotes microservice architecture and to facilitate the same, it provides the support
33
to initialize HTTP services at application level using `AddHTTPService()` method.
44
Support for inter-service http calls provide the following benefits:
55

66
1. Access to the method from container - GET, PUT, POST, PATCH, DELETE.
77
2. Logs and traces for the request.
8-
3. Circuit breaking for enhanced resilience and fault tolerance.
9-
4. Custom Health Check Endpoints
8+
3. [Circuit breaking](/docs/advanced-guide/circuit-breaker) for enhanced resilience and fault tolerance.
9+
4. [Custom Health Check](/docs/advanced-guide/monitoring-service-health) Endpoints
1010

1111
## Usage
1212

docs/advanced-guide/monitoring-service-health/page.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Monitoring Service Health
2+
Health check in microservices refers to a mechanism or process implemented within each service to assess its operational status and readiness to handle requests. It involves regularly querying the service to determine if it is functioning correctly, typically by evaluating its responsiveness and ability to perform essential tasks. Health checks play a critical role in ensuring service availability, detecting failures, preventing cascading issues, and facilitating effective traffic routing in distributed systems.
23

3-
As there can be multiple service, they need to be checked if they are UP or not.
4-
GoFr registers two endpoints by default which are :
4+
## GoFr by default registers two endpoints which are :
55

6-
1. Aliveness - /.well-known/alive
6+
### 1. Aliveness - /.well-known/alive
77

88
It is an endpoint which return the following response when the service is UP with a 200 response code.
99
```json
@@ -24,7 +24,7 @@ To override the endpoint when registering HTTP Service pass the following option
2424
}
2525
```
2626

27-
2. Health-Check - /.well-known/health-check
27+
### 2. Health-Check - /.well-known/health-check
2828

2929
It returns if the service is UP or DOWN along with stats, host, status about the dependent datasources and services.
3030

docs/advanced-guide/publishing-custom-metrics/page.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Publishing Custom Metrics
22

33
For GoFr default metrics refer: [observability](/docs/quick-start/observability).
4-
If there is a requirement of a metric other than the GoFr defaults, you can create them using custom metrics as shown below.
54

6-
GoFr supports the following [metric](https://opentelemetry.io/docs/specs/otel/metrics/) types in prometheus format:
5+
GoFr can handle multiple different metrics concurrently, each uniquely identified by its name during initialization.
6+
It supports the following [metrics](https://opentelemetry.io/docs/specs/otel/metrics/) types in prometheus format:
77

88
1. Counter
99
2. UpDownCounter
1010
3. Histogram
1111
4. Gauge
1212

13-
GoFr is capable of handling multiple Counter, UpDownCounter, Histogram, and Gauge metrics concurrently, each uniquely identified by its name during initialization.
13+
If any metric other than defaults provided, you can create them using custom metrics as shown below.
14+
1415

1516
## Usage
1617

@@ -136,3 +137,18 @@ func main() {
136137
app.Run()
137138
}
138139
```
140+
141+
**Good To Know**
142+
```doc
143+
While registering a metrics two key pieces of information of required
144+
- Name
145+
- Description
146+
147+
When a registered Metrics has to be used 3 key pieces of information are required:
148+
- Metrics name
149+
- Value
150+
- A set of key-value pairs called tags or labels.
151+
152+
A permutation of these key-value values provides the metric cardinality.
153+
Lower the cardinality, faster the query performance and lower the monitoring resource utilisation.
154+
```

docs/advanced-guide/remote-log-level-change/page.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Remote Log Level Change
2-
Gofr makes it easy to adjust the detail captured in your application's logs, even while it's running! This feature empowers
3-
users to effortlessly fine-tune logging levels without the need for redeployment, enhancing the monitoring and debugging experience.
4-
This feature is facilitated through simple configuration settings.
2+
Gofr makes it easy to adjust the detail captured in your application's logs, even while it's running!
53

6-
## Why it is important?
7-
- **Effortless Adjustments:** Modify the level of detail in your logs anytime without restarting your application.
8-
This is especially helpful during troubleshooting or when log volume needs to be adjusted based on the situation.
9-
- **Enhanced Visibility:** Easily switch to a more detailed log level (e.g., `DEBUG`) to gain deeper insights into specific issues,
10-
and then switch back to a less detailed level (e.g., `INFO`) for regular operation.
4+
This feature allows users to effortlessly fine-tune logging levels without the need for redeployment, enhancing the monitoring and debugging experience.
5+
It is facilitated through simple configuration settings.
6+
7+
## How it helps?
8+
- **Effortless Adjustments:** Modify the level of detail in your logs anytime without restarting your application.
9+
This is especially helpful during troubleshooting.
10+
- **Enhanced Visibility:** Easily switch to a more detailed log level (e.g., `DEBUG`) to gain deeper insights into specific issues,
11+
and then switch back to a less detailed level (e.g., `INFO`) for regular operation.
12+
- **Improved Performance:** Generating a large number of logs can overwhelm the logging system, leading to increased I/O operations and resource consumption,
13+
changing to Warn or Error Level reduces the number of logs, and enhancing performance.
1114

1215
## Configuration
13-
To enable remote log level updating, users need to specify the following configuration parameter:
16+
To enable remote log level update, users need to specify the following configuration parameter:
1417

1518
```dotenv
1619
REMOTE_LOG_URL=<URL to your remote log level endpoint> (e.g., https://your-service.com/log-levels)
@@ -40,7 +43,7 @@ The remote log level endpoint should return a JSON response in the following for
4043
- **logLevel:** The new log level you want to set for the specified service.
4144

4245

43-
GoFr parses this response and dynamically adjusts log levels according to the provided configurations.
46+
GoFr parses this response and adjusts log levels based on the provided configurations.
4447

4548

4649

docs/navigation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ export const navigation = [
1212
{
1313
title: 'Advanced Guide',
1414
links: [
15-
{ title: 'Inter-service HTTP Calls', href: '/docs/advanced-guide/interservice-http-call' },
1615
{ title: 'Publishing Custom Metrics', href: '/docs/advanced-guide/publishing-custom-metrics' },
1716
{ title: 'Remote Log Level Change', href: '/docs/advanced-guide/remote-log-level-change' },
1817
{ title: 'Handling Data Migrations', href: '/docs/advanced-guide/handling-data-migrations' },
19-
// { title: 'Dealing with Remote Files', href: '/docs/advanced-guide/remote-files' },
20-
{ title: 'Monitoring Service Health', href: '/docs/advanced-guide/monitoring-service-health' },
21-
// { title: 'Supporting OAuth', href: '/docs/advanced-guide/oauth' },
18+
{ title: 'HTTP Communication', href: '/docs/advanced-guide/http-communication' },
2219
{ title: 'Circuit Breaker Support', href: '/docs/advanced-guide/circuit-breaker' },
20+
{ title: 'Monitoring Service Health', href: '/docs/advanced-guide/monitoring-service-health' },
2321
{ title: 'Custom Spans in Tracning', href: '/docs/advanced-guide/custom-spans-in-tracing' },
22+
// { title: 'Dealing with Remote Files', href: '/docs/advanced-guide/remote-files' },
23+
// { title: 'Supporting OAuth', href: '/docs/advanced-guide/oauth' },
2424
// { title: 'Writing gRPC Server', href: '/docs/advanced-guide/grpc' },
2525
// { title: 'Creating a Static File Server', href: '/docs/advanced-guide/static-file-server' },
2626
// { title: 'WebSockets', href: '/docs/advanced-guide/websockets' },

docs/quick-start/configuration/page.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GoFr reads configuration via environment variables. It provides an easy way to m
44

55
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.
66

7-
To set configs create a `configs` folder in the project's root and add `.env` file.
7+
To set configs create a `configs` directory in the project's root and add `.env` file.
88

99
By default, GoFr starts HTTP server at port 8000, in order to change that we can add the config `HTTP_PORT`
1010
Similarly to Set the app-name you can add `APP_NAME`. For example:

docs/quick-start/connecting-mysql/page.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Connecting MySQL
22

3-
Just like any other datasource gofr also supports connection to MySQL database based on configuration variables.
3+
Just like Redis gofr also supports connection to SQL(mysql and postgres) databases based on configuration variables.
44

55
## Setup
66

@@ -16,7 +16,7 @@ Access `test_db` database and create table customer with columns `id` and `name`
1616
docker exec -it gofr-mysql mysql -uroot -proot123 test_db -e "CREATE TABLE customers (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL);"
1717
```
1818

19-
Now the database with table is ready, we can connect our server to MySQL
19+
Now the database with table is ready, we can connect our GoFr server to MySQL
2020

2121
## Configuration & Usage
2222

docs/quick-start/connecting-redis/page.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To set a sample key, run the following command:
1515
docker exec -it gofr-redis bash -c 'redis-cli SET greeting "Hello from Redis."'
1616
```
1717

18-
## Using Redis in GoFr
18+
## Configuration & Usage
1919

2020
GoFr requires certain configurations to connect to Redis. The necessary configurations include
2121
`REDIS_HOST`and `REDIS_PORT`. Update the `.env` file in the configs directory with the following content:
@@ -28,7 +28,7 @@ REDIS_HOST=localhost
2828
REDIS_PORT=6379
2929
```
3030

31-
Once the Redis configurations are set, you can utilize Redis in your GoFr application.
31+
Once the Redis configurations are set, you can use Redis in your GoFr application.
3232
Below is an example of how to retrieve data from Redis in the `main.go` file:
3333

3434
```golang

docs/quick-start/introduction/page.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Prerequisite
22

3-
- Install or update [Go](https://go.dev/dl/).
3+
- Go 1.19 or above.
4+
To check the version use the following command `go version`.
45

5-
To check the version use the following command `go version`.
6-
7-
- Prior familiarity with Golang syntax is essential. [Golang Tour](https://tour.golang.org/) is highly recommended as it has an excellent guided tour.
6+
- Prior familiarity with Golang syntax is essential. [Golang Tour](https://tour.golang.org/) is highly recommended as it has an excellent guided tour.
87

98
## Write your first GoFr API
109

@@ -45,7 +44,7 @@ func main() {
4544
}
4645
```
4746

48-
Before running the server run the following command to go needs to download and sync the required modules.
47+
Before running the server run the following go command to download and sync the required modules.
4948

5049
`go mod tidy`
5150

@@ -69,20 +68,22 @@ The `hello-world` server involves three essential steps:
6968

7069
_This single line is a standard part of all gofr-based servers._
7170

71+
7272
2. **Attaching a Handler to a Path:**
7373

7474
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 /hello_ maps to HandlerFunction. Likewise, `app.POST("/todo", ToDoCreationHandler)` links a _POST_ request to the /todo endpoint with _ToDoCreationHandler_.
7575

76+
7677
**Good To Know**
7778

78-
In Go, functions are first-class citizens, allowing easy handler definition and reference.
79-
Handler functions should follow the `func(ctx *gofr.Context) (interface{}, error)` signature.
80-
They take a context as input, returning two values: the response data and an error (set to `nil` on success).
79+
> In Go, functions are first-class citizens, allowing easy handler definition and reference.
80+
HTTP Handler functions should follow the `func(ctx *gofr.Context) (interface{}, error)` signature.
81+
They take a context as input, returning two values: the response data and an error (set to `nil` when there is no error).
8182

8283
In GoFr `ctx *gofr.Context` serves as a wrapper for requests, responses, and dependencies, providing various functionalities.
8384

84-
For more details about context, refer [here](/docs/v1/references/context).
85+
For more details about context, refer [here](/docs/references/context).
8586

8687
3. **Starting the server**
8788

88-
When `app.Run()` is called, it configures ,initiates and runs the HTTP server, middlewares based on provided configs. It manages essential features such as routes for health checks, swagger UI etc. It starts the server on the default port 8000.
89+
When `app.Run()` is called, it configures ,initiates and runs the HTTP server, middlewares. It manages essential features such as routes for health check endpoints, metrics server, favicon etc. It starts the server on the default port 8000.

0 commit comments

Comments
 (0)