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-3Lines changed: 1 addition & 3 deletions
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.
6
6
@@ -42,5 +42,3 @@ func main() {
42
42
43
43
Circuit breaker state changes to open when number of consecutive failed requests increases the threshold.
44
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.
45
-
46
-
To override the default aliveness endpoint {% new-tab-link newtab=false title="refer" href="/docs/advanced-guide/monitoring-service-health" /%}.
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" /%}
It involves sending the prefix `Basic` trailed by the Base64-encoded `<username>:<password>` within the standard `Authorization` header.
16
16
17
17
### Basic Authentication in GoFr
18
18
19
19
GoFr offers two ways to implement basic authentication:
20
20
21
21
**1. Predefined Credentials**
22
22
23
-
Use `EnableBasicAuth(username, password)` to configure Gofr with pre-defined credentials.
23
+
Use `EnableBasicAuth(username, password)` to configure GoFr with pre-defined credentials.
24
24
25
25
```go
26
26
funcmain() {
@@ -39,7 +39,8 @@ func main() {
39
39
40
40
**2. Custom Validation Function**
41
41
42
-
Use `EnableBasicAuthWithFunc(validationFunc)` to implement your own validation logic for credentials. The `validationFunc` takes the username and password as arguments and returns true if valid, false otherwise.
42
+
Use `EnableBasicAuthWithFunc(validationFunc)` to implement your own validation logic for credentials.
43
+
The `validationFunc` takes the username and password as arguments and returns true if valid, false otherwise.
This code snippet demonstrates how to add basic authentication to an HTTP service in GoFr and make a request with the appropriate Authorization header:
Users include a unique API key in the request header for validation against a store of authorized keys.
76
+
*API Key Authentication* is an HTTP authentication scheme where a unique API key is included in the request header for validation against a store of authorized keys.
77
77
78
78
### Usage:
79
79
GoFr offers two ways to implement API Keys authentication.
80
80
81
81
**1. Framework Default Validation**
82
-
-Users can select the framework's default validation using **_EnableAPIKeyAuth(apiKeys ...string)_**
82
+
-GoFr's default validation can be selected using **_EnableAPIKeyAuth(apiKeys ...string)_**
83
83
84
84
```go
85
85
package main
@@ -97,7 +97,7 @@ func main() {
97
97
```
98
98
99
99
**2. Custom Validation Function**
100
-
-Users can create their own validator function `apiKeyValidator(apiKey string) bool` for validating APIKeys and pass the func in **_EnableAPIKeyAuthWithFunc(validator)_**
100
+
-GoFr allows a custom validator function `apiKeyValidator(apiKey string) bool` for validating APIKeys and pass the func in **_EnableAPIKeyAuthWithFunc(validator)_**
OAuth 2.0 is the industry-standard protocol for authorization.
131
+
{% new-tab-link title="OAuth" href="https://www.rfc-editor.org/rfc/rfc6749" /%} 2.0 is the industry-standard protocol for authorization.
132
132
It focuses on client developer simplicity while providing specific authorization flows for web applications, desktop applications, mobile phones, and living room devices.
133
-
To know more about it refer {% new-tab-link title="here" href="https://www.rfc-editor.org/rfc/rfc6749" /%}
134
133
135
-
It involves sending the term`Bearer` trailed by the encoded token within the standard `Authorization` header.
134
+
It involves sending the prefix`Bearer` trailed by the encoded token within the standard `Authorization` header.
Enable OAuth 2.0 with three-legged flow to authenticate requests
143
142
144
-
Use `EnableOAuth(jwks-endpoint,refresh_interval)` to configure Gofr with pre-defined credentials.
143
+
Use `EnableOAuth(jwks-endpoint,refresh_interval)` to configure GoFr with pre-defined credentials.
145
144
146
145
```go
147
146
funcmain() {
@@ -163,17 +162,17 @@ For server-to-server communication it follows two-legged OAuth, also known as "c
163
162
where the client application directly exchanges its own credentials (ClientID and ClientSecret)
164
163
for an access token without involving any end-user interaction.
165
164
166
-
This code snippet demonstrates how two-legged OAuth authentication is added to an HTTP service in GoFr and make a request with the appropriate Authorization header.
165
+
This code snippet demonstrates how two-legged OAuth authentication is added to an HTTP service in GoFr and make a request with the appropriate Authorization header:
Copy file name to clipboardExpand all lines: docs/advanced-guide/monitoring-service-health/page.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,15 @@
1
1
# Monitoring Service Health
2
2
3
-
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.
3
+
Health check in microservices refers to a mechanism or process implemented within each service to assess its operational status
4
+
and readiness to handle requests. It involves regularly querying the service to determine if it is functioning correctly,
5
+
typically by evaluating its responsiveness and ability to perform essential tasks. Health checks play a critical role in ensuring service availability,
6
+
detecting failures, preventing cascading issues, and facilitating effective traffic routing in distributed systems.
4
7
5
-
## GoFr by default registers two endpoints which are:
8
+
## GoFr by default registers two endpoints which are:
6
9
7
10
### 1. Aliveness - /.well-known/alive
8
11
9
-
It is an endpoint which return the following response when the service is UP with a 200 response code.
12
+
It is an endpoint which returns the following response with a 200 status code, when the service is UP.
10
13
11
14
```json
12
15
{
@@ -18,8 +21,7 @@ It is an endpoint which return the following response when the service is UP wit
18
21
19
22
It is also used when state of {% new-tab-link newtab=false title="circuit breaker" href="/docs/advanced-guide/circuit-breaker" /%} is open.
20
23
21
-
To override the endpoint when registering HTTP Service pass the following option.
22
-
24
+
To override this endpoint, pass the following option while registering HTTP Service:
23
25
```go
24
26
&service.HealthConfig{
25
27
HealthEndpoint: "breeds",
@@ -28,10 +30,9 @@ To override the endpoint when registering HTTP Service pass the following option
28
30
29
31
### 2. Health-Check - /.well-known/health-check
30
32
31
-
It returns if the service is UP or DOWN along with stats, host, status about the dependent datasources and services.
32
-
33
-
Sample response of how it appears when all the services, and connected data sources are up.
33
+
It is an endpoint which returns whether the service is UP or DOWN along with stats, host, status about the dependent datasources and services.
34
34
35
+
Sample response of how it appears when all the services, and connected data sources are UP:
0 commit comments