Skip to content

Commit 273caad

Browse files
authored
Merge branch 'development' into docs/issue-2557-log-levels
2 parents dfa2e0f + 3bbc7d4 commit 273caad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+7676
-1089
lines changed

.github/workflows/go.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
# Upload coverage report for the 1.24 Go version only
112112
- name: Upload Test Coverage
113113
if: ${{ matrix.go-version == '1.24'}}
114-
uses: actions/upload-artifact@v5
114+
uses: actions/upload-artifact@v6
115115
with:
116116
name: Example-Test-Report
117117
path: profile.cov
@@ -186,7 +186,7 @@ jobs:
186186
# Upload coverage report for the 1.24 Go version only
187187
- name: Upload Test Coverage
188188
if: ${{ matrix.go-version == '1.24'}}
189-
uses: actions/upload-artifact@v5
189+
uses: actions/upload-artifact@v6
190190
with:
191191
name: PKG-Coverage-Report
192192
path: profile.cov
@@ -203,7 +203,7 @@ jobs:
203203

204204
# Download coverage reports from previous jobs
205205
- name: Download Coverage Report
206-
uses: actions/download-artifact@v6
206+
uses: actions/download-artifact@v7
207207
with:
208208
path: artifacts
209209

@@ -297,7 +297,7 @@ jobs:
297297
298298
# Upload submodule coverage reports as an artifact
299299
- name: Upload Coverage Reports
300-
uses: actions/upload-artifact@v5
300+
uses: actions/upload-artifact@v6
301301
with:
302302
name: submodule-coverage-reports
303303
path: coverage_reports/*.cov
@@ -325,7 +325,7 @@ jobs:
325325
326326
# Download coverage artifacts
327327
- name: Download Coverage Report
328-
uses: actions/download-artifact@v6
328+
uses: actions/download-artifact@v7
329329
with:
330330
path: artifacts
331331

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Contribution Guidelines
22
* Minor changes can be done directly by editing code on GitHub. GitHub automatically creates a temporary branch and
33
files a PR. This is only suitable for really small changes like: spelling fixes, variable name changes or error string
4-
change etc. For larger commits, following steps are recommended.
4+
change etc. For larger commits, the following steps are recommended.
55
* (Optional) If you want to discuss your implementation with the users of GoFr, use the GitHub discussions of this repo.
66
* Configure your editor to use goimports and golangci-lint on file changes. Any code which is not formatted using these
77
tools, will fail on the pipeline.
@@ -16,7 +16,7 @@
1616
No PR should ever decrease the overall code coverage.
1717
* Once your code changes are done along with the test cases, submit a PR to development branch. Please note that all PRs
1818
are merged from feature branches to development first.
19-
* PR should be raised only when development is complete and the code is ready for review. This approach helps reduce the number of open pull requests and facilitates a more efficient review process for the team.
19+
* A PR should be raised only when development is complete and the code is ready for review. This approach helps reduce the number of open pull requests and facilitates a more efficient review process for the team.
2020
* All PRs need to be reviewed by at least 2 GoFr developers. They might reach out to you for any clarification.
2121
* Thank you for your contribution. :)
2222

docs/advanced-guide/handling-file/page.md

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -103,66 +103,75 @@ func main() {
103103
104104
### Google Cloud Storage (GCS) Bucket as File-Store
105105

106-
To run GCS File-Store locally we can use fake-gcs-server:
107-
`docker run -it --rm -p 4443:4443 -e STORAGE_EMULATOR_HOST=0.0.0.0:4443 fsouza/fake-gcs-server:latest`
106+
**Local Setup with fake-gcs-server:**
107+
108+
1. Start fake-gcs-server with HTTP:
109+
```bash
110+
docker run -d --name fake-gcs-server -p 4443:4443 \
111+
fsouza/fake-gcs-server -scheme http -port 4443
112+
```
113+
114+
2. Create a bucket:
115+
```bash
116+
curl -X POST http://localhost:4443/storage/v1/b?project=my-project-id \
117+
-H "Content-Type: application/json" \
118+
-d '{"name":"my-bucket"}'
119+
```
120+
121+
3. Set environment variable in your `configs/.env` file:
122+
```bash
123+
STORAGE_EMULATOR_HOST=localhost:4443
124+
```
125+
126+
4. Connect to GCS in your application:
108127

109128
```go
110129
package main
111130

112131
import (
113132
"gofr.dev/pkg/gofr"
114-
115133
"gofr.dev/pkg/gofr/datasource/file/gcs"
116134
)
117135

118136
func main() {
119137
app := gofr.New()
120138

121-
// Option 1: Using JSON credentials with local emulator
122-
fs, err := gcs.New(&gcs.Config{
123-
EndPoint: "http://localhost:4566",
124-
BucketName: "my-bucket",
125-
CredentialsJSON: readFile("gcs-credentials.json"),
126-
ProjectID: "my-project-id",
127-
})
128-
129-
if err != nil {
130-
app.Logger().Fatalf("Failed to initialize GCS: %v", err)
131-
132-
}
133-
134-
app.AddFileStore(fs)
139+
// Local setup with fake-gcs-server (uses STORAGE_EMULATOR_HOST)
140+
app.AddFileStore(gcs.New(&gcs.Config{
141+
BucketName: "my-bucket",
142+
ProjectID: "my-project-id",
143+
}))
135144

136-
// Option 2: Using default credentials (GOOGLE_APPLICATION_CREDENTIALS)
137-
// fs, err := gcs.New(&gcs.Config{
138-
// BucketName: "my-bucket",
139-
// ProjectID: "my-project-id",
140-
// }))
141-
142-
// Option 3: Direct connection to real GCS (no EndPoint)
143-
// fs, err := gcs.New(&gcs.Config{
144-
// BucketName: "my-bucket",
145-
// CredentialsJSON: readFile("prod-creds.json"),
146-
// ProjectID: "my-project-id",
147-
// }))
148-
145+
app.Run()
149146
app.Run()
150147
}
148+
```
151149

152-
// Helper function to read credentials file
153-
func readFile(filename string) []byte {
154-
data, err := os.ReadFile(filename)
155-
if err != nil {
156-
log.Fatalf("Failed to read credentials file: %v", err)
157-
}
158-
return data
159-
}
150+
**Production Setup:**
160151

152+
For production, authenticate using one of these methods:
153+
154+
```go
155+
// Option 1: Using GOOGLE_APPLICATION_CREDENTIALS environment variable
156+
// Set: export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
157+
app.AddFileStore(gcs.New(&gcs.Config{
158+
BucketName: "my-bucket",
159+
ProjectID: "my-project-id",
160+
}))
161+
162+
// Option 2: Using CredentialsJSON directly
163+
credJSON, _ := os.ReadFile("gcs-credentials.json")
164+
app.AddFileStore(gcs.New(&gcs.Config{
165+
BucketName: "my-bucket",
166+
CredentialsJSON: string(credJSON),
167+
ProjectID: "my-project-id",
168+
}))
161169
```
162170

163-
> **Note:** When connecting to the actual GCS service, authentication can be provided via CredentialsJSON or the GOOGLE_APPLICATION_CREDENTIALS environment variable.
164-
> When using fake-gcs-server, authentication is not required.
165-
> Currently supports one bucket per file-store instance.
171+
> **Note:**
172+
> - When `STORAGE_EMULATOR_HOST` is set, the client automatically connects to the local emulator without authentication.
173+
> - For production, use either `GOOGLE_APPLICATION_CREDENTIALS` environment variable or `CredentialsJSON` config field
174+
> - Currently supports one bucket per file-store instance
166175
167176
### Azure File Storage as File-Store
168177

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ func Customer(ctx *gofr.Context) (any, error) {
8888

8989
GoFr provides its user with additional configurational options while registering HTTP service for communication. These are:
9090

91+
- **ConnectionPoolConfig** - This option allows the user to configure HTTP connection pool settings to optimize performance for high-frequency requests. The default Go HTTP client has `MaxIdleConnsPerHost: 2`, which is often insufficient for microservices making frequent requests to the same host. This configuration allows customizing:
92+
- `MaxIdleConns`: Maximum idle connections across all hosts. If not explicitly set (0), a default of 100 will be used.
93+
- `MaxIdleConnsPerHost`: Maximum idle connections per host (critical for performance). If set to 0, Go's DefaultMaxIdleConnsPerHost (2) will be used. Negative values will cause validation error.
94+
- `IdleConnTimeout`: How long to keep idle connections alive. If not explicitly set (0), a default of 90 seconds will be used.
95+
96+
**Important**: `ConnectionPoolConfig` must be applied **first** when using multiple options, as it needs access to the underlying HTTP client transport.
97+
9198
- **APIKeyConfig** - This option allows the user to set the `API-Key` Based authentication as the default auth for downstream HTTP Service.
9299
- **BasicAuthConfig** - This option allows the user to set basic auth (username and password) as the default auth for downstream HTTP Service.
93100

@@ -127,6 +134,14 @@ StopCleanup()
127134
rc := redis.NewClient(a.Config, a.Logger(), a.Metrics())
128135

129136
a.AddHTTPService("cat-facts", "https://catfact.ninja",
137+
// ConnectionPoolConfig must be applied FIRST
138+
&service.ConnectionPoolConfig{
139+
MaxIdleConns: 100, // Maximum idle connections across all hosts
140+
MaxIdleConnsPerHost: 20, // Maximum idle connections per host (increased from default 2)
141+
IdleConnTimeout: 90 * time.Second, // Keep connections alive for 90 seconds
142+
},
143+
144+
// Other options can follow in any order
130145
service.NewAPIKeyConfig("some-random-key"),
131146
service.NewBasicAuthConfig("username", "password"),
132147

0 commit comments

Comments
 (0)