Skip to content

Commit 2c7fe0a

Browse files
author
Raramuri
committed
updated the docs
1 parent 3b2ef76 commit 2c7fe0a

File tree

10 files changed

+293
-242
lines changed

10 files changed

+293
-242
lines changed

docs/advanced-guide/circuit-breaker/page.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import (
2323
func main() {
2424
// Create a new application
2525
app := gofr.New()
26-
26+
2727
app.AddHTTPService("order", "https://order-func",
2828
&service.CircuitBreakerConfig{
2929
// Number of consecutive failed requests after which circuit breaker will be enabled
3030
Threshold: 4,
31-
// Time interval at which circuit breaker will hit the aliveness endpoint.
31+
// Time interval at which circuit breaker will hit the aliveness endpoint.
3232
Interval: 1 * time.Second,
3333
},
3434
)
@@ -41,6 +41,6 @@ func main() {
4141
```
4242

4343
Circuit breaker state changes to open when number of consecutive failed requests increases the threshold.
44-
When it is in open state, GoFr makes request to the aliveness endpoint (default being - /.well-known/alive) at an equal interval of time provided in config.
44+
When it is in open state, GoFr makes request to the aliveness endpoint (default being - /.well-known/alive) at an equal interval of time provided in config.
4545

46-
To override the default aliveness endpoint {% new-tab-link title="refer" href="/docs/advanced-guide/monitoring-service-health" /%}.
46+
To override the default aliveness endpoint {% new-tab-link newtab=false title="refer" href="/docs/advanced-guide/monitoring-service-health" /%}.

docs/advanced-guide/handling-data-migrations/page.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Handling Data Migrations
22

33
Suppose you manually make changes to your database, and now it's your responsibility to inform other developers to execute them. Additionally, you need to keep track of which changes should be applied to production machines in the next deployment.
4-
Gofr supports data migrations for MySQL, Postgres and Redis which allows to alter the state of a database, be it adding a new column to existing table or modifying the data type of existing column or adding constraints to an existing table, setting and removing keys etc.
4+
Gofr supports data migrations for MySQL, Postgres and Redis which allows to alter the state of a database, be it adding a new column to existing table or modifying the data type of existing column or adding constraints to an existing table, setting and removing keys etc.
55

66
## Usage
77

@@ -11,12 +11,13 @@ It is recommended to maintain a migrations directory in your project root to enh
1111

1212
**Migration file names**
1313

14-
It is recommended that each migration file should be numbered in the format of *YYYYMMDDHHMMSS* when the migration was created.
14+
It is recommended that each migration file should be numbered in the format of _YYYYMMDDHHMMSS_ when the migration was created.
1515
This helps prevent numbering conflicts and allows for maintaining the correct sort order by name in different filesystem views.
1616

1717
Create the following file in migrations directory.
1818

1919
**Filename : 20240226153000_create_employee_table.go**
20+
2021
```go
2122
package migrations
2223

@@ -45,14 +46,15 @@ func createTableEmployee() migration.Migrate {
4546
}
4647
```
4748

48-
`migration.Datasource` have the datasources whose migrations are supported i.e. Redis and SQL (MySQL and PostgreSQL).
49+
`migration.Datasource` have the datasources whose migrations are supported i.e. Redis and SQL (MySQL and PostgreSQL).
4950
All the migrations always run in a transaction.
5051

5152
For MySQL it is highly recommended to use `IF EXISTS` and `IF NOT EXIST` in DDL commands as MySQL implicitly commits these commands.
5253

5354
**Create a function which returns all the migrations in a map**
5455

5556
**Filename : all.go**
57+
5658
```go
5759
package migrations
5860

@@ -67,7 +69,8 @@ func All() map[int64]migration.Migrate {
6769

6870
Migrations will run in ascending order of keys in this map.
6971

70-
### Initialisation from main.go
72+
### Initialisation from main.go
73+
7174
```go
7275
package main
7376

@@ -95,11 +98,8 @@ When we run the app we will see the following logs for migrations which ran succ
9598
INFO [16:55:46] Migration 20240226153000 ran successfully
9699
```
97100

98-
99-
100-
101101
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" /%}
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" /%}
103103

104104
## Migration Records
105105

@@ -108,21 +108,32 @@ This way, you only need to ensure that your migrations are properly in place. {%
108108
Migration records are stored and maintained in **gofr_migrations** table which has the following schema:
109109

110110
{% table %}
111-
* Field
112-
* Type
111+
112+
- Field
113+
- Type
114+
113115
---
114-
* version
115-
* bigint
116+
117+
- version
118+
- bigint
119+
116120
---
117-
* method
118-
* varchar(4)
121+
122+
- method
123+
- varchar(4)
124+
119125
---
120-
* start_time
121-
* timestamp
126+
127+
- start_time
128+
- timestamp
129+
122130
---
123-
* duration
124-
* bigint
131+
132+
- duration
133+
- bigint
134+
125135
---
136+
126137
{% /table %}
127138

128139
**REDIS**

docs/advanced-guide/http-communication/page.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
# Interservice HTTP Calls
2+
23
GoFr promotes microservice architecture and to facilitate the same, it provides the support
34
to initialize HTTP services at application level using `AddHTTPService()` method.
45
Support for inter-service http calls provide the following benefits:
56

67
1. Access to the method from container - GET, PUT, POST, PATCH, DELETE.
78
2. Logs and traces for the request.
8-
3. {% new-tab-link title="Circuit breaking" href="/docs/advanced-guide/circuit-breaker" /%} for enhanced resilience and fault tolerance.
9-
4. {% new-tab-link title="Custom Health Check" href="/docs/advanced-guide/monitoring-service-health" /%} Endpoints
9+
3. {% new-tab-link newtab=false title="Circuit breaking" href="/docs/advanced-guide/circuit-breaker" /%} for enhanced resilience and fault tolerance.
10+
4. {% new-tab-link newtab=false title="Custom Health Check" href="/docs/advanced-guide/monitoring-service-health" /%} Endpoints
1011

1112
## Usage
1213

1314
### Registering a simple HTTP Service
14-
Users can register a new HTTP service using the application method `AddHTTPService()`.
15+
16+
Users can register a new HTTP service using the application method `AddHTTPService()`.
1517
It takes in a service name and service address argument to register your dependent service at application level.
1618
Users can easily register multiple dependent services easily, which is a common use case in a microservice architecture.
19+
1720
> The services instances are maintained by the container.
1821
19-
Users can provide other options additionally to coat their basic http client with features like circuit-breaker and
22+
Users can provide other options additionally to coat their basic http client with features like circuit-breaker and
2023
custom health check to add to the functionality of the HTTP service.
2124
The design choice for this was made so that user can add as many options as required and are order agnostic,
2225
i.e. the order of the options is not important.
26+
2327
> Service names are to be kept unique to one service.
2428
2529
```go
2630
app.AddHTTPService(<service_name> , <service_address>)
2731
```
2832

2933
#### Example
34+
3035
```go
3136
package main
3237

@@ -49,6 +54,7 @@ func main() {
4954
```
5055

5156
### Accessing HTTP Service in handler
57+
5258
Users can access the HTTP service client from anywhere using the gofr.Context that gets passed on from the handler.
5359
The service name that was given at the time of registering the service.
5460

@@ -58,22 +64,22 @@ svc := ctx.GetHTTPService(<service_name>)
5864

5965
```go
6066
func Customer(ctx *gofr.Context) (interface{}, error) {
61-
// Get the payment service client
67+
// Get the payment service client
6268
paymentSvc := ctx.GetHTTPService("payment")
63-
69+
6470
// Use the Get method to call the GET /user endpoint of payments service
6571
resp, err := paymentSvc.Get(ctx, "user", nil)
6672
if err != nil {
6773
return nil, err
6874
}
69-
75+
7076
defer resp.Body.Close()
71-
77+
7278
body, err := io.ReadAll(resp.Body)
7379
if err != nil {
7480
return nil, err
7581
}
76-
82+
7783
return string(body), nil
7884
}
7985
```

0 commit comments

Comments
 (0)