Skip to content

Commit ced31c1

Browse files
authored
release(v1.7.7) (#637)
* feat(chore): opt-out surrogate storage * fix(ci): bump golangci-lint to latest (v2+) * fix(ci): use golangci-lint-action v8 * fix(tests): revert condition to use surrogate if not disabled * fix(disable_surrogate_key): add documentation * fix(disable_surrogate_key): caddy
1 parent 516ed8c commit ced31c1

File tree

1,244 files changed

+93727
-29334
lines changed

Some content is hidden

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

1,244 files changed

+93727
-29334
lines changed

.github/workflows/non-regression.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_dispatch:
66

77
env:
8-
GO_VERSION: '1.22'
8+
GO_VERSION: '1.24'
99

1010
jobs:
1111
lint-validation:
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
go-version: ${{ env.GO_VERSION }}
2121
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v6
22+
uses: golangci/golangci-lint-action@v8
2323
with:
2424
args: --timeout=240s
2525
unit-test-golang:

.github/workflows/plugin_template.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ jobs:
3434
uses: actions/checkout@v4
3535
-
3636
name: golangci-lint
37-
uses: golangci/golangci-lint-action@v6
37+
uses: golangci/golangci-lint-action@v8
3838
with:
39-
version: v1.59.1
39+
version: latest
4040
working-directory: plugins/${{ inputs.LOWER_NAME }}
41-
args: --exclude-dirs=override --timeout=240s
41+
args: -c ../../.golangci.yml
42+
if: ${{ ! startsWith(inputs.LOWER_NAME, 'traefik') }}
4243
-
4344
name: Run ${{ inputs.CAPITALIZED_NAME }} tests
4445
run: cd plugins/${{ inputs.LOWER_NAME }} && go test -v .
@@ -69,4 +70,4 @@ jobs:
6970
with:
7071
collection: "docs/e2e/Souin E2E.postman_collection.json"
7172
folder: '["${{ inputs.CAPITALIZED_NAME }}"]'
72-
delayRequest: 5000
73+
delayRequest: 5000

.github/workflows/plugins-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- master
77

88
env:
9-
GO_VERSION: '1.22'
9+
GO_VERSION: '1.24'
1010

1111
jobs:
1212
build-caddy-validator:

.github/workflows/plugins.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ jobs:
88
name: Caddy
99
runs-on: ubuntu-latest
1010
services:
11-
nats:
12-
image: darkweak/nats
13-
ports:
14-
- 4222:4222
15-
- 6222:6222
16-
- 8222:8222
1711
redis:
1812
image: redis
1913
ports:
@@ -42,7 +36,7 @@ jobs:
4236
name: Install Go
4337
uses: actions/setup-go@v3
4438
with:
45-
go-version: '1.22'
39+
go-version: '1.24'
4640
-
4741
name: Checkout code
4842
uses: actions/checkout@v4
@@ -91,7 +85,7 @@ jobs:
9185
name: Install Go
9286
uses: actions/setup-go@v5
9387
with:
94-
go-version: '1.22'
88+
go-version: '1.24'
9589

9690
- name: Install Node.js
9791
uses: actions/setup-node@v4
@@ -164,74 +158,74 @@ jobs:
164158
with:
165159
CAPITALIZED_NAME: Beego
166160
LOWER_NAME: beego
167-
GO_VERSION: '1.22'
161+
GO_VERSION: '1.24'
168162
build-chi-validator:
169163
uses: ./.github/workflows/plugin_template.yml
170164
secrets: inherit
171165
with:
172166
CAPITALIZED_NAME: Chi
173167
LOWER_NAME: chi
174-
GO_VERSION: '1.22'
168+
GO_VERSION: '1.24'
175169
build-dotweb-validator:
176170
uses: ./.github/workflows/plugin_template.yml
177171
secrets: inherit
178172
with:
179173
CAPITALIZED_NAME: Dotweb
180174
LOWER_NAME: dotweb
181-
GO_VERSION: '1.22'
175+
GO_VERSION: '1.24'
182176
build-echo-validator:
183177
uses: ./.github/workflows/plugin_template.yml
184178
secrets: inherit
185179
with:
186180
CAPITALIZED_NAME: Echo
187181
LOWER_NAME: echo
188-
GO_VERSION: '1.22'
182+
GO_VERSION: '1.24'
189183
build-fiber-validator:
190184
uses: ./.github/workflows/plugin_template.yml
191185
secrets: inherit
192186
with:
193187
CAPITALIZED_NAME: Fiber
194188
LOWER_NAME: fiber
195-
GO_VERSION: '1.22'
189+
GO_VERSION: '1.24'
196190
build-gin-validator:
197191
uses: ./.github/workflows/plugin_template.yml
198192
secrets: inherit
199193
with:
200194
CAPITALIZED_NAME: Gin
201195
LOWER_NAME: gin
202-
GO_VERSION: '1.22'
196+
GO_VERSION: '1.24'
203197
build-goa-validator:
204198
uses: ./.github/workflows/plugin_template.yml
205199
secrets: inherit
206200
with:
207201
CAPITALIZED_NAME: Goa
208202
LOWER_NAME: goa
209-
GO_VERSION: '1.22'
203+
GO_VERSION: '1.24'
210204
build-kratos-validator:
211205
uses: ./.github/workflows/plugin_template.yml
212206
secrets: inherit
213207
with:
214208
CAPITALIZED_NAME: Kratos
215209
LOWER_NAME: kratos
216-
GO_VERSION: '1.22'
210+
GO_VERSION: '1.24'
217211
build-souin-validator:
218212
uses: ./.github/workflows/plugin_template.yml
219213
secrets: inherit
220214
with:
221215
CAPITALIZED_NAME: Souin
222216
LOWER_NAME: souin
223-
GO_VERSION: '1.22'
217+
GO_VERSION: '1.24'
224218
build-traefik-validator:
225219
uses: ./.github/workflows/plugin_template.yml
226220
secrets: inherit
227221
with:
228222
CAPITALIZED_NAME: Traefik
229223
LOWER_NAME: traefik
230-
GO_VERSION: '1.22'
224+
GO_VERSION: '1.24'
231225
build-webgo-validator:
232226
uses: ./.github/workflows/plugin_template.yml
233227
secrets: inherit
234228
with:
235229
CAPITALIZED_NAME: Webgo
236230
LOWER_NAME: webgo
237-
GO_VERSION: '1.22'
231+
GO_VERSION: '1.24'

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
tags: ["v*"]
66

77
env:
8-
GO_VERSION: '1.22'
8+
GO_VERSION: '1.24'
99

1010
jobs:
1111
generate-souin-traefik-docker:

.github/workflows/workflow_plugins_generator.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Disabled go-zero and hertz temporary
44
# plugins=("beego" "chi" "dotweb" "echo" "fiber" "gin" "goa" "go-zero" "hertz" "kratos" "roadrunner" "souin" "traefik" "tyk" "webgo")
55
plugins=("beego" "chi" "dotweb" "echo" "fiber" "gin" "goa" "kratos" "souin" "traefik" "webgo")
6-
go_version=1.22
6+
go_version=1.24
77

88
IFS= read -r -d '' tpl <<EOF
99
name: Build and validate Souin as plugins
@@ -93,7 +93,7 @@ jobs:
9393
name: Install Go
9494
uses: actions/setup-go@v5
9595
with:
96-
go-version: '1.22'
96+
go-version: '1.24'
9797
9898
- name: Install Node.js
9999
uses: actions/setup-node@v4
@@ -177,4 +177,4 @@ for i in ${!plugins[@]}; do
177177
EOF
178178
workflow+="$tpl"
179179
done
180-
echo "${workflow%$'\n'}" > "$( dirname -- "$0"; )/plugins.yml"
180+
echo "${workflow%$'\n'}" > "$( dirname -- "$0"; )/plugins.yml"

.golangci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "2"
2+
3+
issues:
4+
fix: true
5+
6+
linters:
7+
disable:
8+
- staticcheck
9+
10+
run:
11+
timeout: 5m

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ generate-workflow: ## Generate plugin workflow
147147
bash .github/workflows/workflow_plugins_generator.sh
148148

149149
golangci-lint: ## Run golangci-lint to ensure the code quality
150-
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:latest golangci-lint run -v --timeout 180s ./...
151-
for plugin in $(PLUGINS_LIST) ; do \
152-
echo "Starting lint $$plugin \n" && docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:latest golangci-lint run -v --exclude-dirs=override --timeout 240s ./plugins/$$plugin; \
150+
golangci-lint run -v ./...
151+
for plugin in $(MOD_PLUGINS_LIST) ; do \
152+
echo "Starting lint $$plugin \n" && cd ./plugins/$$plugin && golangci-lint run -v -c ../../.golangci.yml ./...; cd -; \
153153
done
154154
cd plugins/caddy && go mod tidy && go mod download
155155

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ surrogate_keys:
202202
| `cdn.service_id` | The service id if required, depending the provider | `123456_id` |
203203
| `cdn.zone_id` | The zone id if required, depending the provider | `anywhere_zone` |
204204
| `default_cache.allowed_http_verbs` | The HTTP verbs to support cache | `- GET`<br/><br/>`- POST`<br/><br/>`(default: GET, HEAD)` |
205-
| `default_cache.allowed_additional_status_codes` | The additional HTTP status code to support cache | `- 200`<br/><br/>`- 404` |
205+
| `default_cache.allowed_additional_status_codes` | The additional HTTP status code to support cache | `- 200`<br/><br/>`- 404` |
206206
| `default_cache.badger` | Configure the Badger cache storage | |
207207
| `default_cache.badger.path` | Configure Badger with a file | `/anywhere/badger_configuration.json` |
208208
| `default_cache.badger.configuration` | Configure Badger directly in the Caddyfile or your JSON caddy configuration | [See the Badger configuration for the options](https://dgraph.io/docs/badger/get-started/) |
@@ -241,6 +241,9 @@ surrogate_keys:
241241
| `default_cache.redis.configuration` | Configure Redis directly in the Caddyfile or your JSON caddy configuration | [See the Go-redis configuration for the options](https://github.com/redis/go-redis/blob/master/options.go#L31) or [See the Rueidis configuration for the options](https://github.com/redis/rueidis/blob/master/rueidis.go#56) |
242242
| `default_cache.regex.exclude` | The regex used to prevent paths being cached | `^[A-z]+.*$` |
243243
| `default_cache.stale` | The stale duration | `25m` |
244+
| `default_cache.simplefs` | Configure the SimpleFS cache storage | |
245+
| `default_cache.simplefs.configuration` | Configure SimpleFS directly in the Caddyfile or your JSON caddy configuration | |
246+
| `default_cache.simplefs.configuration.size` | Set the size of the pool in Otter | `999999` (default `10000`) |
244247
| `default_cache.timeout` | The timeout configuration | |
245248
| `default_cache.timeout.backend` | The timeout duration to consider the backend as unreachable | `10s` |
246249
| `default_cache.timeout.cache` | The timeout duration to consider the cache provider as unreachable | `10ms` |
@@ -254,10 +257,23 @@ surrogate_keys:
254257
| `surrogate_keys.{key name}.headers` | Headers that should match to be part of the surrogate key group | `Authorization: ey.+`<br/><br/>`Content-Type: json` |
255258
| `surrogate_keys.{key name}.headers.{header name}` | Header name that should be present a match the regex to be part of the surrogate key group | `Content-Type: json` |
256259
| `surrogate_keys.{key name}.url` | Url that should match to be part of the surrogate key group | `.+` |
260+
| `disable_surrogate_key` | Disable the Surrogate keys storage system | `true` |
257261
| `ykeys.{key name}.headers` | (DEPRECATED) Headers that should match to be part of the ykey group | `Authorization: ey.+`<br/><br/>`Content-Type: json` |
258262
| `ykeys.{key name}.headers.{header name}` | (DEPRECATED) Header name that should be present a match the regex to be part of the ykey group | `Content-Type: json` |
259263
| `ykeys.{key name}.url` | (DEPRECATED) Url that should match to be part of the ykey group | `.+` |
260264

265+
## Storages
266+
Since `v1.7.0` Souin implements only one storage. If you need a specific storage you have to take it from [the storages repository](https://github.com/darkweak/storages) and add it either in your code, during the build otherwise.
267+
268+
Supported storages
269+
- [Badger](https://github.com/dgraph-io/badger)
270+
- [Etcd](https://github.com/etcd-io/etcd)
271+
- [NutsDB](https://github.com/nutsdb/nutsdb)
272+
- [Olric](https://github.com/buraksezer/olric)
273+
- [Otter](https://github.com/maypok86/otter)
274+
- [Redis](https://github.com/redis/redis)
275+
- [Simplefs](https://github.com/darkweak/storages)
276+
261277
## APIs
262278
All endpoints are accessible through the `api.basepath` configuration line or by default through `/souin-api` to avoid named route conflicts. Be sure to define an unused route to not break your existing application.
263279

@@ -311,9 +327,12 @@ See the sequence diagram for the minimal version below
311327
## Cache systems
312328
Supported providers
313329
- [Badger](https://github.com/dgraph-io/badger)
314-
- [NutsDB](https://github.com/nutsdb/nutsdb)
315330
- [Etcd](https://github.com/etcd-io/etcd)
331+
- [NutsDB](https://github.com/nutsdb/nutsdb)
316332
- [Olric](https://github.com/buraksezer/olric)
333+
- [Otter](https://github.com/maypok86/otter)
334+
- [Redis](https://github.com/redis/redis)
335+
- [Simplefs](https://github.com/darkweak/storages)
317336

318337
The cache system sits on top of three providers at the moment. It provides two in-memory storage solutions (badger and nuts), and two distributed storages Olric and Etcd because setting, getting, updating and deleting keys in these providers is as easy as it gets.
319338
**The Badger provider (default one)**: you can tune its configuration using the badger configuration inside your Souin configuration. In order to do that, you have to declare the `badger` block. See the following json example.
@@ -966,7 +985,7 @@ experimental:
966985
plugins:
967986
souin:
968987
moduleName: github.com/darkweak/souin
969-
version: v1.7.6
988+
version: v1.7.7
970989
```
971990
After that you can declare either the whole configuration at once in the middleware block or by service. See the examples below.
972991
```yaml

configurationtypes/types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (c *CacheKeys) MarshalJSON() ([]byte, error) {
106106
for _, cacheKey := range *c {
107107
for rg, key := range cacheKey {
108108
keyBytes, _ := json.Marshal(key)
109-
strKeys = append(strKeys, fmt.Sprintf(`"%s": %v`, rg.Regexp.String(), string(keyBytes)))
109+
strKeys = append(strKeys, fmt.Sprintf(`"%s": %v`, rg.String(), string(keyBytes)))
110110
}
111111
}
112112

@@ -120,7 +120,7 @@ type Duration struct {
120120

121121
// MarshalYAML transform the Duration into a time.duration object
122122
func (d *Duration) MarshalYAML() (interface{}, error) {
123-
return yaml.Marshal(d.Duration.String())
123+
return yaml.Marshal(d.String())
124124
}
125125

126126
// UnmarshalYAML parse the time.duration into a Duration object
@@ -132,7 +132,7 @@ func (d *Duration) UnmarshalYAML(b *yaml.Node) (e error) {
132132

133133
// MarshalJSON transform the Duration into a time.duration object
134134
func (d Duration) MarshalJSON() ([]byte, error) {
135-
return json.Marshal(d.Duration.String())
135+
return json.Marshal(d.String())
136136
}
137137

138138
// UnmarshalJSON parse the time.duration into a Duration object
@@ -481,5 +481,6 @@ type AbstractConfigurationInterface interface {
481481
SetLogger(core.Logger)
482482
GetYkeys() map[string]SurrogateKeys
483483
GetSurrogateKeys() map[string]SurrogateKeys
484+
IsSurrogateDisabled() bool
484485
GetCacheKeys() CacheKeys
485486
}

0 commit comments

Comments
 (0)