mirror of
https://github.com/gofiber/storage.git
synced 2025-09-27 04:46:08 +08:00
Compare commits
198 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
551c37101c | ||
![]() |
23f59994f8 | ||
![]() |
109c6b6f4f | ||
![]() |
fc6b3c841b | ||
![]() |
0b3e720b84 | ||
![]() |
7bcf46ac24 | ||
![]() |
0b31353707 | ||
![]() |
872f038e0b | ||
![]() |
b08cc03b22 | ||
![]() |
328c5ce28f | ||
![]() |
3e54ad6cac | ||
![]() |
7990d6d708 | ||
![]() |
95f32bf522 | ||
![]() |
95f98b0c41 | ||
![]() |
b0af7b2d2e | ||
![]() |
51f7507c86 | ||
![]() |
0965ae08a9 | ||
![]() |
2e6aade129 | ||
![]() |
7d29b5bbf0 | ||
![]() |
6666191087 | ||
![]() |
43b37e9b7e | ||
![]() |
6c53e5e46e | ||
![]() |
d178fca7df | ||
![]() |
230c3a6c5b | ||
![]() |
9b85e40cc6 | ||
![]() |
e38e2dcbba | ||
![]() |
a5d0a37b49 | ||
![]() |
808d103448 | ||
![]() |
30e0b8afa8 | ||
![]() |
da887624a4 | ||
![]() |
5eb8d57c09 | ||
![]() |
89493b1be0 | ||
![]() |
7ad1f0f105 | ||
![]() |
ffa78322a4 | ||
![]() |
ad9cf6da5d | ||
![]() |
a5a18bb80b | ||
![]() |
81764f4072 | ||
![]() |
327c871825 | ||
![]() |
4126450357 | ||
![]() |
8e81d7cded | ||
![]() |
94977c4028 | ||
![]() |
278f9d748a | ||
![]() |
d5f9d825aa | ||
![]() |
3a4eb3934d | ||
![]() |
d0b6aa2131 | ||
![]() |
310758fc7a | ||
![]() |
c1ab36765b | ||
![]() |
f24af60e42 | ||
![]() |
7d0bbde770 | ||
![]() |
efffcc135b | ||
![]() |
1b233673bb | ||
![]() |
07bde5f757 | ||
![]() |
ce174aed64 | ||
![]() |
cff33471cf | ||
![]() |
e211b33874 | ||
![]() |
05c149e84f | ||
![]() |
bf50899345 | ||
![]() |
b2f8339751 | ||
![]() |
e0435cd1a0 | ||
![]() |
d03bf4584c | ||
![]() |
e40f7b86df | ||
![]() |
3a8b8d4f71 | ||
![]() |
c38c925975 | ||
![]() |
d27ddd4739 | ||
![]() |
0aec65bb77 | ||
![]() |
671a3e4a04 | ||
![]() |
cbc4d3d251 | ||
![]() |
fe8cc5f97c | ||
![]() |
af3630ee22 | ||
![]() |
602260698d | ||
![]() |
ad27e8bcbb | ||
![]() |
d4ddc46c29 | ||
![]() |
ac29a7e86c | ||
![]() |
daa2dc7ee4 | ||
![]() |
1e822400d5 | ||
![]() |
57f7bb86d5 | ||
![]() |
ba65508bc9 | ||
![]() |
30e23d86d0 | ||
![]() |
7c79c78623 | ||
![]() |
caf28d82f7 | ||
![]() |
28ae1f71fb | ||
![]() |
bdea86b669 | ||
![]() |
2ec5a2cf70 | ||
![]() |
841d5eaedd | ||
![]() |
9ee4838edf | ||
![]() |
12203cbbe8 | ||
![]() |
e2ce496727 | ||
![]() |
4c11a63573 | ||
![]() |
725abe0123 | ||
![]() |
81c40a28df | ||
![]() |
2465b14c41 | ||
![]() |
d002c1076e | ||
![]() |
c3e5299489 | ||
![]() |
2d113619b3 | ||
![]() |
2fdd8600ad | ||
![]() |
dbc7a0636d | ||
![]() |
382fd19d57 | ||
![]() |
364ffb1dda | ||
![]() |
b787cedd82 | ||
![]() |
2dd7251e59 | ||
![]() |
b6574fdbfa | ||
![]() |
adcd9c09c3 | ||
![]() |
e8a6d1b229 | ||
![]() |
6d96fb56af | ||
![]() |
6fd94ebd5a | ||
![]() |
0c0027d11d | ||
![]() |
07d3c6b7c1 | ||
![]() |
8be14c8950 | ||
![]() |
2f13554ac3 | ||
![]() |
3d96c04300 | ||
![]() |
debcd26997 | ||
![]() |
96284ee8b7 | ||
![]() |
a1f5f8b1b0 | ||
![]() |
6ea9ef03b5 | ||
![]() |
663d7da0e7 | ||
![]() |
3432c9df7b | ||
![]() |
46d63d36ec | ||
![]() |
035b445a98 | ||
![]() |
ef2bde0f4a | ||
![]() |
b2e9530bc7 | ||
![]() |
bd65618ff5 | ||
![]() |
6420cf2823 | ||
![]() |
2f656df41c | ||
![]() |
83339bc156 | ||
![]() |
e464f894c6 | ||
![]() |
a5b31b013b | ||
![]() |
0dd7781663 | ||
![]() |
771b96b211 | ||
![]() |
aeda350995 | ||
![]() |
551f99d5d2 | ||
![]() |
2aa051f366 | ||
![]() |
7d95149519 | ||
![]() |
1c100fe50a | ||
![]() |
395ea51b28 | ||
![]() |
d327e9b0dd | ||
![]() |
5cbf98de49 | ||
![]() |
22444f8aa9 | ||
![]() |
cc5ccf062b | ||
![]() |
315f14ce58 | ||
![]() |
f9eaa6ae4d | ||
![]() |
2be6e0cc10 | ||
![]() |
5b444c36df | ||
![]() |
61fa9709f2 | ||
![]() |
45cc6b9dcd | ||
![]() |
e7293b3841 | ||
![]() |
69b0b5a26f | ||
![]() |
edb920dc05 | ||
![]() |
df9fdcbaf9 | ||
![]() |
1883d62d06 | ||
![]() |
ff1db4e2a4 | ||
![]() |
5048d2480c | ||
![]() |
d75a723f55 | ||
![]() |
864b9a01e0 | ||
![]() |
b866b0b30a | ||
![]() |
842a366c10 | ||
![]() |
2728ec3c02 | ||
![]() |
4a3096149e | ||
![]() |
726ef21f76 | ||
![]() |
3d9778b4da | ||
![]() |
c2fa94c9f4 | ||
![]() |
ff033d0e0e | ||
![]() |
f815ac6561 | ||
![]() |
f0233feaea | ||
![]() |
2e2ed658fd | ||
![]() |
fe9649ddfb | ||
![]() |
6004253367 | ||
![]() |
d93f683d40 | ||
![]() |
d3c4120740 | ||
![]() |
9fe7fada49 | ||
![]() |
1619377fd7 | ||
![]() |
1761413f2b | ||
![]() |
ccd2f0bbd6 | ||
![]() |
d6fbde4b32 | ||
![]() |
36af0e2d7b | ||
![]() |
0c07206571 | ||
![]() |
7bbbc01f84 | ||
![]() |
b94d9ecf40 | ||
![]() |
ae3553dac9 | ||
![]() |
b9b7ed25ca | ||
![]() |
61a72fd587 | ||
![]() |
be29dff25d | ||
![]() |
d62b0bb95f | ||
![]() |
40a44d5655 | ||
![]() |
6a0f72c350 | ||
![]() |
aedc03b9c3 | ||
![]() |
3397275612 | ||
![]() |
6afe536cce | ||
![]() |
53f888504d | ||
![]() |
2760d0e29e | ||
![]() |
48d48cfd7e | ||
![]() |
a83ebb0aac | ||
![]() |
7cfce7a88b | ||
![]() |
8b66d2ff33 | ||
![]() |
feaf977424 | ||
![]() |
935434a940 | ||
![]() |
4d84709369 | ||
![]() |
8a84698537 | ||
![]() |
f69705a65d |
79
.github/dependabot.yml
vendored
79
.github/dependabot.yml
vendored
@@ -2,102 +2,93 @@
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/arangodb/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/badger/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/dynamodb/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/memcache/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/memory/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/mongodb/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/mysql/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/postgres/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/redis/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/sqlite3/" # Location of package manifests
|
||||
default_labels:
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/ristretto/" # Location of package manifests
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/s3/" # Location of package manifests
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/bbolt/" # Location of package manifests
|
||||
labels:
|
||||
- "🤖 Dependencies"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
automerged_updates:
|
||||
- match:
|
||||
dependency_name: "gofiber/fiber/*"
|
||||
|
32
.github/release-drafter.yml
vendored
32
.github/release-drafter.yml
vendored
@@ -16,6 +16,7 @@ categories:
|
||||
- '📒 Documentation'
|
||||
change-template: '- $TITLE (#$NUMBER)'
|
||||
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||
sort-by: 'title'
|
||||
version-resolver:
|
||||
major:
|
||||
labels:
|
||||
@@ -42,33 +43,54 @@ autolabeler:
|
||||
- '/typos/i'
|
||||
- '/comment/i'
|
||||
- '/📚/i'
|
||||
- '/📒/i'
|
||||
- '/📝/i'
|
||||
- '/documentation/i'
|
||||
- label: '☢️ Bug'
|
||||
branch:
|
||||
- '/fix\/.+/'
|
||||
title:
|
||||
- '/fix/i'
|
||||
- '/race/i'
|
||||
- '/bug/i'
|
||||
- '/missing/i'
|
||||
- '/correct/i'
|
||||
- '/🐛/i'
|
||||
- '/☢/i'
|
||||
- '/🩹/i'
|
||||
- '/🚨/i'
|
||||
- label: '🧹 Updates'
|
||||
title:
|
||||
- '/improve/i'
|
||||
- '/update/i'
|
||||
- '/refactor/i'
|
||||
- '/deprecated/i'
|
||||
- '/remove/i'
|
||||
- '/unused/i'
|
||||
- '/test/i'
|
||||
- '/⚡/i'
|
||||
- '/👷/i'
|
||||
- '/🚧/i'
|
||||
- '/♻️/i'
|
||||
- '/🎨/i'
|
||||
- '/🧪/i'
|
||||
- '/🧹/i'
|
||||
- label: '🤖 Dependencies'
|
||||
title:
|
||||
- '/bumb/i'
|
||||
- '/dependencies/i'
|
||||
- '/📦/i'
|
||||
- '/🤖/i'
|
||||
- label: '✏️ Feature'
|
||||
branch:
|
||||
- '/feature\/.+/'
|
||||
body:
|
||||
title:
|
||||
- '/feature/i'
|
||||
- '/create/i'
|
||||
- '/implement/i'
|
||||
- '/add/i'
|
||||
- '/🚀/i'
|
||||
- '/✨/i'
|
||||
- '/🔥/i'
|
||||
template: |
|
||||
$CHANGES
|
||||
|
||||
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
||||
|
||||
Thank you $CONTRIBUTORS for making this update possible.
|
||||
|
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
with:
|
||||
languages: go
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -51,4 +51,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
23
.github/workflows/dependabot_automerge.yml
vendored
Normal file
23
.github/workflows/dependabot_automerge.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Dependabot auto-merge
|
||||
on: pull_request
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
dependabot:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||
steps:
|
||||
- name: Dependabot metadata
|
||||
id: metadata
|
||||
uses: dependabot/fetch-metadata@v1.3.3
|
||||
with:
|
||||
github-token: "${{ secrets.PR_TOKEN }}"
|
||||
- name: Enable auto-merge for Dependabot PRs
|
||||
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
|
||||
run: gh pr merge --auto --merge "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{github.event.pull_request.html_url}}
|
||||
GITHUB_TOKEN: ${{secrets.PR_TOKEN}}
|
4
.github/workflows/linter.yml
vendored
4
.github/workflows/linter.yml
vendored
@@ -5,8 +5,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Golint
|
||||
uses: reviewdog/action-golangci-lint@v1
|
||||
uses: reviewdog/action-golangci-lint@v2
|
||||
with:
|
||||
golangci_lint_flags: "--tests=false"
|
||||
|
22
.github/workflows/security.yml
vendored
22
.github/workflows/security.yml
vendored
@@ -5,16 +5,18 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '^1.17.6'
|
||||
- name: Install Gosec
|
||||
run: |
|
||||
export PATH=${PATH}:`go env GOPATH`/bin
|
||||
go get -u github.com/securego/gosec/v2/cmd/gosec
|
||||
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||
- name: Run Gosec (root)
|
||||
working-directory: .
|
||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal -exclude-dir=redis -exclude-dir=badger -exclude-dir=mysql -exclude-dir=sqlite3 -exclude-dir=mongodb -exclude-dir=postgres -exclude-dir=memcache -exclude-dir=dynamodb -exclude-dir=arangodb -exclude-dir=memory ./..."
|
||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal -exclude-dir=arangodb -exclude-dir=badger -exclude-dir=dynamodb -exclude-dir=memcache -exclude-dir=memory -exclude-dir=mongodb -exclude-dir=mysql -exclude-dir=postgres -exclude-dir=redis -exclude-dir=ristretto -exclude-dir=sqlite3 -exclude-dir=s3 -exclude-dir=bbolt ./..."
|
||||
# -----
|
||||
- name: Run Gosec (arangodb)
|
||||
working-directory: ./arangodb
|
||||
@@ -56,3 +58,15 @@ jobs:
|
||||
working-directory: ./sqlite3
|
||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||
# -----
|
||||
- name: Run Gosec (s3)
|
||||
working-directory: ./s3
|
||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||
# -----
|
||||
- name: Run Gosec (ristretto)
|
||||
working-directory: ./ristretto
|
||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||
# -----
|
||||
- name: Run Gosec (bbolt)
|
||||
working-directory: ./bbolt
|
||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||
# -----
|
||||
|
11
.github/workflows/snyk.yml
vendored
11
.github/workflows/snyk.yml
vendored
@@ -1,11 +0,0 @@
|
||||
on: [push, pull_request_target]
|
||||
name: Snyk security
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run Snyk to check for vulnerabilities
|
||||
uses: snyk/actions/golang@master
|
||||
env:
|
||||
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
78
.github/workflows/test-arangodb.yml
vendored
78
.github/workflows/test-arangodb.yml
vendored
@@ -1,31 +1,51 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: ArangoDB
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
arangodb:
|
||||
image: 'arangodb:latest'
|
||||
env:
|
||||
ARANGO_NO_AUTH: 1
|
||||
ports:
|
||||
- '8529:8529'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Run Test
|
||||
run: cd ./arangodb && go test ./... -v -race
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
arangodb:
|
||||
image: 'arangodb:latest'
|
||||
env:
|
||||
ARANGO_NO_AUTH: 1
|
||||
ports:
|
||||
- '8529:8529'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./arangodb && go test ./... -v -race
|
||||
|
44
.github/workflows/test-bbolt.yml
vendored
Normal file
44
.github/workflows/test-bbolt.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: Bbolt
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./bbolt && go mod tidy && go test ./... -v -race
|
49
.github/workflows/test-dynamodb.yml
vendored
Normal file
49
.github/workflows/test-dynamodb.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: DynamoDB
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
image: 'amazon/dynamodb-local:latest'
|
||||
ports:
|
||||
- '8000:8000'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./dynamodb && go test ./... -v -race
|
74
.github/workflows/test-memcache.yml
vendored
74
.github/workflows/test-memcache.yml
vendored
@@ -1,29 +1,49 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: Memcache
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
image: 'memcached:latest'
|
||||
ports:
|
||||
- '11211:11211'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Run Test
|
||||
run: cd ./memcache && go test ./... -v -race
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
image: 'memcached:latest'
|
||||
ports:
|
||||
- '11211:11211'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./memcache && go test ./... -v -race
|
||||
|
74
.github/workflows/test-mongodb.yml
vendored
74
.github/workflows/test-mongodb.yml
vendored
@@ -1,29 +1,49 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: MongoDB
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
image: 'mongo:latest'
|
||||
ports:
|
||||
- '27017:27017'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Run Test
|
||||
run: cd ./mongodb && go test ./... -v -race
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
image: 'mongo:latest'
|
||||
ports:
|
||||
- '27017:27017'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./mongodb && go test ./... -v -race
|
||||
|
98
.github/workflows/test-mysql.yml
vendored
98
.github/workflows/test-mysql.yml
vendored
@@ -1,41 +1,61 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: MySQL
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mysql:
|
||||
image: 'mysql:latest'
|
||||
env:
|
||||
MYSQL_DATABASE: fiber
|
||||
MYSQL_USER: username
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
ports:
|
||||
- '3306:3306'
|
||||
options: >-
|
||||
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
|
||||
5s --health-retries 5
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Run Test
|
||||
run: cd ./mysql && go test ./... -v -race
|
||||
env:
|
||||
MYSQL_USERNAME: username
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_DATABASE: fiber
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mysql:
|
||||
image: 'mysql:latest'
|
||||
env:
|
||||
MYSQL_DATABASE: fiber
|
||||
MYSQL_USER: username
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
ports:
|
||||
- '3306:3306'
|
||||
options: >-
|
||||
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
|
||||
5s --health-retries 5
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./mysql && go test ./... -v -race
|
||||
env:
|
||||
MYSQL_USERNAME: username
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_DATABASE: fiber
|
||||
|
96
.github/workflows/test-postgres.yml
vendored
96
.github/workflows/test-postgres.yml
vendored
@@ -1,40 +1,60 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: Postgres
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: 'postgres:latest'
|
||||
ports:
|
||||
- '5432:5432'
|
||||
env:
|
||||
POSTGRES_DB: fiber
|
||||
POSTGRES_USER: username
|
||||
POSTGRES_PASSWORD: password
|
||||
options: >-
|
||||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
|
||||
--health-retries 5
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Run Test
|
||||
run: cd ./postgres && go test ./... -v -race
|
||||
env:
|
||||
POSTGRES_DATABASE: fiber
|
||||
POSTGRES_USERNAME: username
|
||||
POSTGRES_PASSWORD: password
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: 'postgres:latest'
|
||||
ports:
|
||||
- '5432:5432'
|
||||
env:
|
||||
POSTGRES_DB: fiber
|
||||
POSTGRES_USER: username
|
||||
POSTGRES_PASSWORD: password
|
||||
options: >-
|
||||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
|
||||
--health-retries 5
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./postgres && go test ./... -v -race
|
||||
env:
|
||||
POSTGRES_DATABASE: fiber
|
||||
POSTGRES_USERNAME: username
|
||||
POSTGRES_PASSWORD: password
|
||||
|
89
.github/workflows/test-redis.yml
vendored
89
.github/workflows/test-redis.yml
vendored
@@ -1,29 +1,62 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
name: Redis
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: S3
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
redis:
|
||||
image: 'redis:latest'
|
||||
ports:
|
||||
- '6379:6379'
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Run Test
|
||||
run: cd ./redis && go test ./... -v -race
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Redis
|
||||
uses: shogo82148/actions-setup-redis@v1
|
||||
with:
|
||||
redis-version: '6.x'
|
||||
auto-start: 'false'
|
||||
redis-port: '6379'
|
||||
redis-tls-port: '6380'
|
||||
|
||||
- name: Run Redis
|
||||
run: |
|
||||
redis-server --tls-port 6380 --port 6379 \
|
||||
--tls-cert-file ./redis/tests/tls/redis.crt \
|
||||
--tls-key-file ./redis/tests/tls/redis.key \
|
||||
--tls-ca-cert-file ./redis/tests/tls/ca.crt&
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
|
||||
- name: Run Test
|
||||
run: cd ./redis && go test ./... -v -race
|
||||
|
44
.github/workflows/test-ristretto.yml
vendored
Normal file
44
.github/workflows/test-ristretto.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: S3
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./ristretto && go mod tidy && go test ./... -v -race
|
53
.github/workflows/test-s3.yml
vendored
Normal file
53
.github/workflows/test-s3.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: S3
|
||||
jobs:
|
||||
Tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- name: Install MinIO
|
||||
run: |
|
||||
docker run -d -p 9000:9000 --name minio minio/minio server /data
|
||||
|
||||
export AWS_ACCESS_KEY_ID=minioadmin
|
||||
export AWS_SECRET_ACCESS_KEY=minioadmin
|
||||
export AWS_EC2_METADATA_DISABLED=true
|
||||
|
||||
aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://testbucket
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run Test
|
||||
run: cd ./s3 && go test ./... -v -race
|
77
.github/workflows/test.yml
vendored
77
.github/workflows/test.yml
vendored
@@ -1,28 +1,53 @@
|
||||
'on':
|
||||
- push
|
||||
- pull_request
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
name: Local Storage
|
||||
jobs:
|
||||
Tests:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
runs-on: '${{ matrix.platform }}'
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Test Badger
|
||||
run: cd ./badger && go test ./... -v -race
|
||||
- name: Test Memory
|
||||
run: cd ./memory && go test ./... -v -race
|
||||
- name: Test SQLite3
|
||||
run: cd ./sqlite3 && go test ./... -v -race
|
||||
Tests:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version:
|
||||
- 1.14.x
|
||||
- 1.16.x
|
||||
- 1.19.x
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
runs-on: '${{ matrix.platform }}'
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '${{ matrix.go-version }}'
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
# In order:
|
||||
# * Module download cache
|
||||
# * Build cache (Linux)
|
||||
# * Build cache (Mac)
|
||||
# * Build cache (Windows)
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
~/Library/Caches/go-build
|
||||
~\AppData\Local\go-build
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
|
||||
- name: Fetch Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Test Badger
|
||||
run: cd ./badger && go test ./... -v -race
|
||||
- name: Test Memory
|
||||
run: cd ./memory && go test ./... -v -race
|
||||
- name: Test SQLite3 - with -race check
|
||||
if: runner.os != 'Windows'
|
||||
run: cd ./sqlite3 && go test ./... -v -race
|
||||
- name: Test SQLite3 - without -race check
|
||||
if: runner.os == 'Windows'
|
||||
run: cd ./sqlite3 && go test ./... -v
|
||||
|
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
*.tmp
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# IDE files
|
||||
.vscode
|
||||
.DS_Store
|
||||
.idea
|
||||
|
||||
# Misc
|
||||
*.fiber.gz
|
||||
*.fasthttp.gz
|
||||
*.pprof
|
||||
*.workspace
|
||||
|
||||
# Dependencies
|
||||
/vendor/
|
||||
vendor/
|
||||
vendor
|
||||
/Godeps/
|
22
MIGRATE.md
Normal file
22
MIGRATE.md
Normal file
@@ -0,0 +1,22 @@
|
||||
This document contains instructions for migrating to various storage versions.
|
||||
|
||||
### 0.1 -> 0.2
|
||||
v0.2 fixes [a bug](https://github.com/gofiber/fiber/issues/1258) in MYSQL, Postgres and Arangodb in which
|
||||
inserting non-UTF8 characters would trigger a panic due to the values being saved in a TEXT column instead of a
|
||||
BYTEA/BLOB column. Migration instructions (note you may need to adjust the table names if you have supplied a custom
|
||||
config to the storage):
|
||||
|
||||
**Postgres**
|
||||
```sql
|
||||
ALTER TABLE fiber_storage
|
||||
ALTER COLUMN v TYPE BYTEA USING v::bytea;
|
||||
```
|
||||
|
||||
**MYSQL**
|
||||
```sql
|
||||
ALTER TABLE fiber_storage MODIFY COLUMN v BLOB;
|
||||
```
|
||||
|
||||
**Arangodb**
|
||||
|
||||
No migration other then updating the library is necessary.
|
@@ -57,6 +57,9 @@ type Storage interface {
|
||||
* [Badger](/badger) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||
</a>
|
||||
* [Bbolt](/bbolt) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Bbolt%22">
|
||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Bbolt?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||
</a>
|
||||
* [DynamoDB](/dynamodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22DynamoDB%22">
|
||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/DynamoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||
</a>
|
||||
@@ -81,3 +84,6 @@ type Storage interface {
|
||||
* [SQLite3](/sqlite3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||
</a>
|
||||
* [S3](/s3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22S3%22">
|
||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/S3?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||
</a>
|
@@ -16,6 +16,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() driver.Client
|
||||
```
|
||||
### Installation
|
||||
ArangoDB is tested on the 2 last (1.14/1.15) [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
|
@@ -246,3 +246,8 @@ func (s *Storage) gc() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() driver.Client {
|
||||
return s.client
|
||||
}
|
||||
|
@@ -118,6 +118,21 @@ func Test_ARANGODB_Reset(t *testing.T) {
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_ARANGODB_Non_UTF8(t *testing.T) {
|
||||
val := []byte("0xF5")
|
||||
|
||||
err := testStore.Set("0xF6", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get("0xF6")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
}
|
||||
|
||||
func Test_ARANGODB_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_ARANGODB_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
@@ -3,6 +3,6 @@ module github.com/gofiber/storage/arangodb
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/arangodb/go-driver v0.0.0-20201106193344-56ae8fd24510
|
||||
github.com/arangodb/go-driver v1.3.3
|
||||
github.com/gofiber/utils v0.1.2
|
||||
)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
github.com/arangodb/go-driver v0.0.0-20201106193344-56ae8fd24510 h1:jVOBZk8fW8KD22P3jXs1qpxnsGPBVZu2JNrMwJMy67A=
|
||||
github.com/arangodb/go-driver v0.0.0-20201106193344-56ae8fd24510/go.mod h1:aOzPRCCGAYXx/ByHMk+7btStYxcz0rcWBFS4Zp1bpCA=
|
||||
github.com/arangodb/go-driver v1.3.3 h1:UEV74zLYvvAvQgQgNHORdvaADtDX2uTVZH+1H7WAFAQ=
|
||||
github.com/arangodb/go-driver v1.3.3/go.mod h1:5GAx3XvK72DJPhJgyjZOtYAGc4SpY7rZDb3LyhCvLcQ=
|
||||
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g=
|
||||
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
|
||||
github.com/coreos/go-iptables v0.4.3/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
|
||||
@@ -7,10 +7,9 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/google/addlicense v0.0.0-20200817051935-6f4cd4aacc89/go.mod h1:EMjYTRimagHs1FwlIqKyX3wAM0u3rA+McvlIIWmSamA=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@@ -22,26 +21,19 @@ github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJ
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200818005847-188abfa75333/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
3
badger/.gitignore
vendored
Normal file
3
badger/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fiber.badger/
|
||||
fiber.config.badger/
|
||||
fiber.with_options.badger/
|
@@ -3,14 +3,15 @@
|
||||
A fast key-value DB using [dgraph-io/badger](https://github.com/dgraph-io/badger)
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [Signatures](#signatures)
|
||||
- [Installation](#installation)
|
||||
- [Examples](#examples)
|
||||
- [Config](#config)
|
||||
- [Default Config](#default-config)
|
||||
|
||||
|
||||
### Signatures
|
||||
|
||||
```go
|
||||
func New(config ...Config) Storage
|
||||
func (s *Storage) Get(key string) ([]byte, error)
|
||||
@@ -18,25 +19,33 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *badger.DB
|
||||
```
|
||||
|
||||
### Installation
|
||||
|
||||
Badger is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
|
||||
```bash
|
||||
go mod init github.com/<user>/<repo>
|
||||
```
|
||||
|
||||
And then install the badger implementation:
|
||||
|
||||
```bash
|
||||
go get github.com/gofiber/storage/badger
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
Import the storage package.
|
||||
|
||||
```go
|
||||
import "github.com/gofiber/storage/badger"
|
||||
```
|
||||
|
||||
You can use the following possibilities to create a storage:
|
||||
|
||||
```go
|
||||
// Initialize default config
|
||||
store := badger.New()
|
||||
@@ -50,6 +59,7 @@ store := badger.New(badger.Config{
|
||||
```
|
||||
|
||||
### Config
|
||||
|
||||
```go
|
||||
type Config struct {
|
||||
// Database name
|
||||
@@ -66,14 +76,33 @@ type Config struct {
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
|
||||
// BadgerOptions is a way to set options in badger
|
||||
//
|
||||
// Optional. Default is badger.DefaultOptions("./fiber.badger")
|
||||
BadgerOptions badger.Options
|
||||
|
||||
// Logger is the default logger used by badger
|
||||
//
|
||||
// Optional. Default is nil
|
||||
Logger badger.Logger
|
||||
|
||||
// UseLogger define if any logger will be used
|
||||
//
|
||||
// Optional. Default is false
|
||||
UseLogger bool
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
Database: "./fiber.badger",
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
Database: "./fiber.badger",
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
BadgerOptions: badger.DefaultOptions("./fiber.badger").WithLogger(nil),
|
||||
Logger: nil,
|
||||
UseLogger: false,
|
||||
}
|
||||
```
|
||||
|
@@ -3,7 +3,7 @@ package badger
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/dgraph-io/badger"
|
||||
"github.com/dgraph-io/badger/v3"
|
||||
"github.com/gofiber/utils"
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ func New(config ...Config) *Storage {
|
||||
cfg := configDefault(config...)
|
||||
|
||||
// Set options
|
||||
opt := badger.DefaultOptions(cfg.Database).WithTruncate(true).WithLogger(nil)
|
||||
opt := cfg.BadgerOptions
|
||||
|
||||
// Open database
|
||||
db, err := badger.Open(opt)
|
||||
@@ -123,3 +123,8 @@ func (s *Storage) gc() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *badger.DB {
|
||||
return s.db
|
||||
}
|
||||
|
@@ -119,3 +119,7 @@ func Test_Badger_Reset(t *testing.T) {
|
||||
func Test_Badger_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Badger_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
package badger
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"github.com/dgraph-io/badger/v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
@@ -18,13 +21,33 @@ type Config struct {
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
|
||||
// BadgerOptions is a way to set options in badger
|
||||
//
|
||||
// Optional. Default is badger.DefaultOptions("./fiber.badger")
|
||||
BadgerOptions badger.Options
|
||||
|
||||
// Logger is the default logger used by badger
|
||||
//
|
||||
// Optional. Default is nil
|
||||
Logger badger.Logger
|
||||
|
||||
// UseLogger define if any logger will be used
|
||||
//
|
||||
// Optional. Default is false
|
||||
UseLogger bool
|
||||
}
|
||||
|
||||
const defaultDatabase = "./fiber.badger"
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Database: "./fiber.badger",
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
Database: defaultDatabase,
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
BadgerOptions: badger.DefaultOptions(defaultDatabase).WithLogger(nil),
|
||||
Logger: nil,
|
||||
UseLogger: false,
|
||||
}
|
||||
|
||||
// Helper function to set default values
|
||||
@@ -44,5 +67,20 @@ func configDefault(config ...Config) Config {
|
||||
if int(cfg.GCInterval.Seconds()) <= 0 {
|
||||
cfg.GCInterval = ConfigDefault.GCInterval
|
||||
}
|
||||
overrideLogger := false
|
||||
// Detecting if no default Badger option was given
|
||||
// Also detects when a default badger option is given with a custom database name
|
||||
if cfg.BadgerOptions.ValueLogFileSize <= 0 || cfg.BadgerOptions.Dir == "" || cfg.BadgerOptions.ValueDir == "" ||
|
||||
(cfg.BadgerOptions.Dir == defaultDatabase && cfg.BadgerOptions.Dir != cfg.Database) {
|
||||
cfg.BadgerOptions = badger.DefaultOptions(cfg.Database)
|
||||
overrideLogger = true
|
||||
}
|
||||
if overrideLogger {
|
||||
if cfg.UseLogger && cfg.Logger != nil {
|
||||
cfg.BadgerOptions = cfg.BadgerOptions.WithLogger(cfg.Logger)
|
||||
} else if !cfg.UseLogger {
|
||||
cfg.BadgerOptions = cfg.BadgerOptions.WithLogger(nil)
|
||||
}
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
36
badger/config_test.go
Normal file
36
badger/config_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package badger
|
||||
|
||||
import (
|
||||
"github.com/dgraph-io/badger/v3"
|
||||
"github.com/gofiber/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func assertRecoveryPanic(t *testing.T) {
|
||||
err := recover()
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_Badger_Only_Name(t *testing.T) {
|
||||
defer assertRecoveryPanic(t)
|
||||
testDB := New(Config{
|
||||
Database: "fiber.config.badger",
|
||||
UseLogger: false,
|
||||
})
|
||||
utils.AssertEqual(t, nil, testDB.Close())
|
||||
}
|
||||
|
||||
func Test_Badger_Options(t *testing.T) {
|
||||
defer assertRecoveryPanic(t)
|
||||
testDB := New(Config{
|
||||
BadgerOptions: badger.DefaultOptions("fiber.with_options.badger"),
|
||||
UseLogger: false,
|
||||
})
|
||||
utils.AssertEqual(t, nil, testDB.Close())
|
||||
}
|
||||
|
||||
func Test_Empty_Config(t *testing.T) {
|
||||
defer assertRecoveryPanic(t)
|
||||
testDB := New(Config{})
|
||||
utils.AssertEqual(t, nil, testDB.Close())
|
||||
}
|
@@ -3,12 +3,18 @@ module github.com/gofiber/storage/badger
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/dgraph-io/badger v1.6.2
|
||||
github.com/dgraph-io/ristretto v0.0.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgraph-io/badger/v3 v3.2103.2
|
||||
github.com/gofiber/utils v0.1.2
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
|
||||
google.golang.org/protobuf v1.25.0 // indirect
|
||||
github.com/golang/glog v1.0.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/flatbuffers v2.0.5+incompatible // indirect
|
||||
github.com/klauspost/compress v1.13.6 // indirect
|
||||
github.com/kr/pretty v0.2.0 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d // indirect
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
)
|
||||
|
@@ -1,6 +1,4 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
|
||||
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
@@ -8,7 +6,11 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
@@ -16,25 +18,32 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
|
||||
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
|
||||
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
|
||||
github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||
github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI=
|
||||
github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||
github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8=
|
||||
github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M=
|
||||
github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI=
|
||||
github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
|
||||
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
@@ -43,16 +52,34 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||
github.com/google/flatbuffers v2.0.5+incompatible h1:ANsW0idDAXIY+mNHzIHxWRfabV2x5LUEEIIWcwsYgB8=
|
||||
github.com/google/flatbuffers v2.0.5+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -62,8 +89,6 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@@ -81,54 +106,84 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d h1:62NvYBuaanGXR2ZOfwDFkhhl6X1DUgf8qg3GuQvxZsE=
|
||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
@@ -138,8 +193,15 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
93
bbolt/README.md
Normal file
93
bbolt/README.md
Normal file
@@ -0,0 +1,93 @@
|
||||
# Bbolt
|
||||
A Bbolt storage driver using [etcd-io/bbolt](https://github.com/etcd-io/bbolt). Bolt is a pure Go key/value store inspired by [Howard Chu's](https://twitter.com/hyc_symas) [LMDB project](https://www.symas.com/symas-embedded-database-lmdb). The goal of the project is to provide a simple, fast, and reliable database for projects that don't require a full database server such as Postgres or MySQL.
|
||||
|
||||
|
||||
### Table of Contents
|
||||
- [Signatures](#signatures)
|
||||
- [Installation](#installation)
|
||||
- [Examples](#examples)
|
||||
- [Config](#config)
|
||||
- [Default Config](#default-config)
|
||||
|
||||
### Signatures
|
||||
```go
|
||||
func New(config ...Config) Storage
|
||||
func (s *Storage) Get(key string) ([]byte, error)
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *bbolt.DB
|
||||
```
|
||||
### Installation
|
||||
Bbolt is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
```bash
|
||||
go mod init github.com/<user>/<repo>
|
||||
```
|
||||
And then install the s3 implementation:
|
||||
```bash
|
||||
go get github.com/gofiber/storage/bbolt
|
||||
```
|
||||
|
||||
### Examples
|
||||
Import the storage package.
|
||||
```go
|
||||
import "github.com/gofiber/storage/bbolt"
|
||||
```
|
||||
|
||||
You can use the following possibilities to create a storage:
|
||||
```go
|
||||
// Initialize default config
|
||||
store := bbolt.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := bbolt.New(bbolt.Config{
|
||||
Database: "my_database.db",
|
||||
Bucket: "my-bucket",
|
||||
Reset: false,
|
||||
})
|
||||
```
|
||||
|
||||
### Config
|
||||
```go
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Database path
|
||||
//
|
||||
// Optional. Default is "fiber.db"
|
||||
Database string
|
||||
|
||||
// Bbolt bucket name
|
||||
//
|
||||
// Optional. Default is "fiber_storage"
|
||||
Bucket string
|
||||
|
||||
// Timeout is the amount of time to wait to obtain a file lock.
|
||||
// Only available on Darwin and Linux.
|
||||
//
|
||||
// Optional. Default is 60 * time.Second.
|
||||
Timeout time.Duration
|
||||
|
||||
// Open database in read-only mode.
|
||||
//
|
||||
// Optional. Default is false
|
||||
ReadOnly bool
|
||||
|
||||
// Reset clears any existing keys in existing Bucket
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Database: "fiber.db",
|
||||
Bucket: "fiber_storage",
|
||||
Timeout: 60 * time.Second,
|
||||
ReadOnly: false,
|
||||
Reset: false,
|
||||
}
|
||||
```
|
111
bbolt/bbolt.go
Normal file
111
bbolt/bbolt.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package bbolt
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/utils"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
// Storage interface that is implemented by storage providers
|
||||
type Storage struct {
|
||||
conn *bbolt.DB
|
||||
bucket string
|
||||
}
|
||||
|
||||
// New creates a new storage
|
||||
func New(config ...Config) *Storage {
|
||||
// Set default config
|
||||
cfg := configDefault(config...)
|
||||
|
||||
conn, err := bbolt.Open(cfg.Database, 0666, &bbolt.Options{
|
||||
Timeout: cfg.Timeout,
|
||||
ReadOnly: cfg.ReadOnly,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Reset bucket if field selected
|
||||
if cfg.Reset {
|
||||
if err := removeBucket(cfg, conn); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create bucket if not exists
|
||||
if err := createBucket(cfg, conn); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &Storage{
|
||||
conn: conn,
|
||||
bucket: cfg.Bucket,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get value by key
|
||||
func (s *Storage) Get(key string) ([]byte, error) {
|
||||
if len(key) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var value []byte
|
||||
|
||||
err := s.conn.View(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||
value = b.Get(utils.UnsafeBytes(key))
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return value, err
|
||||
}
|
||||
|
||||
// Set key with value
|
||||
func (s *Storage) Set(key string, value []byte, exp time.Duration) error {
|
||||
if len(key) <= 0 || len(value) <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return s.conn.Update(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||
|
||||
return b.Put(utils.UnsafeBytes(key), value)
|
||||
})
|
||||
}
|
||||
|
||||
// Delete entry by key
|
||||
func (s *Storage) Delete(key string) error {
|
||||
if len(key) <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return s.conn.Update(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||
|
||||
return b.Delete(utils.UnsafeBytes(key))
|
||||
})
|
||||
}
|
||||
|
||||
// Reset all entries
|
||||
func (s *Storage) Reset() error {
|
||||
return s.conn.Update(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||
|
||||
return b.ForEach(func(k, _ []byte) error {
|
||||
return b.Delete(k)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Close the database
|
||||
func (s *Storage) Close() error {
|
||||
return s.conn.Close()
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *bbolt.DB {
|
||||
return s.conn
|
||||
}
|
101
bbolt/bbolt_test.go
Normal file
101
bbolt/bbolt_test.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package bbolt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gofiber/utils"
|
||||
)
|
||||
|
||||
var testStore = New()
|
||||
|
||||
func Test_Bbolt_Set(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_Bbolt_Set_Override(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_Bbolt_Get(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
}
|
||||
|
||||
func Test_Bbolt_Get_NotExist(t *testing.T) {
|
||||
|
||||
result, err := testStore.Get("notexist")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Bbolt_Delete(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Delete(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Bbolt_Reset(t *testing.T) {
|
||||
var (
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set("john1", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Set("john2", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Reset()
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get("john1")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
|
||||
result, err = testStore.Get("john2")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Bbolt_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Bbolt_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
63
bbolt/config.go
Normal file
63
bbolt/config.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package bbolt
|
||||
|
||||
import "time"
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Database path
|
||||
//
|
||||
// Optional. Default is "fiber.db"
|
||||
Database string
|
||||
|
||||
// Bbolt bucket name
|
||||
//
|
||||
// Optional. Default is "fiber_storage"
|
||||
Bucket string
|
||||
|
||||
// Timeout is the amount of time to wait to obtain a file lock.
|
||||
// Only available on Darwin and Linux.
|
||||
//
|
||||
// Optional. Default is set to 60 * time.Second.
|
||||
Timeout time.Duration
|
||||
|
||||
// Open database in read-only mode.
|
||||
//
|
||||
// Optional. Default is false
|
||||
ReadOnly bool
|
||||
|
||||
// Reset clears any existing keys in existing Bucket
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
}
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Database: "fiber.db",
|
||||
Bucket: "fiber_storage",
|
||||
Timeout: 60 * time.Second,
|
||||
ReadOnly: false,
|
||||
Reset: false,
|
||||
}
|
||||
|
||||
// Helper function to set default values
|
||||
func configDefault(config ...Config) Config {
|
||||
// Return default config if nothing provided
|
||||
if len(config) < 1 {
|
||||
return ConfigDefault
|
||||
}
|
||||
|
||||
// Override default config
|
||||
cfg := config[0]
|
||||
|
||||
// Set default values
|
||||
if cfg.Database == "" {
|
||||
cfg.Database = ConfigDefault.Database
|
||||
}
|
||||
|
||||
if cfg.Bucket == "" {
|
||||
cfg.Bucket = ConfigDefault.Bucket
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
10
bbolt/go.mod
Normal file
10
bbolt/go.mod
Normal file
@@ -0,0 +1,10 @@
|
||||
module github.com/gofiber/storage/bbolt
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/gofiber/utils v0.1.2
|
||||
go.etcd.io/bbolt v1.3.6
|
||||
)
|
||||
|
||||
require golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a // indirect
|
7
bbolt/go.sum
Normal file
7
bbolt/go.sum
Normal file
@@ -0,0 +1,7 @@
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
|
||||
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
|
||||
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a h1:ppl5mZgokTT8uPkmYOyEUmPTr3ypaKkg5eFOGrAmxxE=
|
||||
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
20
bbolt/utils.go
Normal file
20
bbolt/utils.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package bbolt
|
||||
|
||||
import (
|
||||
"github.com/gofiber/utils"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
func createBucket(cfg Config, conn *bbolt.DB) error {
|
||||
return conn.Update(func(tx *bbolt.Tx) error {
|
||||
_, err := tx.CreateBucketIfNotExists(utils.UnsafeBytes(cfg.Bucket))
|
||||
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func removeBucket(cfg Config, conn *bbolt.DB) error {
|
||||
return conn.Update(func(tx *bbolt.Tx) error {
|
||||
return tx.DeleteBucket(utils.UnsafeBytes(cfg.Bucket))
|
||||
})
|
||||
}
|
@@ -1,4 +1,7 @@
|
||||
# ⚠ DynamoDB is still in development, do not use in production!
|
||||
# DynamoDB
|
||||
A DynamoDB storage driver using [aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2).
|
||||
|
||||
**Note:** If config fields of credentials not given, credentials are using from the environment variables, ~/.aws/credentials, or EC2 instance role. If config fields of credentials given, credentials are using from config. Look at: [specifying credentials](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials)
|
||||
|
||||
....
|
||||
|
||||
@@ -20,6 +23,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *awsdynamodb.Client
|
||||
```
|
||||
|
||||
### Installation
|
||||
@@ -60,28 +64,70 @@ type Config struct {
|
||||
// Optional ("fiber_storage" by default).
|
||||
Table string
|
||||
|
||||
// AWS access key ID (part of the credentials).
|
||||
// Optional (read from shared credentials file or environment variable if not set).
|
||||
// Environment variable: "AWS_ACCESS_KEY_ID".
|
||||
AWSaccessKeyID string
|
||||
|
||||
// AWS secret access key (part of the credentials).
|
||||
// Optional (read from shared credentials file or environment variable if not set).
|
||||
// Environment variable: "AWS_SECRET_ACCESS_KEY".
|
||||
AWSsecretAccessKey string
|
||||
|
||||
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
|
||||
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
|
||||
// Typical value for the Docker container: "http://localhost:8000".
|
||||
// See https://hub.docker.com/r/amazon/dynamodb-local/.
|
||||
// Optional ("" by default)
|
||||
CustomEndpoint string
|
||||
Endpoint string
|
||||
|
||||
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||
//
|
||||
// Optional. Default is Credentials{}
|
||||
Credentials Credentials
|
||||
|
||||
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||
//
|
||||
// Optional. Default is 3
|
||||
MaxAttempts int
|
||||
|
||||
// Reset clears any existing keys in existing Bucket
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// ReadCapacityUnits of the table.
|
||||
// Only required when the table doesn't exist yet and is created by gokv.
|
||||
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
||||
// 25 RCUs are included in the free tier (across all tables).
|
||||
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||
ReadCapacityUnits int64
|
||||
|
||||
// ReadCapacityUnits of the table.
|
||||
// Only required when the table doesn't exist yet and is created by gokv.
|
||||
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
||||
// 25 RCUs are included in the free tier (across all tables).
|
||||
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||
WriteCapacityUnits int64
|
||||
|
||||
// If the table doesn't exist yet, gokv creates it.
|
||||
// If WaitForTableCreation is true, gokv will block until the table is created, with a timeout of 15 seconds.
|
||||
// If the table still doesn't exist after 15 seconds, an error is returned.
|
||||
// If WaitForTableCreation is false, gokv returns the client immediately.
|
||||
// In the latter case you need to make sure that you don't read from or write to the table before it's created,
|
||||
// because otherwise you will get ResourceNotFoundException errors.
|
||||
// Optional (true by default).
|
||||
WaitForTableCreation *bool
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
AccessKey string
|
||||
SecretAccessKey string
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
Table: "fiber_storage",
|
||||
Table: "fiber_storage",
|
||||
Credentials: Credentials{},
|
||||
MaxAttempts: 3,
|
||||
Reset: false,
|
||||
ReadCapacityUnits: 5,
|
||||
WriteCapacityUnits: 5,
|
||||
WaitForTableCreation: aws.Bool(true),
|
||||
}
|
||||
```
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package dynamodb
|
||||
|
||||
import "github.com/aws/aws-sdk-go/aws"
|
||||
import "github.com/aws/aws-sdk-go-v2/aws"
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
@@ -15,22 +15,27 @@ type Config struct {
|
||||
// Optional ("fiber_storage" by default).
|
||||
Table string
|
||||
|
||||
// AWS access key ID (part of the credentials).
|
||||
// Optional (read from shared credentials file or environment variable if not set).
|
||||
// Environment variable: "AWS_ACCESS_KEY_ID".
|
||||
AWSaccessKeyID string
|
||||
|
||||
// AWS secret access key (part of the credentials).
|
||||
// Optional (read from shared credentials file or environment variable if not set).
|
||||
// Environment variable: "AWS_SECRET_ACCESS_KEY".
|
||||
AWSsecretAccessKey string
|
||||
|
||||
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
|
||||
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
|
||||
// Typical value for the Docker container: "http://localhost:8000".
|
||||
// See https://hub.docker.com/r/amazon/dynamodb-local/.
|
||||
// Optional ("" by default)
|
||||
CustomEndpoint string
|
||||
Endpoint string
|
||||
|
||||
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||
//
|
||||
// Optional. Default is Credentials{}
|
||||
Credentials Credentials
|
||||
|
||||
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||
//
|
||||
// Optional. Default is 3
|
||||
MaxAttempts int
|
||||
|
||||
// Reset clears any existing keys in existing Bucket
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// ReadCapacityUnits of the table.
|
||||
// Only required when the table doesn't exist yet and is created by gokv.
|
||||
@@ -38,14 +43,16 @@ type Config struct {
|
||||
// 25 RCUs are included in the free tier (across all tables).
|
||||
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||
readCapacityUnits int64
|
||||
ReadCapacityUnits int64
|
||||
|
||||
// ReadCapacityUnits of the table.
|
||||
// Only required when the table doesn't exist yet and is created by gokv.
|
||||
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
||||
// 25 RCUs are included in the free tier (across all tables).
|
||||
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||
writeCapacityUnits int64
|
||||
WriteCapacityUnits int64
|
||||
|
||||
// If the table doesn't exist yet, gokv creates it.
|
||||
// If WaitForTableCreation is true, gokv will block until the table is created, with a timeout of 15 seconds.
|
||||
// If the table still doesn't exist after 15 seconds, an error is returned.
|
||||
@@ -53,15 +60,23 @@ type Config struct {
|
||||
// In the latter case you need to make sure that you don't read from or write to the table before it's created,
|
||||
// because otherwise you will get ResourceNotFoundException errors.
|
||||
// Optional (true by default).
|
||||
waitForTableCreation *bool
|
||||
WaitForTableCreation *bool
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
AccessKey string
|
||||
SecretAccessKey string
|
||||
}
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Table: "fiber_storage",
|
||||
readCapacityUnits: 5,
|
||||
writeCapacityUnits: 5,
|
||||
waitForTableCreation: aws.Bool(true),
|
||||
Credentials: Credentials{},
|
||||
MaxAttempts: 3,
|
||||
Reset: false,
|
||||
ReadCapacityUnits: 5,
|
||||
WriteCapacityUnits: 5,
|
||||
WaitForTableCreation: aws.Bool(true),
|
||||
}
|
||||
|
||||
// configDefault is a helper function to set default values
|
||||
@@ -78,5 +93,18 @@ func configDefault(config ...Config) Config {
|
||||
if cfg.Table == "" {
|
||||
cfg.Table = ConfigDefault.Table
|
||||
}
|
||||
if cfg.MaxAttempts == 0 {
|
||||
cfg.MaxAttempts = ConfigDefault.MaxAttempts
|
||||
}
|
||||
if cfg.ReadCapacityUnits == 0 {
|
||||
cfg.ReadCapacityUnits = ConfigDefault.ReadCapacityUnits
|
||||
}
|
||||
if cfg.WriteCapacityUnits == 0 {
|
||||
cfg.WriteCapacityUnits = ConfigDefault.WriteCapacityUnits
|
||||
}
|
||||
if cfg.WaitForTableCreation == nil {
|
||||
cfg.WaitForTableCreation = ConfigDefault.WaitForTableCreation
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
@@ -3,90 +3,23 @@ package dynamodb
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
awsdynamodb "github.com/aws/aws-sdk-go/service/dynamodb"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/aws/retry"
|
||||
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
|
||||
awsdynamodb "github.com/aws/aws-sdk-go-v2/service/dynamodb"
|
||||
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
|
||||
)
|
||||
|
||||
// Storage interface that is implemented by storage providers
|
||||
type Storage struct {
|
||||
db *awsdynamodb.DynamoDB
|
||||
table string
|
||||
}
|
||||
|
||||
// New creates a new storage
|
||||
func New(config Config) *Storage {
|
||||
// Set default config
|
||||
cfg := configDefault(config)
|
||||
|
||||
// Create db
|
||||
var creds *credentials.Credentials
|
||||
if (cfg.AWSaccessKeyID != "" && cfg.AWSsecretAccessKey == "") || (cfg.AWSaccessKeyID == "" && cfg.AWSsecretAccessKey != "") {
|
||||
panic("[DynamoDB] You need to set BOTH AWSaccessKeyID AND AWSsecretAccessKey")
|
||||
} else if cfg.AWSaccessKeyID != "" {
|
||||
// Due to the previous check we can be sure that in this case AWSsecretAccessKey is not empty as well.
|
||||
creds = credentials.NewStaticCredentials(cfg.AWSaccessKeyID, cfg.AWSsecretAccessKey, "")
|
||||
}
|
||||
|
||||
// Set database options
|
||||
opt := aws.NewConfig()
|
||||
if cfg.Region != "" {
|
||||
opt = opt.WithRegion(cfg.Region)
|
||||
}
|
||||
if creds != nil {
|
||||
opt = opt.WithCredentials(creds)
|
||||
}
|
||||
if cfg.CustomEndpoint != "" {
|
||||
opt = opt.WithEndpoint(cfg.CustomEndpoint)
|
||||
}
|
||||
|
||||
sessionOpt := session.Options{
|
||||
SharedConfigState: session.SharedConfigEnable,
|
||||
}
|
||||
|
||||
// ...but allow overwrite of region and credentials if they are set in the options.
|
||||
sessionOpt.Config.MergeIn(opt)
|
||||
session, err := session.NewSessionWithOptions(sessionOpt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
svc := awsdynamodb.New(session)
|
||||
|
||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
describeTableInput := awsdynamodb.DescribeTableInput{
|
||||
TableName: &cfg.Table,
|
||||
}
|
||||
|
||||
_, err = svc.DescribeTableWithContext(timeoutCtx, &describeTableInput)
|
||||
if err != nil {
|
||||
awsErr, ok := err.(awserr.Error)
|
||||
if !ok {
|
||||
panic(err)
|
||||
} else if awsErr.Code() == awsdynamodb.ErrCodeResourceNotFoundException {
|
||||
err = createTable(cfg.Table, cfg.readCapacityUnits, cfg.writeCapacityUnits, *cfg.waitForTableCreation, describeTableInput, svc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create storage
|
||||
store := &Storage{
|
||||
db: svc,
|
||||
table: cfg.Table,
|
||||
}
|
||||
|
||||
// Start garbage collector
|
||||
//go store.gc()
|
||||
|
||||
return store
|
||||
db *awsdynamodb.Client
|
||||
table string
|
||||
requestTimeout time.Duration
|
||||
}
|
||||
|
||||
// "k" is used as table column name for the key.
|
||||
@@ -95,126 +28,182 @@ var keyAttrName = "k"
|
||||
// "v" is used as table column name for the value.
|
||||
var valAttrName = "v"
|
||||
|
||||
type table struct {
|
||||
K string
|
||||
V []byte
|
||||
}
|
||||
|
||||
// New creates a new storage
|
||||
func New(config Config) *Storage {
|
||||
// Set default config
|
||||
cfg := configDefault(config)
|
||||
|
||||
awscfg, err := returnAWSConfig(cfg)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("unable to load SDK config, %v", err))
|
||||
}
|
||||
|
||||
// Create db
|
||||
sess := awsdynamodb.NewFromConfig(awscfg)
|
||||
|
||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
describeTableInput := awsdynamodb.DescribeTableInput{
|
||||
TableName: &cfg.Table,
|
||||
}
|
||||
|
||||
// Create storage
|
||||
store := &Storage{
|
||||
db: sess,
|
||||
table: cfg.Table,
|
||||
}
|
||||
|
||||
// Create table
|
||||
_, err = sess.DescribeTable(timeoutCtx, &describeTableInput)
|
||||
if err != nil {
|
||||
var rnfe *types.ResourceNotFoundException
|
||||
if errors.As(err, &rnfe) {
|
||||
err := store.createTable(cfg, describeTableInput)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
// Get value by key
|
||||
func (s *Storage) Get(key string) ([]byte, error) {
|
||||
k := make(map[string]*awsdynamodb.AttributeValue)
|
||||
k[keyAttrName] = &awsdynamodb.AttributeValue{
|
||||
S: &key,
|
||||
ctx, cancel := s.requestContext()
|
||||
defer cancel()
|
||||
|
||||
k := make(map[string]types.AttributeValue)
|
||||
k[keyAttrName] = &types.AttributeValueMemberS{
|
||||
Value: key,
|
||||
}
|
||||
getItemInput := awsdynamodb.GetItemInput{
|
||||
TableName: &s.table,
|
||||
Key: k,
|
||||
}
|
||||
getItemOutput, err := s.db.GetItem(&getItemInput)
|
||||
getItemOutput, err := s.db.GetItem(ctx, &getItemInput)
|
||||
if err != nil {
|
||||
var rnfe *types.ResourceNotFoundException
|
||||
if errors.As(err, &rnfe) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
} else if getItemOutput.Item == nil {
|
||||
return nil, nil
|
||||
}
|
||||
attributeVal := getItemOutput.Item[valAttrName]
|
||||
if attributeVal == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return attributeVal.B, nil
|
||||
|
||||
item := &table{}
|
||||
err = attributevalue.UnmarshalMap(getItemOutput.Item, &item)
|
||||
|
||||
return item.V, err
|
||||
}
|
||||
|
||||
// Set key with value
|
||||
// Set key with value
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
ctx, cancel := s.requestContext()
|
||||
defer cancel()
|
||||
|
||||
// Ain't Nobody Got Time For That
|
||||
if len(key) <= 0 || len(val) <= 0 {
|
||||
return nil
|
||||
}
|
||||
item := make(map[string]*awsdynamodb.AttributeValue)
|
||||
item[keyAttrName] = &awsdynamodb.AttributeValue{
|
||||
S: &key,
|
||||
|
||||
item := make(map[string]types.AttributeValue)
|
||||
item[keyAttrName] = &types.AttributeValueMemberS{
|
||||
Value: key,
|
||||
}
|
||||
item[valAttrName] = &awsdynamodb.AttributeValue{
|
||||
B: val,
|
||||
item[valAttrName] = &types.AttributeValueMemberB{
|
||||
Value: val,
|
||||
}
|
||||
putItemInput := awsdynamodb.PutItemInput{
|
||||
TableName: &s.table,
|
||||
Item: item,
|
||||
}
|
||||
_, err := s.db.PutItem(&putItemInput)
|
||||
|
||||
_, err := s.db.PutItem(ctx, &putItemInput)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete entry by key
|
||||
func (s *Storage) Delete(key string) error {
|
||||
ctx, cancel := s.requestContext()
|
||||
defer cancel()
|
||||
|
||||
// Ain't Nobody Got Time For That
|
||||
if len(key) <= 0 {
|
||||
return nil
|
||||
}
|
||||
k := make(map[string]*awsdynamodb.AttributeValue)
|
||||
k[keyAttrName] = &awsdynamodb.AttributeValue{
|
||||
S: &key,
|
||||
|
||||
k := make(map[string]types.AttributeValue)
|
||||
k[keyAttrName] = &types.AttributeValueMemberS{
|
||||
Value: key,
|
||||
}
|
||||
deleteItemInput := awsdynamodb.DeleteItemInput{
|
||||
TableName: &s.table,
|
||||
Key: k,
|
||||
}
|
||||
_, err := s.db.DeleteItem(&deleteItemInput)
|
||||
|
||||
_, err := s.db.DeleteItem(ctx, &deleteItemInput)
|
||||
return err
|
||||
}
|
||||
|
||||
// Reset all entries, including unexpired
|
||||
func (s *Storage) Reset() error {
|
||||
ctx, cancel := s.requestContext()
|
||||
defer cancel()
|
||||
|
||||
deleteTableInput := awsdynamodb.DeleteTableInput{
|
||||
TableName: &s.table,
|
||||
}
|
||||
_, err := s.db.DeleteTable(&deleteTableInput)
|
||||
_, err := s.db.DeleteTable(ctx, &deleteTableInput)
|
||||
return err
|
||||
}
|
||||
|
||||
// Close the database
|
||||
func (s *Storage) Close() error {
|
||||
// In the DynamoDB implementation this doesn't have any effect.
|
||||
return nil
|
||||
}
|
||||
|
||||
// GC deletes all expired entries
|
||||
// func (s *Storage) gc() {
|
||||
// ticker := time.NewTicker(s.gcInterval)
|
||||
// defer ticker.Stop()
|
||||
// for {
|
||||
// select {
|
||||
// case <-s.done:
|
||||
// return
|
||||
// case t := <-ticker.C:
|
||||
// _, _ = s.db.Exec(s.sqlGC, t.Unix())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
func (s *Storage) createTable(cfg Config, describeTableInput awsdynamodb.DescribeTableInput) error {
|
||||
ctx, cancel := s.requestContext()
|
||||
defer cancel()
|
||||
|
||||
func createTable(tableName string, readCapacityUnits, writeCapacityUnits int64, waitForTableCreation bool, describeTableInput awsdynamodb.DescribeTableInput, svc *awsdynamodb.DynamoDB) error {
|
||||
keyAttrType := "S" // For "string"
|
||||
keyType := "HASH" // As opposed to "RANGE"
|
||||
|
||||
createTableInput := awsdynamodb.CreateTableInput{
|
||||
TableName: &tableName,
|
||||
AttributeDefinitions: []*awsdynamodb.AttributeDefinition{{
|
||||
TableName: &s.table,
|
||||
AttributeDefinitions: []types.AttributeDefinition{{
|
||||
AttributeName: &keyAttrName,
|
||||
AttributeType: &keyAttrType,
|
||||
AttributeType: types.ScalarAttributeType(keyAttrType),
|
||||
}},
|
||||
KeySchema: []*awsdynamodb.KeySchemaElement{{
|
||||
KeySchema: []types.KeySchemaElement{{
|
||||
AttributeName: &keyAttrName,
|
||||
KeyType: &keyType,
|
||||
KeyType: types.KeyType(keyType),
|
||||
}},
|
||||
ProvisionedThroughput: &awsdynamodb.ProvisionedThroughput{
|
||||
ReadCapacityUnits: &readCapacityUnits,
|
||||
WriteCapacityUnits: &writeCapacityUnits,
|
||||
ProvisionedThroughput: &types.ProvisionedThroughput{
|
||||
ReadCapacityUnits: &cfg.ReadCapacityUnits,
|
||||
WriteCapacityUnits: &cfg.WriteCapacityUnits,
|
||||
},
|
||||
}
|
||||
_, err := svc.CreateTable(&createTableInput)
|
||||
_, err := s.db.CreateTable(ctx, &createTableInput)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// If configured (true by default), block until the table is created.
|
||||
// Typical table creation duration is 10 seconds.
|
||||
if waitForTableCreation {
|
||||
if *cfg.WaitForTableCreation {
|
||||
for try := 1; try < 16; try++ {
|
||||
describeTableOutput, err := svc.DescribeTable(&describeTableInput)
|
||||
if err != nil || *describeTableOutput.Table.TableStatus == "CREATING" {
|
||||
describeTableOutput, err := s.db.DescribeTable(ctx, &describeTableInput)
|
||||
if err != nil || describeTableOutput.Table.TableStatus == "CREATING" {
|
||||
time.Sleep(1 * time.Second)
|
||||
} else {
|
||||
break
|
||||
@@ -222,14 +211,61 @@ func createTable(tableName string, readCapacityUnits, writeCapacityUnits int64,
|
||||
}
|
||||
// Last try (16th) after 15 seconds of waiting.
|
||||
// Now handle error as such.
|
||||
describeTableOutput, err := svc.DescribeTable(&describeTableInput)
|
||||
describeTableOutput, err := s.db.DescribeTable(ctx, &describeTableInput)
|
||||
if err != nil {
|
||||
return errors.New("The DynamoDB table couldn't be created")
|
||||
return errors.New("dynamodb: the table couldn't be created")
|
||||
}
|
||||
if *describeTableOutput.Table.TableStatus == "CREATING" {
|
||||
return errors.New("The DynamoDB table took too long to be created")
|
||||
if describeTableOutput.Table.TableStatus == "CREATING" {
|
||||
return errors.New("dynamodb: the table took too long to be created")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Context for making requests will timeout if a non-zero timeout is configured
|
||||
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
||||
if s.requestTimeout > 0 {
|
||||
return context.WithTimeout(context.Background(), s.requestTimeout)
|
||||
}
|
||||
return context.Background(), func() {}
|
||||
}
|
||||
|
||||
func returnAWSConfig(cfg Config) (aws.Config, error) {
|
||||
endpoint := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
||||
if cfg.Endpoint != "" {
|
||||
return aws.Endpoint{
|
||||
PartitionID: "aws",
|
||||
URL: cfg.Endpoint,
|
||||
SigningRegion: cfg.Region,
|
||||
HostnameImmutable: true,
|
||||
}, nil
|
||||
}
|
||||
return aws.Endpoint{}, &aws.EndpointNotFoundError{}
|
||||
})
|
||||
|
||||
if cfg.Credentials != (Credentials{}) {
|
||||
credentials := credentials.NewStaticCredentialsProvider(cfg.Credentials.AccessKey, cfg.Credentials.SecretAccessKey, "")
|
||||
return awsconfig.LoadDefaultConfig(context.TODO(),
|
||||
awsconfig.WithRegion(cfg.Region),
|
||||
awsconfig.WithEndpointResolverWithOptions(endpoint),
|
||||
awsconfig.WithCredentialsProvider(credentials),
|
||||
awsconfig.WithRetryer(func() aws.Retryer {
|
||||
return retry.AddWithMaxAttempts(retry.NewStandard(), cfg.MaxAttempts)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
return awsconfig.LoadDefaultConfig(context.TODO(),
|
||||
awsconfig.WithRegion(cfg.Region),
|
||||
awsconfig.WithEndpointResolverWithOptions(endpoint),
|
||||
awsconfig.WithRetryer(func() aws.Retryer {
|
||||
return retry.AddWithMaxAttempts(retry.NewStandard(), cfg.MaxAttempts)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *awsdynamodb.Client {
|
||||
return s.db
|
||||
}
|
||||
|
@@ -1 +1,111 @@
|
||||
package dynamodb
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gofiber/utils"
|
||||
)
|
||||
|
||||
var testStore = New(
|
||||
Config{
|
||||
Table: "fiber_storage",
|
||||
Endpoint: "http://localhost:8000/",
|
||||
Region: "us-east-1",
|
||||
Credentials: Credentials{
|
||||
AccessKey: "dummy",
|
||||
SecretAccessKey: "dummy",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
func Test_DynamoDB_Set(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Set_Override(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Get(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Get_NotExist(t *testing.T) {
|
||||
|
||||
result, err := testStore.Get("notexist")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Delete(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Delete(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Reset(t *testing.T) {
|
||||
var (
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set("john1", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Set("john2", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Reset()
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get("john1")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
|
||||
result, err = testStore.Get("john2")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_DynamoDB_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
@@ -2,4 +2,11 @@ module github.com/gofiber/storage/dynamodb
|
||||
|
||||
go 1.14
|
||||
|
||||
require github.com/aws/aws-sdk-go v1.38.3
|
||||
require (
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.14
|
||||
github.com/aws/aws-sdk-go-v2/config v1.17.5
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.18
|
||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.16
|
||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.16.4
|
||||
github.com/gofiber/utils v0.1.2
|
||||
)
|
||||
|
@@ -1,27 +1,50 @@
|
||||
github.com/aws/aws-sdk-go v1.38.3 h1:QCL/le04oAz2jELMRSuJVjGT7H+4hhoQc66eMPCfU/k=
|
||||
github.com/aws/aws-sdk-go v1.38.3/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.14 h1:db6GvO4Z2UqHt5gvT0lr6J5x5P+oQ7bdRzczVaRekMU=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.14/go.mod h1:s/G+UV29dECbF5rf+RNj1xhlmvoNurGSr+McVSRj59w=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.17.5 h1:+NS1BWvprx7nHcIk5o32LrZgifs/7Pm1V2nWjQgZ2H0=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.17.5/go.mod h1:H0cvPNDO3uExWts/9PDhD/0ne2esu1uaIulwn1vkwxM=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.18 h1:HF62tbhARhgLfvmfwUbL9qZ+dkbZYzbFdxBb3l5gr7Q=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.18/go.mod h1:O7n/CPagQ33rfG6h7vR/W02ammuc5CrsSM22cNZp9so=
|
||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.16 h1:bm0AJ3XXZMUgtQnIWd/ICwno6rpSt3RGFPcNj+yEd8s=
|
||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.16/go.mod h1:oChsFs0jCKdGVvFGD6gwPKTxrD7nEGX4C1ZevitspEo=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15 h1:nkQ+aI0OCeYfzrBipL6ja/6VEbUnHQoZHBHtoK+Nzxw=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15/go.mod h1:Oz2/qWINxIgSmoZT9adpxJy2UhpcOAI3TIyWgYMVSz0=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21 h1:gRIXnmAVNyoRQywdNtpAkgY+f30QNzgF53Q5OobNZZs=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21/go.mod h1:XsmHMV9c512xgsW01q7H0ut+UQQQpWX8QsFbdLHDwaU=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15 h1:noAhOo2mMDyYhTx99aYPvQw16T3fQ/DiKAv9fzpIKH8=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15/go.mod h1:kjJ4CyD9M3Wq88GYg3IPfj67Rs0Uvz8aXK7MJ8BvE4I=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22 h1:nF+E8HfYpOMw6M5oA9efB602VC00IHNQnB5CmFvZPvA=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22/go.mod h1:tltHVGy977LrSOgRR5aV9+miyno/Gul/uJNPKS7FzP4=
|
||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.16.4 h1:mAZdz3kvGBWC0feqQcpUF9trQ0d1qmJVNrcUv6eneIo=
|
||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.16.4/go.mod h1:xDs8FfL3lHGCYWb0ytqxjIKT5AYLY/Oi9Mh8BV0nkLg=
|
||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.18 h1:LxbyLA3QSk3OiIstssH/9YYKABi2p++GSHXuUVe9/uU=
|
||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.18/go.mod h1:GD6ADXrQblUCuTnIjApbCXztFPMMzaOlYwQY7z40io4=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8 h1:NpixDFjwr1BZg2459mX07NZnVYGGp62Lb6AtVGOLNlo=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8/go.mod h1:MJUgrBPfGB4yk2uWoImVqd9cklry1hATyJV/7gJ6JTk=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.15 h1:cglph/vzXji9hnXhlWq2bVkPU0qofeOCV/Jv7AWGEh4=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.15/go.mod h1:NNBwPIB0wjkpeeQztU3FRD8O8T77MCrObyC1RiHf6G8=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15 h1:xlf0J6DUgAj/ocvKQxCmad8Bu1lJuRbt5Wu+4G1xw1g=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15/go.mod h1:ZVJ7ejRl4+tkWMuCwjXoy0jd8fF5u3RCyWjSVjUIvQE=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.21 h1:7jUFr+7F4MzIjCZzy7ygRtXFQcQ0kAbT0gUvtUeAdyU=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.21/go.mod h1:q8nYq51W3gpZempYsAD83fPRlrOTMCwN+Ahg4BKFTXQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3 h1:UTTPNP3/WzZa7hoHP3Szb/Yl0bM3NoBrf5ABy1OArUM=
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3/go.mod h1:+IF75RMJh0+zqTGXGshyEGRsU2ImqWv6UuHGkHl6kEo=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.17 h1:LVM2jzEQ8mhb2dhrFl4PJ3sa5+KcKT01dsMk2Ma9/FU=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.17/go.mod h1:bQujK1n0V1D1Gz5uII1jaB1WDvhj4/T3tElsJnVXCR0=
|
||||
github.com/aws/smithy-go v1.13.2 h1:TBLKyeJfXTrTXRHmsv4qWt9IQGYyWThLYaJWSahTOGE=
|
||||
github.com/aws/smithy-go v1.13.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *mc.Client
|
||||
```
|
||||
|
||||
### Installation
|
||||
|
@@ -3,6 +3,6 @@ module github.com/gofiber/storage/memcache
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
|
||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d
|
||||
github.com/gofiber/utils v0.1.2
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pOvUGt1D1lA5KjYhPBAN/3iWdP7xeFS9F0=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
|
@@ -122,3 +122,8 @@ func (s *Storage) releaseItem(item *mc.Item) {
|
||||
s.items.Put(item)
|
||||
}
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *mc.Client {
|
||||
return s.db
|
||||
}
|
||||
|
@@ -119,3 +119,7 @@ func Test_Memcache_Reset(t *testing.T) {
|
||||
func Test_Memcache_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Memcache_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() map[string]entry
|
||||
```
|
||||
|
||||
### Installation
|
||||
|
@@ -116,3 +116,8 @@ func (s *Storage) gc() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() map[string]entry {
|
||||
return s.db
|
||||
}
|
||||
|
@@ -119,3 +119,7 @@ func Test_Memory_Reset(t *testing.T) {
|
||||
func Test_Memory_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Memory_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *mongo.Database
|
||||
```
|
||||
### Installation
|
||||
MongoDB is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
|
@@ -3,12 +3,8 @@ module github.com/gofiber/storage/mongodb
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.35.33 // indirect
|
||||
github.com/gofiber/utils v0.1.2
|
||||
github.com/golang/snappy v0.0.2 // indirect
|
||||
github.com/klauspost/compress v1.11.3 // indirect
|
||||
go.mongodb.org/mongo-driver v1.5.0
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
|
||||
golang.org/x/text v0.3.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||
go.mongodb.org/mongo-driver v1.10.2
|
||||
)
|
||||
|
132
mongodb/go.sum
132
mongodb/go.sum
@@ -1,140 +1,66 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
|
||||
github.com/aws/aws-sdk-go v1.35.33 h1:8qPRZqCRok5i7VNN51k/Ky7CuyoXMdSs4mUfKyCqvPw=
|
||||
github.com/aws/aws-sdk-go v1.35.33/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
|
||||
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
|
||||
github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
|
||||
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs=
|
||||
github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
|
||||
github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
|
||||
github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
|
||||
github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28=
|
||||
github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo=
|
||||
github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk=
|
||||
github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
|
||||
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
|
||||
github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg=
|
||||
github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE=
|
||||
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
|
||||
github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
|
||||
github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
|
||||
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
|
||||
github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
|
||||
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
|
||||
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
|
||||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw=
|
||||
github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
|
||||
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc=
|
||||
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
|
||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
|
||||
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc h1:n+nNi93yXLkJvKwXNP9d55HC7lGK4H/SRcwB5IaUZLo=
|
||||
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
|
||||
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
|
||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
go.mongodb.org/mongo-driver v1.5.0 h1:REddm85e1Nl0JPXGGhgZkgJdG/yOe6xvpXUcYK5WLt0=
|
||||
go.mongodb.org/mongo-driver v1.5.0/go.mod h1:boiGPFqyBs5R0R5qf2ErokGRekMfwn+MqKaUyHs7wy0=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
||||
go.mongodb.org/mongo-driver v1.10.2 h1:4Wk3cnqOrQCn0P92L3/mmurMxzdvWWs5J9jinAVKD+k=
|
||||
go.mongodb.org/mongo-driver v1.10.2/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 h1:phUcVbl53swtrUN8kQEXFhUxPlIlWyBfKmidCu7P95o=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@@ -199,3 +199,8 @@ func (s *Storage) releaseItem(item *item) {
|
||||
s.items.Put(item)
|
||||
}
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *mongo.Database {
|
||||
return s.db
|
||||
}
|
||||
|
@@ -121,3 +121,7 @@ func Test_MongoDB_Reset(t *testing.T) {
|
||||
func Test_MongoDB_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_MongoDB_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *sql.DB
|
||||
```
|
||||
### Installation
|
||||
MySQL is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
@@ -48,11 +49,23 @@ store := mysql.New(mysql.Config{
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
|
||||
// Initialize custom config using connection string
|
||||
store := postgres.New(postgres.Config{
|
||||
ConnectionURI: "mysql://user:password@localhost:3306/fiber"
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
```
|
||||
|
||||
### Config
|
||||
```go
|
||||
type Config struct {
|
||||
// Connection string to use for DB. Will override all other authentication values if used
|
||||
//
|
||||
// Optional. Default is ""
|
||||
ConnectionURI string
|
||||
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// Optional. Default is "127.0.0.1"
|
||||
@@ -98,6 +111,7 @@ type Config struct {
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
ConnectionURI: "",
|
||||
Host: "127.0.0.1",
|
||||
Port: 3306,
|
||||
Database: "fiber",
|
||||
|
@@ -7,6 +7,11 @@ import (
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Connection string to use for DB. Will override all other authentication values if used
|
||||
//
|
||||
// Optional. Default is ""
|
||||
ConnectionURI string
|
||||
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// Optional. Default is "127.0.0.1"
|
||||
@@ -58,6 +63,7 @@ type Config struct {
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
ConnectionURI: "",
|
||||
Host: "127.0.0.1",
|
||||
Port: 3306,
|
||||
Database: "fiber",
|
||||
@@ -70,6 +76,9 @@ var ConfigDefault = Config{
|
||||
}
|
||||
|
||||
func (c Config) dsn() string {
|
||||
if c.ConnectionURI != "" {
|
||||
return c.ConnectionURI
|
||||
}
|
||||
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", c.Username, c.Password, c.Host, c.Port, c.Database)
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,6 @@ module github.com/gofiber/storage/mysql
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/gofiber/utils v0.1.2
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
|
@@ -3,10 +3,10 @@ package mysql
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/gofiber/utils"
|
||||
)
|
||||
|
||||
// Storage interface that is implemented by storage providers
|
||||
@@ -23,15 +23,19 @@ type Storage struct {
|
||||
}
|
||||
|
||||
var (
|
||||
checkSchemaMsg = "The `v` row has an incorrect data type. " +
|
||||
"It should be BLOB but is instead %s. This will cause encoding-related panics if the DB is not migrated (see https://github.com/gofiber/storage/blob/main/MIGRATE.md)."
|
||||
dropQuery = "DROP TABLE IF EXISTS %s;"
|
||||
initQuery = []string{
|
||||
`CREATE TABLE IF NOT EXISTS %s (
|
||||
k VARCHAR(64) NOT NULL DEFAULT '',
|
||||
v TEXT NOT NULL,
|
||||
v BLOB NOT NULL,
|
||||
e BIGINT NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (k)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
|
||||
}
|
||||
checkSchemaQuery = `SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '%s' AND COLUMN_NAME = 'v';`
|
||||
)
|
||||
|
||||
// New creates a new storage
|
||||
@@ -81,10 +85,12 @@ func New(config ...Config) *Storage {
|
||||
sqlSelect: fmt.Sprintf("SELECT v, e FROM %s WHERE k=?;", cfg.Table),
|
||||
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES (?,?,?) ON DUPLICATE KEY UPDATE v = ?, e = ?", cfg.Table),
|
||||
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=?", cfg.Table),
|
||||
sqlReset: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
|
||||
sqlReset: fmt.Sprintf("TRUNCATE TABLE %s;", cfg.Table),
|
||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= ? AND e != 0", cfg.Table),
|
||||
}
|
||||
|
||||
store.checkSchema(cfg.Table)
|
||||
|
||||
// Start garbage collector
|
||||
go store.gcTicker()
|
||||
|
||||
@@ -133,8 +139,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
if exp != 0 {
|
||||
expSeconds = time.Now().Add(exp).Unix()
|
||||
}
|
||||
valStr := utils.UnsafeString(val)
|
||||
_, err := s.db.Exec(s.sqlInsert, key, valStr, expSeconds, valStr, expSeconds)
|
||||
_, err := s.db.Exec(s.sqlInsert, key, val, expSeconds, val, expSeconds)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -160,6 +165,11 @@ func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *sql.DB {
|
||||
return s.db
|
||||
}
|
||||
|
||||
// gcTicker starts the gc ticker
|
||||
func (s *Storage) gcTicker() {
|
||||
ticker := time.NewTicker(s.gcInterval)
|
||||
@@ -178,3 +188,16 @@ func (s *Storage) gcTicker() {
|
||||
func (s *Storage) gc(t time.Time) {
|
||||
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
||||
}
|
||||
|
||||
func (s *Storage) checkSchema(tableName string) {
|
||||
var data []byte
|
||||
|
||||
row := s.db.QueryRow(fmt.Sprintf(checkSchemaQuery, tableName))
|
||||
if err := row.Scan(&data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if strings.ToLower(string(data)) != "blob" {
|
||||
fmt.Printf(checkSchemaMsg, string(data))
|
||||
}
|
||||
}
|
||||
|
@@ -148,6 +148,21 @@ func Test_MYSQL_GC(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func Test_MYSQL_Non_UTF8(t *testing.T) {
|
||||
val := []byte("0xF5")
|
||||
|
||||
err := testStore.Set("0xF6", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get("0xF6")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
}
|
||||
|
||||
func Test_MYSQL_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_MYSQL_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *sql.DB
|
||||
```
|
||||
### Installation
|
||||
Postgres is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
@@ -47,6 +48,14 @@ store := postgres.New(postgres.Config{
|
||||
Table: "fiber_storage",
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
SslMode: "disable",
|
||||
})
|
||||
|
||||
// Initialize custom config using connection string
|
||||
store := postgres.New(postgres.Config{
|
||||
ConnectionURI: "postgresql://user:password@localhost:5432/fiber"
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
})
|
||||
```
|
||||
|
||||
@@ -54,6 +63,11 @@ store := postgres.New(postgres.Config{
|
||||
```go
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Connection string to use for DB. Will override all other authentication values if used
|
||||
//
|
||||
// Optional. Default is ""
|
||||
ConnectionURI string
|
||||
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// Optional. Default is "127.0.0.1"
|
||||
@@ -93,17 +107,24 @@ type Config struct {
|
||||
//
|
||||
// Optional. Default is 10 * time.Second
|
||||
GCInterval time.Duration
|
||||
|
||||
// The SSL mode for the connection
|
||||
//
|
||||
// Optional. Default is "disable"
|
||||
SslMode string
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
ConnectionURI: "",
|
||||
Host: "127.0.0.1",
|
||||
Port: 5432,
|
||||
Database: "fiber",
|
||||
Table: "fiber_storage",
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
SslMode: "disable",
|
||||
}
|
||||
```
|
||||
|
@@ -6,6 +6,11 @@ import (
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Connection string to use for DB. Will override all other authentication values if used
|
||||
//
|
||||
// Optional. Default is ""
|
||||
ConnectionURI string
|
||||
|
||||
// Host name where the DB is hosted
|
||||
//
|
||||
// Optional. Default is "127.0.0.1"
|
||||
@@ -36,6 +41,11 @@ type Config struct {
|
||||
// Optional. Default is "fiber_storage"
|
||||
Table string
|
||||
|
||||
// The SSL mode for the connection
|
||||
//
|
||||
// Optional. Default is "disable"
|
||||
SslMode string
|
||||
|
||||
// Reset clears any existing keys in existing Table
|
||||
//
|
||||
// Optional. Default is false
|
||||
@@ -85,10 +95,12 @@ type Config struct {
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
ConnectionURI: "",
|
||||
Host: "127.0.0.1",
|
||||
Port: 5432,
|
||||
Database: "fiber",
|
||||
Table: "fiber_storage",
|
||||
SslMode: "disable",
|
||||
Reset: false,
|
||||
GCInterval: 10 * time.Second,
|
||||
maxOpenConns: 100,
|
||||
@@ -119,6 +131,9 @@ func configDefault(config ...Config) Config {
|
||||
if cfg.Table == "" {
|
||||
cfg.Table = ConfigDefault.Table
|
||||
}
|
||||
if cfg.SslMode == "" {
|
||||
cfg.SslMode = ConfigDefault.SslMode
|
||||
}
|
||||
if int(cfg.GCInterval.Seconds()) <= 0 {
|
||||
cfg.GCInterval = ConfigDefault.GCInterval
|
||||
}
|
||||
|
@@ -4,5 +4,5 @@ go 1.14
|
||||
|
||||
require (
|
||||
github.com/gofiber/utils v0.1.2
|
||||
github.com/lib/pq v1.10.0
|
||||
github.com/lib/pq v1.10.7
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
|
||||
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
|
@@ -5,9 +5,9 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/utils"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
@@ -25,15 +25,19 @@ type Storage struct {
|
||||
}
|
||||
|
||||
var (
|
||||
checkSchemaMsg = "The `v` row has an incorrect data type. " +
|
||||
"It should be BYTEA but is instead %s. This will cause encoding-related panics if the DB is not migrated (see https://github.com/gofiber/storage/blob/main/MIGRATE.md)."
|
||||
dropQuery = `DROP TABLE IF EXISTS %s;`
|
||||
initQuery = []string{
|
||||
`CREATE TABLE IF NOT EXISTS %s (
|
||||
k VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT '',
|
||||
v TEXT NOT NULL,
|
||||
v BYTEA NOT NULL,
|
||||
e BIGINT NOT NULL DEFAULT '0'
|
||||
);`,
|
||||
`CREATE INDEX IF NOT EXISTS e ON %s (e);`,
|
||||
}
|
||||
checkSchemaQuery = `SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '%s' AND COLUMN_NAME = 'v';`
|
||||
)
|
||||
|
||||
// New creates a new storage
|
||||
@@ -42,21 +46,31 @@ func New(config ...Config) *Storage {
|
||||
cfg := configDefault(config...)
|
||||
|
||||
// Create data source name
|
||||
var dsn string = "postgresql://"
|
||||
if cfg.Username != "" {
|
||||
dsn += url.QueryEscape(cfg.Username)
|
||||
var dsn string
|
||||
if cfg.ConnectionURI != "" {
|
||||
dsn = cfg.ConnectionURI
|
||||
} else {
|
||||
dsn = "postgresql://"
|
||||
if cfg.Username != "" {
|
||||
dsn += url.QueryEscape(cfg.Username)
|
||||
}
|
||||
if cfg.Password != "" {
|
||||
dsn += ":" + cfg.Password
|
||||
}
|
||||
if cfg.Username != "" || cfg.Password != "" {
|
||||
dsn += "@"
|
||||
}
|
||||
// unix socket host path
|
||||
if strings.HasPrefix(cfg.Host, "/") {
|
||||
dsn += fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)
|
||||
} else {
|
||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||
}
|
||||
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=%s",
|
||||
url.QueryEscape(cfg.Database),
|
||||
int64(cfg.timeout.Seconds()),
|
||||
cfg.SslMode)
|
||||
}
|
||||
if cfg.Password != "" {
|
||||
dsn += ":" + cfg.Password
|
||||
}
|
||||
if cfg.Username != "" || cfg.Password != "" {
|
||||
dsn += "@"
|
||||
}
|
||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=disable",
|
||||
url.QueryEscape(cfg.Database),
|
||||
int64(cfg.timeout.Seconds()),
|
||||
)
|
||||
|
||||
// Create db
|
||||
db, err := sql.Open("postgres", dsn)
|
||||
@@ -99,10 +113,12 @@ func New(config ...Config) *Storage {
|
||||
sqlSelect: fmt.Sprintf(`SELECT v, e FROM %s WHERE k=$1;`, cfg.Table),
|
||||
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES ($1, $2, $3) ON CONFLICT (k) DO UPDATE SET v = $4, e = $5", cfg.Table),
|
||||
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=$1", cfg.Table),
|
||||
sqlReset: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
|
||||
sqlReset: fmt.Sprintf("TRUNCATE TABLE %s;", cfg.Table),
|
||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= $1 AND e != 0", cfg.Table),
|
||||
}
|
||||
|
||||
store.checkSchema(cfg.Table)
|
||||
|
||||
// Start garbage collector
|
||||
go store.gcTicker()
|
||||
|
||||
@@ -137,7 +153,6 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// Set key with value
|
||||
// Set key with value
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
// Ain't Nobody Got Time For That
|
||||
@@ -148,8 +163,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
if exp != 0 {
|
||||
expSeconds = time.Now().Add(exp).Unix()
|
||||
}
|
||||
valStr := utils.UnsafeString(val)
|
||||
_, err := s.db.Exec(s.sqlInsert, key, valStr, expSeconds, valStr, expSeconds)
|
||||
_, err := s.db.Exec(s.sqlInsert, key, val, expSeconds, val, expSeconds)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -175,6 +189,11 @@ func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *sql.DB {
|
||||
return s.db
|
||||
}
|
||||
|
||||
// gcTicker starts the gc ticker
|
||||
func (s *Storage) gcTicker() {
|
||||
ticker := time.NewTicker(s.gcInterval)
|
||||
@@ -193,3 +212,16 @@ func (s *Storage) gcTicker() {
|
||||
func (s *Storage) gc(t time.Time) {
|
||||
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
||||
}
|
||||
|
||||
func (s *Storage) checkSchema(tableName string) {
|
||||
var data []byte
|
||||
|
||||
row := s.db.QueryRow(fmt.Sprintf(checkSchemaQuery, tableName))
|
||||
if err := row.Scan(&data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if strings.ToLower(string(data)) != "bytea" {
|
||||
fmt.Printf(checkSchemaMsg, string(data))
|
||||
}
|
||||
}
|
||||
|
@@ -148,6 +148,36 @@ func Test_Postgres_GC(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func Test_Postgres_Non_UTF8(t *testing.T) {
|
||||
val := []byte("0xF5")
|
||||
|
||||
err := testStore.Set("0xF6", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get("0xF6")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
}
|
||||
|
||||
func Test_SslRequiredMode(t *testing.T) {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
utils.AssertEqual(t, true, nil, "Connection was established with a `require`")
|
||||
}
|
||||
}()
|
||||
_ = New(Config{
|
||||
Database: "fiber",
|
||||
Username: "username",
|
||||
Password: "password",
|
||||
Reset: true,
|
||||
SslMode: "require",
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Postgres_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Postgres_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Redis
|
||||
|
||||
A Redis storage driver using [go-redis/redis](github.com/go-redis/redis).
|
||||
A Redis storage driver using [go-redis/redis](https://github.com/go-redis/redis).
|
||||
|
||||
### Table of Contents
|
||||
- [Signatures](#signatures)
|
||||
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *redis.Client
|
||||
```
|
||||
### Installation
|
||||
Redis is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
@@ -41,13 +42,15 @@ store := redis.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := redis.New(redis.Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
})
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
URL: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
TLSConfig: nil,
|
||||
}
|
||||
|
||||
// or just the url with all information
|
||||
store = redis.New(redis.Config{
|
||||
@@ -66,7 +69,7 @@ type Config struct {
|
||||
|
||||
// Port where the DB is listening on
|
||||
//
|
||||
// Optional. Default is 3306
|
||||
// Optional. Default is 6379
|
||||
Port int
|
||||
|
||||
// Server username
|
||||
@@ -84,16 +87,21 @@ type Config struct {
|
||||
// Optional. Default is 0
|
||||
Database int
|
||||
|
||||
// URL the standard format redis url to parse all other options. If this is set all other config options, Host, Port, Username, Password, Database have no effect.
|
||||
//
|
||||
// Example: redis://<user>:<pass>@localhost:6379/<db>
|
||||
// Optional. Default is ""
|
||||
URL string
|
||||
// URL the standard format redis url to parse all other options. If this is set all other config options, Host, Port, Username, Password, Database have no effect.
|
||||
//
|
||||
// Example: redis://<user>:<pass>@localhost:6379/<db>
|
||||
// Optional. Default is ""
|
||||
URL string
|
||||
|
||||
// Reset clears any existing keys in existing Collection
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// TLS Config to use. When set TLS will be negotiated.
|
||||
//
|
||||
// Optional. Default is nil
|
||||
TLSConfig *tls.Config
|
||||
}
|
||||
|
||||
```
|
||||
@@ -101,11 +109,13 @@ type Config struct {
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
URL: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
TLSConfig: nil,
|
||||
}
|
||||
```
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package redis
|
||||
|
||||
import "crypto/tls"
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// Host name where the DB is hosted
|
||||
@@ -9,7 +11,7 @@ type Config struct {
|
||||
|
||||
// Port where the DB is listening on
|
||||
//
|
||||
// Optional. Default is 3306
|
||||
// Optional. Default is 6379
|
||||
Port int
|
||||
|
||||
// Server username
|
||||
@@ -38,6 +40,9 @@ type Config struct {
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// TLS Config to use. When set TLS will be negotiated.
|
||||
TLSConfig *tls.Config
|
||||
|
||||
////////////////////////////////////
|
||||
// Adaptor related config options //
|
||||
////////////////////////////////////
|
||||
@@ -47,13 +52,14 @@ type Config struct {
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
URL: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
Host: "127.0.0.1",
|
||||
Port: 6379,
|
||||
Username: "",
|
||||
Password: "",
|
||||
URL: "",
|
||||
Database: 0,
|
||||
Reset: false,
|
||||
TLSConfig: nil,
|
||||
}
|
||||
|
||||
// Helper function to set default values
|
||||
|
@@ -3,6 +3,7 @@ module github.com/gofiber/storage/redis
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/go-redis/redis/v8 v8.8.0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/gofiber/utils v0.1.2
|
||||
github.com/google/go-cmp v0.5.6 // indirect
|
||||
)
|
||||
|
74
redis/go.sum
74
redis/go.sum
@@ -1,14 +1,18 @@
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/go-redis/redis/v8 v8.8.0 h1:fDZP58UN/1RD3DjtTXP/fFZ04TFohSYhjZDkcDe2dnw=
|
||||
github.com/go-redis/redis/v8 v8.8.0/go.mod h1:F7resOH5Kdug49Otu24RjHWwgK7u9AmtqWMnCV1iP5Y=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -17,38 +21,38 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.15.0 h1:1V1NfVQR87RtWAgp1lv9JZJ5Jap+XFGKPi00andXGi4=
|
||||
github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0 h1:CcuG/HvWNkkaqCUpJifQY8z7qEMBJya6aLPx6ftGyjQ=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.5 h1:7n6FEkpFmfCoo2t+YYqXH0evK+a9ICQz0xcAy9dYcaQ=
|
||||
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/otel v0.19.0 h1:Lenfy7QHRXPZVsw/12CWpxX6d/JkrX8wrx2vO8G80Ng=
|
||||
go.opentelemetry.io/otel v0.19.0/go.mod h1:j9bF567N9EfomkSidSfmMwIwIBuP37AMAIzVW85OxSg=
|
||||
go.opentelemetry.io/otel/metric v0.19.0 h1:dtZ1Ju44gkJkYvo+3qGqVXmf88tc+a42edOywypengg=
|
||||
go.opentelemetry.io/otel/metric v0.19.0/go.mod h1:8f9fglJPRnXuskQmKpnad31lcLJ2VmNNqIsx/uIwBSc=
|
||||
go.opentelemetry.io/otel/oteltest v0.19.0 h1:YVfA0ByROYqTwOxqHVZYZExzEpfZor+MU1rU+ip2v9Q=
|
||||
go.opentelemetry.io/otel/oteltest v0.19.0/go.mod h1:tI4yxwh8U21v7JD6R3BcA/2+RBoTKFexE/PJ/nSO7IA=
|
||||
go.opentelemetry.io/otel/trace v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc=
|
||||
go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bjBWZQA5DXz/qg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
@@ -58,8 +62,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -69,13 +73,19 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
@@ -89,15 +99,17 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
|
@@ -25,15 +25,17 @@ func New(config ...Config) *Storage {
|
||||
|
||||
if cfg.URL != "" {
|
||||
options, err = redis.ParseURL(cfg.URL)
|
||||
options.TLSConfig = cfg.TLSConfig
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
options = &redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
||||
DB: cfg.Database,
|
||||
Username: cfg.Username,
|
||||
Password: cfg.Password,
|
||||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
||||
DB: cfg.Database,
|
||||
Username: cfg.Username,
|
||||
Password: cfg.Password,
|
||||
TLSConfig: cfg.TLSConfig,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,3 +99,8 @@ func (s *Storage) Reset() error {
|
||||
func (s *Storage) Close() error {
|
||||
return s.db.Close()
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *redis.Client {
|
||||
return s.db
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -121,6 +123,10 @@ func Test_Redis_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Redis_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
||||
|
||||
func Test_Redis_Initalize_WithURL(t *testing.T) {
|
||||
testStoreUrl := New(Config{
|
||||
URL: "redis://localhost:6379",
|
||||
@@ -142,3 +148,46 @@ func Test_Redis_Initalize_WithURL(t *testing.T) {
|
||||
|
||||
utils.AssertEqual(t, nil, testStoreUrl.Close())
|
||||
}
|
||||
|
||||
func Test_Redis_Initalize_WithURL_TLS(t *testing.T) {
|
||||
cer, err := tls.LoadX509KeyPair("./tests/tls/client.crt", "./tests/tls/client.key")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
tlsCfg := &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
|
||||
PreferServerCipherSuites: true,
|
||||
InsecureSkipVerify: true,
|
||||
Certificates: []tls.Certificate{cer},
|
||||
CipherSuites: []uint16{
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
||||
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
|
||||
},
|
||||
}
|
||||
|
||||
testStoreUrl := New(Config{
|
||||
URL: "redis://localhost:6380",
|
||||
TLSConfig: tlsCfg,
|
||||
})
|
||||
|
||||
var (
|
||||
key = "clark"
|
||||
val = []byte("kent")
|
||||
)
|
||||
|
||||
err = testStoreUrl.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStoreUrl.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
|
||||
err = testStoreUrl.Delete(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
utils.AssertEqual(t, nil, testStoreUrl.Close())
|
||||
}
|
||||
|
57
redis/tests/gen-test-certs.sh
Normal file
57
redis/tests/gen-test-certs.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Generate some test certificates which are used by the regression test suite:
|
||||
#
|
||||
# ./tls/ca.{crt,key} Self signed CA certificate.
|
||||
# ./tls/redis.{crt,key} A certificate with no key usage/policy restrictions.
|
||||
# ./tls/client.{crt,key} A certificate restricted for SSL client usage.
|
||||
# ./tls/server.{crt,key} A certificate restricted for SSL server usage.
|
||||
# ./tls/redis.dh DH Params file.
|
||||
|
||||
generate_cert() {
|
||||
local name=$1
|
||||
local cn="$2"
|
||||
local opts="$3"
|
||||
|
||||
local keyfile=./tls/${name}.key
|
||||
local certfile=./tls/${name}.crt
|
||||
|
||||
[ -f $keyfile ] || openssl genrsa -out $keyfile 2048
|
||||
openssl req \
|
||||
-new -sha256 \
|
||||
-subj "/O=Redis Test/CN=$cn" \
|
||||
-key $keyfile | \
|
||||
openssl x509 \
|
||||
-req -sha256 \
|
||||
-CA ./tls/ca.crt \
|
||||
-CAkey ./tls/ca.key \
|
||||
-CAserial ./tls/ca.txt \
|
||||
-CAcreateserial \
|
||||
-days 365 \
|
||||
$opts \
|
||||
-out $certfile
|
||||
}
|
||||
|
||||
mkdir -p ./tls
|
||||
[ -f ./tls/ca.key ] || openssl genrsa -out ./tls/ca.key 4096
|
||||
openssl req \
|
||||
-x509 -new -nodes -sha256 \
|
||||
-key ./tls/ca.key \
|
||||
-days 3650 \
|
||||
-subj '/O=Redis Test/CN=Certificate Authority' \
|
||||
-out ./tls/ca.crt
|
||||
|
||||
cat > ./tls/openssl.cnf <<_END_
|
||||
[ server_cert ]
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
nsCertType = server
|
||||
[ client_cert ]
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
nsCertType = client
|
||||
_END_
|
||||
|
||||
generate_cert server "Server-only" "-extfile ./tls/openssl.cnf -extensions server_cert"
|
||||
generate_cert client "Client-only" "-extfile ./tls/openssl.cnf -extensions client_cert"
|
||||
generate_cert redis "Generic-cert"
|
||||
|
||||
[ -f ./tls/redis.dh ] || openssl dhparam -out ./tls/redis.dh 2048
|
29
redis/tests/tls/ca.crt
Normal file
29
redis/tests/tls/ca.crt
Normal file
@@ -0,0 +1,29 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE5jCCAs4CCQCX6TN/mZGB/zANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
||||
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjEx
|
||||
MTExMTYzNjE2WhcNMzExMTA5MTYzNjE2WjA1MRMwEQYDVQQKDApSZWRpcyBUZXN0
|
||||
MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEB
|
||||
AQUAA4ICDwAwggIKAoICAQDnZXRXrYURmTc/559vMe7CZnwtKul2ZMOtS7UDPCcw
|
||||
G3I1KHCxFkAxLNDhLtIENWId90Lc1mAIKtULy+RX2ORfOhYZ+JDK3sY25+53dgFq
|
||||
vdPdtSpiiLklSh5XXdLcNq5sg8Zs1W514otDrfooYWqUp7BU4vZ0Cb/MWP/WEynD
|
||||
ne3Aj1lpsEqV4+ydYhoki91tY9VS9y48VOZ+VC/+aCcbkm4G8FSczLZrglmnDq0v
|
||||
d/ZrQ6dtALvPzKXdPA0HuqacT7VZ09d9tVOBj8xRkq5YEgUNHStkzZiRHzFXtRx5
|
||||
+mH/WkkzbA1C7eUeRFxIxp+C1KZB08cg9CgdrJYs/osFttesSncOIdDieauaqkTU
|
||||
wlcEY//sv/eiOv4XCIvuG+39r0ITQ4m8Amb28v0uaz2s1e8UVpk1mLuUVcpspmAf
|
||||
q0UUyb3aKjkluBn5rZuHxZLP14FueojFTLIXW6sNKYGqHqh4TicogmqCQAGhd9wo
|
||||
Wis21+xeOI9FgojASxugN+tY/64nwYQfCWsv8AuZegjyQ+AodGrtIHEbrAdgeYOj
|
||||
heEYDePaKMau/0vc14vlOs5EssXf49QYhciRqESc+0O85rHemgqhb4Qz31V3AGf1
|
||||
NP0wvqA97AmBYRLZSNc4ExvmQponOIVJY+idWiqJuRZSOeScEx0sx22MF1Nhwaw+
|
||||
3QIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQCN1SnYfobIM0bY1bI/n5njNV8HEFAT
|
||||
X9EoXEKEg8lTJNNHSAEBDGgJMH4tc2+gQ/AQxdjCTJXlYP7ET5eHHPiUxXRqwjZr
|
||||
MDSVbipaqJ3AVkJs+XeqrxyjsJ0S4uPd82gYzcPYCP6Zq2hFGTnzlnNE8oZq+Ys9
|
||||
mdVEwWmOnD+sl8pcRuccxUfPAJoZK3A5G+X2xctJLwMM6Y82ppu5XVMbmuoMTQaK
|
||||
pkhw6wZwah6Fa0QSgL1Lro63aDG1xDvUi8HXD7baZw/nNT/rI81ZFwT735sRkRm5
|
||||
7WXnfic8/SsQGk0zw8grUy+Q/7YSonr6LxUPd6vSJk3ZBEWo/FbDpXRSLaZQiR2S
|
||||
87gWa1Mt/a98OHR736q1jBvIeiGhC0dB1mj2Cclvtc3rO0uJzsHBzviE4008t8mn
|
||||
mCVTp03nvMMO9BOpwECDOnBok4aMfqiIMJlPrl2ieiZX1lM5xiwZkzS/x9mTp6dx
|
||||
9dhppRo/y9ViuB8PVxkDQCPjnZ+WefRXTW6Vtacc4D6LNQgJytFL4nVBAzgABfpv
|
||||
cUOk41qGpY/n9VscZRGadyHjz2f0l4LY6GeIDg/iF9/qzOFTTRx6eyJ4ueeq2+/T
|
||||
V5Ro8kzYg8aXkDY2dFLdSz8KBkaZ++8A6Q7h2SPVNfAepKGLHyB76ktMaqjonhbn
|
||||
rq7Y+FUj+SMshw==
|
||||
-----END CERTIFICATE-----
|
51
redis/tests/tls/ca.key
Normal file
51
redis/tests/tls/ca.key
Normal file
@@ -0,0 +1,51 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIJKQIBAAKCAgEA52V0V62FEZk3P+efbzHuwmZ8LSrpdmTDrUu1AzwnMBtyNShw
|
||||
sRZAMSzQ4S7SBDViHfdC3NZgCCrVC8vkV9jkXzoWGfiQyt7GNufud3YBar3T3bUq
|
||||
Yoi5JUoeV13S3DaubIPGbNVudeKLQ636KGFqlKewVOL2dAm/zFj/1hMpw53twI9Z
|
||||
abBKlePsnWIaJIvdbWPVUvcuPFTmflQv/mgnG5JuBvBUnMy2a4JZpw6tL3f2a0On
|
||||
bQC7z8yl3TwNB7qmnE+1WdPXfbVTgY/MUZKuWBIFDR0rZM2YkR8xV7Ucefph/1pJ
|
||||
M2wNQu3lHkRcSMafgtSmQdPHIPQoHayWLP6LBbbXrEp3DiHQ4nmrmqpE1MJXBGP/
|
||||
7L/3ojr+FwiL7hvt/a9CE0OJvAJm9vL9Lms9rNXvFFaZNZi7lFXKbKZgH6tFFMm9
|
||||
2io5JbgZ+a2bh8WSz9eBbnqIxUyyF1urDSmBqh6oeE4nKIJqgkABoXfcKForNtfs
|
||||
XjiPRYKIwEsboDfrWP+uJ8GEHwlrL/ALmXoI8kPgKHRq7SBxG6wHYHmDo4XhGA3j
|
||||
2ijGrv9L3NeL5TrORLLF3+PUGIXIkahEnPtDvOax3poKoW+EM99VdwBn9TT9ML6g
|
||||
PewJgWES2UjXOBMb5kKaJziFSWPonVoqibkWUjnknBMdLMdtjBdTYcGsPt0CAwEA
|
||||
AQKCAgARw2kN/gUUF8X1AuvrVlL023c25G9tpkibOg+YQvrjJ4g56nPUNFgTLlSO
|
||||
pNB8gDibAktAtrhCiD84m5tY3w6Q/N2LethqqnVe66kTxJxRPGdSQsERNVu5MBpq
|
||||
LIquWwhCzk7iNfQ32n9EX8uvY+MRrFnN+mpe+AygPEjPf0MagDorKRX9FgpzvT6B
|
||||
ynElUxNZfWt35f/Ho+DZ286fYhF2fWQy5iooq1JpqGUHfQnwde4Vx+jHZmIEjrpA
|
||||
5IY/jKWTpE7QqYGGZfAWJxrRPEhj/GYk3pNhNqM6qMFZ8U5RUtZJCv5Jk0blV2va
|
||||
Sfcnow/FtFta/E3yCqw1svUIWTYEwekaJIB5n3K2vbYwFdrsfrLJ0dOu3qMW4H4A
|
||||
XSzuSleswPQf3wE3HKfPL4H2RsQsl7M/1tEFZWzegT5b9jAjDPQOagKi9OoQf39f
|
||||
iJlPxzt91ukcYiYLcPbV6vr3WP+8TJshV3u2gd85zdQ6N+Jm7fcbtjT8UjJYa2RQ
|
||||
UM6OiNrOPEqwZcRlXbBDyIQYIBN8VMVS610NekHDgSmWNpdofmquMUoWSukL4Vl7
|
||||
FA+kPgAyvoHU4nUc13rFOis71ZUYP+JzFEWdE16q72ehemFnEgRNcyTUQAlz5Wl+
|
||||
SApH9ibqjXfD/jYFpHlIg+Aw6LQqo+g9m7MyNHb7MNEyVfOjhQKCAQEA9MePx+uZ
|
||||
vSIDcmxNsi0lIELbpwOSwgYH8v2WWWHARVZF9i9ZQ94R+PHmVFouzOZ6AB89EqDw
|
||||
c7qSX5rveJH8FurXOWu9LPIwSR0SATB67yPh2GR55vTQP9F3gHRA1nB4Wto6Uhk/
|
||||
2W1WBNnO3xOcOzitvBuPHCRMK193pa6HDmKXzZHeDA3NPhaM13eGI37rpM3tqm7I
|
||||
lyeZrCo2Tps+8j9qkBOQ1VaPUtc36bMZpnTlnTP3fFp7oaQKgtHnpqpQsVZuzt90
|
||||
Y8UeVRe0LOWi6VOWjiasVvQl14338CNyKoi9KCu3NL4B+4OQBoxNrpEsd0/OKEXX
|
||||
grCIRg12tajluwKCAQEA8gDX4wqOzmdrcqsIlACREhyubnIDEJ7WmceR+dklrs1/
|
||||
aaYL0H8IVSBmszzIUiTA9kjEFCU9vls6vjguBpF49YlXQc2pmyu26zQc83X4m9n8
|
||||
roO6Jdlic5lkYbUtuB6c3AE7J5vTg2Yc9oLAOMibkjLrwfgQpBfMHhUY9hWpTBFF
|
||||
8tBiUFB0ZDTcdDpIWd3P20j/RSB7e28sq34k6t0KkiWkIVecEHTq4uI6TGePzvIW
|
||||
vdDVAKM4nllPYUPK6jQRvJ+fsKxnqmra0MoOPIpwpvsyg888992KaKC6zL2/EWP0
|
||||
axExlKVYruyo7GNsSPOZq9eJ40Txc0nHbYUO3LEYRwKCAQBUM5GyI8lu1hR5d+gC
|
||||
MqViw5zrhr8lHw38+F6PwKBzOYo3dXIvdmSYTh39RkhzE5VEFXrcvZ/5L2TKnnFh
|
||||
+FXPTFlc10LsAyO5Atb+sb6YJK+70FRerjg0u8lv1o23NlkwZ4FIXIcqNAIzCPmw
|
||||
ov5LIOQioRhJhfLtuJlf1PmAaUnu3Q6U9upzQS6Rr/vkmfRVbMEkr5cw595k6uBj
|
||||
iePNUSNHDHP17yC+Tmpdac6ZA/04ZnfrvvRoVhWHis0098FqP2E+qH9REq2sd8ry
|
||||
5stzl91iaMs/3hxmWd/AK3FKUF9BQkhzTClCa69PkVPniOjS4hD4qY3I1xEJh/gd
|
||||
5UuhAoIBAQCBO/4OGvdENmpk4/1CvEK8f2CPTodgetJzcOX9nP7IqKkgDDJG92/F
|
||||
tfXiRdVcOJBrdVRwxaqBW0q1hl7d1xXXWa6lT2UBnoiidkP3p8pJwFF2CJaB2+L9
|
||||
hK7cltqBdqehvW6PqmF7zC4vXoe0Szz5CARqo0SPvL2eWvnngI3WN2s5ThsSdMST
|
||||
Nr97uhwlEZUMr6DSk5QdyLL8KfMhEUWx4jQSMiz/hNBitRkY8D0V8KZAW6NEIeX8
|
||||
egkwEfnstD28kym+OXNqyIFt+lk771pVcdP6G9OdMkvVr+/RoorEiLJf8uCdVudT
|
||||
EsLq6fVLx/sKj6HtIkYmoQHE9MeJB3HFAoIBAQCrl5LBfNKjqx9ijX/ghAvvHm52
|
||||
T9cSJxHZ2VaIghAIwXDAA7vUpeLlXcR8zHp+TozFWpfEcZh4ztmfmEozN8Ljcutr
|
||||
94VX7urIdC/JYzfJ2rzNmJdk0sgXZ+yv4LJ9RvoehIuhwQc95JLdnlEP3kNBiqUM
|
||||
N7i66BLdWq015b6WCIYS8DeBfETkXRLMH2hawpB1ZmhiWQ3G49cGJU/CXt8471dC
|
||||
urEwlHtCLDvZ4peTCoVtV0OgNTcE05RPO15gFIMWrHF/UoZiV+PZCHTJNzjupjNw
|
||||
8xgu+EhDo62M8t+SILwNRPvusAbOLXsnTbq7xbmWR/9zPtJscBCxMCxiHkKc
|
||||
-----END RSA PRIVATE KEY-----
|
1
redis/tests/tls/ca.txt
Normal file
1
redis/tests/tls/ca.txt
Normal file
@@ -0,0 +1 @@
|
||||
F93DEACFF8ACD904
|
24
redis/tests/tls/client.crt
Normal file
24
redis/tests/tls/client.crt
Normal file
@@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkDMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
||||
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
||||
Fw0yMTExMTExNjM2MTZaFw0yMjExMTExNjM2MTZaMCsxEzARBgNVBAoMClJlZGlz
|
||||
IFRlc3QxFDASBgNVBAMMC0NsaWVudC1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEAtKcK6sWYkbgmWKV03WzmLbicEr9gMZVsoyxgNV52ciFnPQ72
|
||||
2B0PEafTO4CFdzTj3titqqOtcQVVqo6uCZroBfwCYzEgozBEPvECcY/ldw1uiN9c
|
||||
EyCKTAEGFqnSZwJ4UfC/JDnsNRjflLrAZ5xsQV56+yreYurY8WzCmdjpxkHQ0i0s
|
||||
BBG0wdd/d4G8EYSHjOhtoqckUCeHU3Z8+WOn3LeIjK2XaAZTJHC+a9Pjj376degV
|
||||
bgEQufwrTiyOimwoMVvu2biMEyPo6KXJeofaPjAMeS2uD89czV2qjPPoLrb+x1mZ
|
||||
wVWK+PIiQE5cgBGhjNTEToj0xI8ZhGiqvoLTdQIDAQABoyIwIDALBgNVHQ8EBAMC
|
||||
BaAwEQYJYIZIAYb4QgEBBAQDAgeAMA0GCSqGSIb3DQEBCwUAA4ICAQAkDELpveEq
|
||||
jdQ2S3meMJlBjSI5raNkZ3eduV8TMQd7w7Wti6/DYhpquYyt1SqKnDm5Req5BC0D
|
||||
Q6EgJuTOJ8ElkZ0PC3mZXDsAsHrjgJ9PAgMpGv9HB4XkAjvD9YdKH610IkmOUHMu
|
||||
pToFdck+woe5lbQsILJl2AE72zzqCgDM1K7FxMoP6ZN8fmX+7/TSwiEfVgkwLDgp
|
||||
FkGPCGGnHcWYW3H+4UF1UbjP1uZwiSAq2GbzfHuUrCQhVUCnFOEygMowgK8CtZgb
|
||||
ONJV3ePGSE8ESh/hQPnihlJBASXT7AXO/8Z4pW1J54VgamTrDKbiz/35fNAcsCId
|
||||
tfiPXGTAG1QSWHMB+Lio9okNleb0RNHsXWQH3j6oNjPfMOGqYIpmkefv+2nivin+
|
||||
LAfzbcSGNXnus19HtsS+AjUNeSeoR1IIBg/aRmYeDCX1sBTugyIo8njdWtyT3Pj4
|
||||
LgOuMi/vyNL6hocdwkTfMqceMo3cCF+G0R6V1yrZ5xKFTmkqT8E2SqHC1sHHqI9o
|
||||
G1AvHtivIlNuACilB/s7ptnDdgcGPu5aNSWPm3S1GctR6JHOxbGzSaa1UiIAHzoT
|
||||
B1HLud63T/6YDWTWn01zLfE1X+tdSkekTEk9qCyQZRokbvrP/oIwSpnuuzPlUlYn
|
||||
OvQBR7Rly6F3JkME8rk9sCYv995CiUr+4A==
|
||||
-----END CERTIFICATE-----
|
27
redis/tests/tls/client.key
Normal file
27
redis/tests/tls/client.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAtKcK6sWYkbgmWKV03WzmLbicEr9gMZVsoyxgNV52ciFnPQ72
|
||||
2B0PEafTO4CFdzTj3titqqOtcQVVqo6uCZroBfwCYzEgozBEPvECcY/ldw1uiN9c
|
||||
EyCKTAEGFqnSZwJ4UfC/JDnsNRjflLrAZ5xsQV56+yreYurY8WzCmdjpxkHQ0i0s
|
||||
BBG0wdd/d4G8EYSHjOhtoqckUCeHU3Z8+WOn3LeIjK2XaAZTJHC+a9Pjj376degV
|
||||
bgEQufwrTiyOimwoMVvu2biMEyPo6KXJeofaPjAMeS2uD89czV2qjPPoLrb+x1mZ
|
||||
wVWK+PIiQE5cgBGhjNTEToj0xI8ZhGiqvoLTdQIDAQABAoIBAQCeCzGi2QG0Ik3x
|
||||
6baG7Pmm8EYipKjMWDR1wKHeruiiypReN5Q+15VSVeeXu8WH146vbBLrIUzgftFG
|
||||
aJLbtljcu29/RgCOo/BgvErt/Py8HdUhC3+rACHdglvIQgPfuKp4zUz7rWz3uu4H
|
||||
WSZwvsl6muSujf+GvHzVIdhR7hH/LianictHN6OBvuIk6+88LYxOvPzvOuzTs6o8
|
||||
D4CdNwaWUtOm4/gV2/UXKBosbdpIoVbYAAOZPnu4gLAJV9ICnLDKMtZ+buZNEBdo
|
||||
Pt3vtzN9LqmaiC1BfaH3Uqr2nhPW86VwLIr61uFGRG5Y1GS2XXOq+dgxW8BmXWMP
|
||||
42J2GUlBAoGBAN+mPYJUckGFlToREOefwHsKJqPP+1aK4LjibqXZSnTtRvAur/kD
|
||||
Bw/b8xGSHx/pisQU9wwtbaaVy0tbW6fMBBweOiZMJdQ3XRaH87GfPDyEmqRnUWAF
|
||||
/NiyshHDmg6HK6Dm1hT4Ndd35PO1xJDsgGyqCrsMRwfAON0pfSVxdWyFAoGBAM7I
|
||||
n7tBdWeTWeVVFuZdyTVOWsYO14ZRsHULd30gO+bXaXFAK7X8/5tawZ4PXJq4VD0f
|
||||
rpOcsnNtuROpbh3MshsplEDuq+JQ9DlhBTiz8wVcKp9z3RCY4GQjuPNIFuVMjN6i
|
||||
dsL0U+IKwMPpYnlgimW3sNygO3q/nNxrUobBITYxAoGBAKYkC7t+2iXcg1/Qf7th
|
||||
jI6amtvETFUc9BXEeCgSRGKaRcF1HVqhqiRY47fg0ehWCLTjUicktDk1PAFuC6ea
|
||||
Qk9VESOUG+ILgsaTFjCUNx5J78tDyUrJB+0+ylOx+Abk2T89XDnVrcG0GkwFctGq
|
||||
LzkKFNChLT8Px+5bvNEM+Qs1AoGANcSjDBzkO09sU56BetsuI4dBQTjAv/Njz7tw
|
||||
kX+dM9QVXdZSx1qG2E2MBN53tN9zQAWJ7mYTXMJOGpe2w1bjhP6VxyCIXyuvpW/d
|
||||
3LWl3mHtz1JgTB2EU2WahN/c3DjAdG+IM/82BJPJNefsrCT3N6XA/k1Hyg4i6omZ
|
||||
huKXETECgYEAqr6GHzgFy3Y4OIpobwuAKvrY2/s7bo68pF6QTqvxalkJkjkp5HyP
|
||||
FobWC0GxrPfwjkRbQTRANA0vVwFP/MnCU1ag3UeoYamOmG2GnTiiYWQehovAhOyi
|
||||
TK7QXf+j5o4nrRt/TRfyeZH9XevX53HIGuFRtFZbm+WMn4bPjQj7ypg=
|
||||
-----END RSA PRIVATE KEY-----
|
6
redis/tests/tls/openssl.cnf
Normal file
6
redis/tests/tls/openssl.cnf
Normal file
@@ -0,0 +1,6 @@
|
||||
[ server_cert ]
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
nsCertType = server
|
||||
[ client_cert ]
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
nsCertType = client
|
23
redis/tests/tls/redis.crt
Normal file
23
redis/tests/tls/redis.crt
Normal file
@@ -0,0 +1,23 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID3TCCAcUCCQD5PerP+KzZBDANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
||||
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjEx
|
||||
MTExMTYzNjE3WhcNMjIxMTExMTYzNjE3WjAsMRMwEQYDVQQKDApSZWRpcyBUZXN0
|
||||
MRUwEwYDVQQDDAxHZW5lcmljLWNlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
||||
ggEKAoIBAQC/lqyvZ+JecRTRWFEoyfIYnxz+1HiZwFGL7BhSrPf7Y6CSDwV+A7tB
|
||||
Pvu7gSQx69cfMIeS78n/pNV4P0dCgiEiOYZlqa8z1H3MVG6ZuM9uIfeubAeOvG5M
|
||||
Emk9UJ3KU01XFFLCaQ9u+WPJNUQyB+hUDE92k3PQ+sh3getcgYDQm6ktt1lZOgUK
|
||||
JwXPNg6E1HlLDMrf4kqsCLMHCAuI7pT0RjMrK6mNEvs7hFf487zj857Jd1XJ069l
|
||||
Fhqt/LOW7jOOCEXiGtfWEJ8pApsIsc1Pdgzxh+WS1HH0qRELMv0RUJXnhw/uiE1A
|
||||
TwLVUD91YwboSLIYf/E3m7zREaXwf14RAgMBAAEwDQYJKoZIhvcNAQELBQADggIB
|
||||
ADWC4NSOil1EAqtrZbNAMm2beofNCcgkcO1FzYjgLXlEmq7ntvJF6LNhVBFtQCJw
|
||||
dRFfYqAH2TPI9nU3NadaJFCNTC3MQaSaIOXe4ntV2H8swbNlHEonjJ+PutK+GQYL
|
||||
6+ZF4heW7ZgOREr1cldVFo7GWQIGKR0jlckscn6OwHcBiqxYdrW8xXfUEcRH0EJk
|
||||
pFn8QjZlCBvMM1oVSPE4xdi04DRJJxHeE++KNH17KyoTSuvIrHvf24bKr2RlPvN8
|
||||
HC6cvLGSWVZYu4MKx2tWtQUNwnA+oQ+Ri7Id+KdpEBn+UJrSoZ0hu5xz9LBakbXo
|
||||
CoJJ9vzhHn4VP0Q1/UT+GQzdC39P+s2TErHKNQFql+qZYNJltJcbq3uWQHL0K0v7
|
||||
ai7AXsGSIJHWTMT3LihKBeWFLDZBugWxpFF6SjHmcONpv1KSfxHvRw+OrNARPIof
|
||||
13/5IEx6SecT3E7EVjVZyyTgpjv3lOburIrw1amHqTtxRaewMjloYCQwjVmrgyme
|
||||
BcjZtsHzXjF7/AmlEtwnc6BE0jUwJHznfyfV8rYTwfO0Ew/xrLJ3EAvMTNMOOvfl
|
||||
Ll5DDqA61Ai2/61rVhoUEyjPNDjB8hyY8NB0F81Mbbhm8T4/BY+TAX9MxFv9Rt/y
|
||||
3nBxLL8uIt1LUC7blW4sR+DsUEmk8nlJ/TW+166B+2+M
|
||||
-----END CERTIFICATE-----
|
8
redis/tests/tls/redis.dh
Normal file
8
redis/tests/tls/redis.dh
Normal file
@@ -0,0 +1,8 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIIBCAKCAQEA1nYlp0dgMjvcReATfJwuS1lAtpvaTl8/Fu1/CuQ4rCoB9fgqvlTv
|
||||
jgnHRAW42FD9NwOQibol/mDAmThd8Srq/teu84w9j4CGsd3+qO+/HP16GHLACVkP
|
||||
LmImh30irqfTC2JkuiRccMYmt4N93Ba8FgC+GLcEjEB0JKW/JBZ71qO8fvwvvI7h
|
||||
QU4YddezMsPG3L6TDYX0cFCSrcBNKa8mGgGLtppT30UWvAH0QAlsd6jiIR1cto+T
|
||||
yDAv5WYIkBlsGcH70X1EEglHz48USV0Xu5lADkiazpXvKTl3XkD6gVkrCcxHF1iE
|
||||
7VEbxKaGx5HsdRw7EV6Fdxp98mGRWjBlKwIBAg==
|
||||
-----END DH PARAMETERS-----
|
27
redis/tests/tls/redis.key
Normal file
27
redis/tests/tls/redis.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAv5asr2fiXnEU0VhRKMnyGJ8c/tR4mcBRi+wYUqz3+2Ogkg8F
|
||||
fgO7QT77u4EkMevXHzCHku/J/6TVeD9HQoIhIjmGZamvM9R9zFRumbjPbiH3rmwH
|
||||
jrxuTBJpPVCdylNNVxRSwmkPbvljyTVEMgfoVAxPdpNz0PrId4HrXIGA0JupLbdZ
|
||||
WToFCicFzzYOhNR5SwzK3+JKrAizBwgLiO6U9EYzKyupjRL7O4RX+PO84/OeyXdV
|
||||
ydOvZRYarfyzlu4zjghF4hrX1hCfKQKbCLHNT3YM8YflktRx9KkRCzL9EVCV54cP
|
||||
7ohNQE8C1VA/dWMG6EiyGH/xN5u80RGl8H9eEQIDAQABAoIBAQCsjHdaQqWNiSrG
|
||||
oFP3+Gkh46uplpJHZv4KlsgRLdbpggDLitvXcmTjjmYJqXV/wHgujvaLT4sNwta/
|
||||
Rb5YF/rfaA+y3+/7LhVeQWya5edruQvo+0KTOwHbYXmGz2RNJFkzZAplLVnJCLLm
|
||||
NCMHLDgB+lRW5tYYEMUbXNcsqTXqqbSj9YHJ31z4y4GMXvw/ZIqikixgJzvIKe6P
|
||||
zXBkK+J9otHWO3Z3CMFoRmhI0fp/wIiOlp9Xk2QzhUIIo5mzpRP2FnVBQH6qA1Qx
|
||||
HcHy/kHCNOtkebaM50tCHwSZi+w6WjKRfbTpQHCaUIjvTfVEup088iI8b+gt48Zz
|
||||
noX1efhBAoGBAPwCiX71kICymFBMyfE+0KZqg95w5oOygb/UvqmfAAHL8wwAxFRB
|
||||
zTG6GQE67P/nROxUm3mr3JcTgszGcNBfeB9d3J59AFIoyHCOk8fXUS4I1JOKdIdg
|
||||
XIwtCcIrCkCcLrzUVZlT8mJRH0F4U/LaB0NHiRZe25AWSVUdpbA/SDlHAoGBAMKf
|
||||
O9iWdGZT6YC8FnFjS+HV7mJlUmaEgGXLqwVnEXOuGKell6WS5GN9XEcP8BnUqaoi
|
||||
ARCWfku18x2LgOm1WZf9voPUvGwYAOuvzFtX9d8MYQQnI+fZX7ZpRO0Pako0kQhr
|
||||
4SUadVQXXJIbB6kHr3JVP7dICEn2LOmlhWLnRlnnAoGBAOzxqbuAQaxvvzwI5vp3
|
||||
mBBQJ8qWlnYO+WWXLukmwQfvbYbEldOuxrJRij8Y20rEdI5MAp7EkzRMuPe2QM36
|
||||
ZWQAiXVOjGWzSLpjo9kKvp4s2UobrPK4DGwT0JAKjaov7tXGQvFV95ivM1cIPs4g
|
||||
ZyG/+cnZyFDSU4K+zFFJPqvzAoGAaaa5fT1H2RjqZJk2cb1evy08aKvqTH7XmOs0
|
||||
Xw1xmuPCvJeXOCoC08OE6YrMY6lfpV0qSM/5pa4TWVGW3Mg259y2pKhC1Uc+kLNx
|
||||
c5DPh5MXw4Jf6ofFfqes5Cf/ImNg7DpsEZFIair4dNQ5l1f1tVJz8VIoNcZu4TOa
|
||||
snMsbLcCgYALyGUUdgCDZErB32O2I6o6vLQh6Lc0YqbjrGGkvuygOEUiLa5Wtjqe
|
||||
AHyb9aT39jSCFEaTMKPma3T555+Lkk1Io2jYRVenoFS+O1nlRQKuIbIyuejA/SFm
|
||||
z8rZ8EMT4g485CZJ3VjkoVXNXl/L61F1I9vK31Il88qgvm4y2JlYyg==
|
||||
-----END RSA PRIVATE KEY-----
|
24
redis/tests/tls/server.crt
Normal file
24
redis/tests/tls/server.crt
Normal file
@@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkCMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
||||
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
||||
Fw0yMTExMTExNjM2MTZaFw0yMjExMTExNjM2MTZaMCsxEzARBgNVBAoMClJlZGlz
|
||||
IFRlc3QxFDASBgNVBAMMC1NlcnZlci1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEApvPQ66+fMPnJMf8BkGMq35EAT3FJIECqd3K/DNS2zox53gSj
|
||||
P9cPuaW+JBlMUXTpGhgNKSLD8TMwJcA406A/pJScLNrdfoI9RvlKblwWWxcr2QBS
|
||||
gFvEcnAYByVQb7S9gEOZev5CHGPw9Bav4jYZ+nTc+ERDuMC6HaqrjbLk1UbkuvAV
|
||||
cWipYygtVFeeWx1TdHmez7n+kXcKNVojp1BbNJj5162zYXD7CnWrepA0r8b3ETEs
|
||||
jTFRmJd6UgjZ/u+apf+DlIQ5UZOWPUs1okzmCjHAL0hp55Mj6lRW7F+ZEX8uC/pG
|
||||
jOz/Qi2AIztZp+tYSQmyXlsEODft88D6StWKLwIDAQABoyIwIDALBgNVHQ8EBAMC
|
||||
BaAwEQYJYIZIAYb4QgEBBAQDAgZAMA0GCSqGSIb3DQEBCwUAA4ICAQAkwYDPD0Qk
|
||||
mi3YyIdK/+KtiDcyTAYszQfKx5luSZ1+dU9fSc3xM8vMy2ZogpzOjjq+Gmxm+/mj
|
||||
8FonHMnlBH21tyuCBxs/yXeR8bqNRL1PyGN3lI0/3IF2dlQGGUBhmnSvgt1ZL0G6
|
||||
jeonmiLg+DjOPr38lO1B0qY+gwhmrJkGf6+NmwfCWJg6xO7D2fKS9iRRb4DTxfms
|
||||
6UPpFtaHOKSGQMjvDQ86t0tAgavYBYib4xAxRwnkxfriVhncEybOpmlO5tEU1Xl8
|
||||
D1Ax/LYgHFZa0W89NrlFoFx6mVpBHjUml9OBYaZkzrsMix6J+47aJPyceKThh86Q
|
||||
TmKEOV1Zko55JBUGoFDzfyCLHYiugdupwrvW1nEJ07JfODbrwbMC6uNRR5CxowgA
|
||||
oRS1TTHINqOKFR03AbrqQ1yDf6Ufh4k/2f+L4i8TKeH2A6IKmXfgMEWvqf6gw1tm
|
||||
7z8j0klDxH5ezQUjSJS0jf65JFLX3TxdbfZEwLvZUg73m0XUNouvq6agUmcIoeHv
|
||||
IKycZntJ4YPPerIGMMM9iGh6ij/NWeNZSQQ5Y0wk7yXsI2PPOUj1O9blzDU5NrgN
|
||||
0DXjoVQqRgFln1U6lAtqxCkjp1YIo/LGKtscpXingSj2IRsbGkT5tUMmCv+sOd+x
|
||||
2DenVLRlUlVuEDkkwcA9mwxKYaafCv2tqg==
|
||||
-----END CERTIFICATE-----
|
27
redis/tests/tls/server.key
Normal file
27
redis/tests/tls/server.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEApvPQ66+fMPnJMf8BkGMq35EAT3FJIECqd3K/DNS2zox53gSj
|
||||
P9cPuaW+JBlMUXTpGhgNKSLD8TMwJcA406A/pJScLNrdfoI9RvlKblwWWxcr2QBS
|
||||
gFvEcnAYByVQb7S9gEOZev5CHGPw9Bav4jYZ+nTc+ERDuMC6HaqrjbLk1UbkuvAV
|
||||
cWipYygtVFeeWx1TdHmez7n+kXcKNVojp1BbNJj5162zYXD7CnWrepA0r8b3ETEs
|
||||
jTFRmJd6UgjZ/u+apf+DlIQ5UZOWPUs1okzmCjHAL0hp55Mj6lRW7F+ZEX8uC/pG
|
||||
jOz/Qi2AIztZp+tYSQmyXlsEODft88D6StWKLwIDAQABAoIBAG+d3BRmIrDUnp1t
|
||||
VndYxWYYhDOYkoIcmZsoPPBwGhO3ORak1RuuRZYhaCCsRSjEV7+ZStswof1U8qCa
|
||||
haN+pG386PjYDnMw0ZTsv8VOjaeysx7uJzonoAu+Q2IroT49gOAK0ca3zC085+/Y
|
||||
Zxh+gRnAHadhxED1oLiKzQz8CB9JpNIWWIhMEAPUgnnVMRzED62OyMTsX6ztPSx0
|
||||
EiM1sNU7Jnf9TVMYS1LjJ9SNqbT9tmPaRj4DM2X17Iolg6ntx3rl8xeKQfcrOl/1
|
||||
EWjiXBSmmqsGpQZPyD8uCE4d1/V+5sNpRkPRBJVoqPKRdmSHCgOPkeWDv1zoJZv5
|
||||
RnS6MKECgYEA0nRtQt6j3USq/PDdnzRjskks7qsfOtsMR7ebQFwD+bbpAiY+walu
|
||||
zTFwr1KggAtfjlp1pegnLg2aIvCoVr3wDAf7itAFIY34OKXsgV6AAu8k/Kr2KYgI
|
||||
ZbPKmhn7bCH3vCzC+SsN0kBHhOmWLiErx50mpVPFgjkOHG/RQZa24NECgYEAyxVH
|
||||
cGfSMWRe/e25R6F8b5V+oUThCZ6JyL0n03Vp9OFt1FN9OleBjezA47AysnKFnqIa
|
||||
jsUwjXEZOFHmNSO9tPoNxqPH5vaE/BShSTVdP/zeOXF3BQLajrqwC6+2tzDMmpmT
|
||||
erc1lPWHIMrvNaVkF/9mVbaDyZcGa4eNwm0Iev8CgYAtcTRSdw587aHaIgxInyBT
|
||||
09ce5dZFeBzrs2qTeArntaYUb7unR3WEWwOQ589+NnZ4n3G91CX5nLhGiR5gNH0L
|
||||
rAGVlJs3Bpeta65otMYBXC/pWuTyTMw7YZoCsk+GpsL+X8/ty20dlAGdYm6qIUF5
|
||||
xaYdlrwUBUvVuhM+DVQJsQKBgALJ9AUzJ8vN2RAbp6O4MAFISEjmrUB4kOPU1Ssu
|
||||
PZpDTkLQMrQOZ5UPX0bBMLEKqZMYHs0/H/+RQgtn9IVeTEij9nR341Lkp8becaiT
|
||||
twgd7N9VE5FaDK5RGgHPE+9IGEc3PLM+uNmm1Yg5wTc3YjyCIWGj9ANcs5Xecq/s
|
||||
12T5AoGAAlLIzXB5KStzhEibmwgmXLDL16hgTXmMHZ59Uy3Wz5g5r66rUqQL1Fg0
|
||||
RjtRYeCjylVzDGw5ffzQYPUg2DqAncD/K2Pgw1EirwdZfzdWU7oXIiA+FYEEi0Z3
|
||||
q3VVFmHAJaTQpU2A5UpL5+a8s0oPxxmU8p+FVhVuTLSuX8GcJr0=
|
||||
-----END RSA PRIVATE KEY-----
|
75
ristretto/README.md
Normal file
75
ristretto/README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Ristretto
|
||||
|
||||
A Memory-bound storage driver using [`dgraph-io/ristretto`](https://github.com/dgraph-io/ristretto).
|
||||
|
||||
### Table of Contents
|
||||
- [Signatures](#signatures)
|
||||
- [Installation](#installation)
|
||||
- [Examples](#examples)
|
||||
- [Config](#config)
|
||||
- [Default Config](#default-config)
|
||||
|
||||
|
||||
### Signatures
|
||||
```go
|
||||
func New(config ...Config) Storage
|
||||
func (s *Storage) Get(key string) ([]byte, error)
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *ristretto.Cache
|
||||
```
|
||||
|
||||
### Installation
|
||||
Ristretto is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
```bash
|
||||
go mod init github.com/<user>/<repo>
|
||||
```
|
||||
And then install the ristretto implementation:
|
||||
```bash
|
||||
go get github.com/gofiber/storage/ristretto
|
||||
```
|
||||
|
||||
### Examples
|
||||
Import the storage package.
|
||||
```go
|
||||
import "github.com/gofiber/storage/ristretto"
|
||||
```
|
||||
|
||||
You can use the following possibilities to create a storage:
|
||||
```go
|
||||
// Initialize default config
|
||||
store := ristretto.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := ristretto.New(ristretto.Config{
|
||||
NumCounters: 1e7, // number of keys to track frequency of (10M).
|
||||
MaxCost: 1 << 30, // maximum cost of cache (1GB).
|
||||
BufferItems: 64, // number of keys per Get buffer.
|
||||
})
|
||||
```
|
||||
|
||||
### Config
|
||||
```go
|
||||
type Config struct {
|
||||
// NumCounters number of keys to track frequency of (10M).
|
||||
NumCounters int64
|
||||
|
||||
// MaxCost maximum cost of cache (1GB).
|
||||
MaxCost int64
|
||||
|
||||
// BufferItems number of keys per Get buffer.
|
||||
BufferItems int64
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
```go
|
||||
var ConfigDefault = Config{
|
||||
NumCounters: 1e7,
|
||||
MaxCost: 1 << 30,
|
||||
BufferItems: 64,
|
||||
DefaultCost: 1,
|
||||
}
|
||||
```
|
46
ristretto/config.go
Normal file
46
ristretto/config.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package ristretto
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// NumCounters number of keys to track frequency of (10M).
|
||||
NumCounters int64
|
||||
|
||||
// MaxCost maximum cost of cache (1GB).
|
||||
MaxCost int64
|
||||
|
||||
// BufferItems number of keys per Get buffer.
|
||||
BufferItems int64
|
||||
DefaultCost int64
|
||||
}
|
||||
|
||||
var ConfigDefault = Config{
|
||||
NumCounters: 1e7,
|
||||
MaxCost: 1 << 30,
|
||||
BufferItems: 64,
|
||||
DefaultCost: 1,
|
||||
}
|
||||
|
||||
func configDefault(config ...Config) Config {
|
||||
if len(config) < 1 {
|
||||
return ConfigDefault
|
||||
}
|
||||
cfg := config[0]
|
||||
|
||||
if cfg.NumCounters < 1 {
|
||||
cfg.NumCounters = ConfigDefault.NumCounters
|
||||
}
|
||||
|
||||
if cfg.MaxCost < 1 {
|
||||
cfg.MaxCost = ConfigDefault.MaxCost
|
||||
}
|
||||
|
||||
if cfg.BufferItems < 1 {
|
||||
cfg.BufferItems = ConfigDefault.BufferItems
|
||||
}
|
||||
|
||||
if cfg.DefaultCost == 0 {
|
||||
cfg.DefaultCost = ConfigDefault.DefaultCost
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
11
ristretto/go.mod
Normal file
11
ristretto/go.mod
Normal file
@@ -0,0 +1,11 @@
|
||||
module github.com/gofiber/storage/ristretto
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgraph-io/ristretto v0.1.0
|
||||
github.com/gofiber/utils v0.1.2
|
||||
github.com/golang/glog v1.0.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
)
|
30
ristretto/go.sum
Normal file
30
ristretto/go.sum
Normal file
@@ -0,0 +1,30 @@
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI=
|
||||
github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
|
||||
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
96
ristretto/ristretto.go
Normal file
96
ristretto/ristretto.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package ristretto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/dgraph-io/ristretto"
|
||||
)
|
||||
|
||||
// Storage interface that is implemented by storage providers.
|
||||
type Storage struct {
|
||||
cache *ristretto.Cache
|
||||
defaultCost int64
|
||||
}
|
||||
|
||||
// New creates a new storage.
|
||||
func New(config ...Config) *Storage {
|
||||
cfg := configDefault(config...)
|
||||
cache, err := ristretto.NewCache(&ristretto.Config{
|
||||
NumCounters: cfg.NumCounters,
|
||||
MaxCost: cfg.MaxCost,
|
||||
BufferItems: cfg.BufferItems,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
store := &Storage{
|
||||
cache: cache,
|
||||
defaultCost: cfg.DefaultCost,
|
||||
}
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
// Get gets the value for the given key.
|
||||
// `nil, nil` is returned when the key does not exist
|
||||
func (s *Storage) Get(key string) ([]byte, error) {
|
||||
if len(key) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
item, found := s.cache.Get(key)
|
||||
if !found {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
buf, asserted := item.([]byte)
|
||||
if !asserted {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// Set stores the given value for the given key along
|
||||
// with an expiration value, time.Time{} means no expiration.
|
||||
// Empty key or value will be ignored without an error.
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
if len(key) <= 0 || len(val) <= 0 {
|
||||
return nil
|
||||
}
|
||||
saved := s.cache.SetWithTTL(key, val, s.defaultCost, exp)
|
||||
if !saved {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes the value for the given key.
|
||||
// It returns no error if the storage does not contain the key,
|
||||
func (s *Storage) Delete(key string) error {
|
||||
if len(key) <= 0 {
|
||||
return nil
|
||||
}
|
||||
s.cache.Del(key)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset resets the storage and delete all keys.
|
||||
func (s *Storage) Reset() error {
|
||||
s.cache.Clear()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close closes the storage and will stop any running garbage
|
||||
// collectors and open connections.
|
||||
func (s *Storage) Close() error {
|
||||
s.cache.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return database client
|
||||
func (s *Storage) Conn() *ristretto.Cache {
|
||||
return s.cache
|
||||
}
|
132
ristretto/ristretto_test.go
Normal file
132
ristretto/ristretto_test.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package ristretto_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/storage/ristretto"
|
||||
"github.com/gofiber/utils"
|
||||
)
|
||||
|
||||
var testStore = ristretto.New()
|
||||
|
||||
func Test_Ristretto_Set(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Set_Override(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Get(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
// stabilize with some delay in between -> bug already communicated
|
||||
time.Sleep(10000)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, val, result)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Set_Expiration(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
exp = 1 * time.Second
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, exp)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
testStore.Reset()
|
||||
}
|
||||
|
||||
func Test_Ristretto_Get_Expired(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Get_NotExist(t *testing.T) {
|
||||
|
||||
result, err := testStore.Get("notexist")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Delete(t *testing.T) {
|
||||
var (
|
||||
key = "john"
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set(key, val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
// stabilize with some delay in between -> bug already communicated
|
||||
time.Sleep(10000)
|
||||
|
||||
err = testStore.Delete(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get(key)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Reset(t *testing.T) {
|
||||
var (
|
||||
val = []byte("doe")
|
||||
)
|
||||
|
||||
err := testStore.Set("john1", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Set("john2", val, 0)
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
err = testStore.Reset()
|
||||
utils.AssertEqual(t, nil, err)
|
||||
|
||||
result, err := testStore.Get("john1")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
|
||||
result, err = testStore.Get("john2")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Ristretto_Close(t *testing.T) {
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
||||
func Test_Ristretto_Conn(t *testing.T) {
|
||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||
}
|
109
s3/README.md
Normal file
109
s3/README.md
Normal file
@@ -0,0 +1,109 @@
|
||||
# S3
|
||||
|
||||
A S3 storage driver using [aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2).
|
||||
|
||||
**Note:** If config fields of credentials not given, credentials are using from the environment variables, ~/.aws/credentials, or EC2 instance role. If config fields of credentials given, credentials are using from config. Look at: [specifying credentials](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials)
|
||||
|
||||
|
||||
### Table of Contents
|
||||
- [Signatures](#signatures)
|
||||
- [Installation](#installation)
|
||||
- [Examples](#examples)
|
||||
- [Config](#config)
|
||||
- [Default Config](#default-config)
|
||||
|
||||
### Signatures
|
||||
```go
|
||||
func New(config ...Config) Storage
|
||||
func (s *Storage) Get(key string) ([]byte, error)
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||
func (s *Storage) Delete(key string) error
|
||||
func (s *Storage) Reset() error
|
||||
func (s *Storage) Close() error
|
||||
func (s *Storage) Conn() *s3.Client
|
||||
```
|
||||
### Installation
|
||||
S3 is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||
```bash
|
||||
go mod init github.com/<user>/<repo>
|
||||
```
|
||||
And then install the s3 implementation:
|
||||
```bash
|
||||
go get github.com/gofiber/storage/s3
|
||||
```
|
||||
|
||||
### Examples
|
||||
Import the storage package.
|
||||
```go
|
||||
import "github.com/gofiber/storage/s3"
|
||||
```
|
||||
|
||||
You can use the following possibilities to create a storage:
|
||||
```go
|
||||
// Initialize default config
|
||||
store := s3.New()
|
||||
|
||||
// Initialize custom config
|
||||
store := s3.New(s3.Config{
|
||||
Bucket: "my-bucket-url",
|
||||
Endpoint: "my-endpoint",
|
||||
Region: "my-region",
|
||||
Reset: false,
|
||||
})
|
||||
```
|
||||
|
||||
### Config
|
||||
```go
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// S3 bucket name
|
||||
Bucket string
|
||||
|
||||
// AWS endpoint
|
||||
Endpoint string
|
||||
|
||||
// AWS region
|
||||
Region string
|
||||
|
||||
// Request timeout
|
||||
//
|
||||
// Optional. Default is 0 (no timeout)
|
||||
RequestTimeout time.Duration
|
||||
|
||||
// Reset clears any existing keys in existing Bucket
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||
//
|
||||
// Optional. Default is Credentials{}
|
||||
Credentials Credentials
|
||||
|
||||
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||
//
|
||||
// Optional. Default is 3
|
||||
MaxAttempts int
|
||||
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
AccessKey string
|
||||
SecretAccessKey string
|
||||
}
|
||||
```
|
||||
|
||||
### Default Config
|
||||
The default configuration lacks Bucket, Region, and Endpoint which are all required and must be overwritten:
|
||||
```go
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Bucket: "",
|
||||
Region: "",
|
||||
Endpoint: "",
|
||||
Credentials: Credentials{},
|
||||
MaxAttempts: 3,
|
||||
RequestTimeout: 0,
|
||||
Reset: false,
|
||||
}
|
||||
```
|
69
s3/config.go
Normal file
69
s3/config.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package s3
|
||||
|
||||
import "time"
|
||||
|
||||
// Config defines the config for storage.
|
||||
type Config struct {
|
||||
// S3 bucket name
|
||||
Bucket string
|
||||
|
||||
// AWS endpoint
|
||||
Endpoint string
|
||||
|
||||
// AWS region
|
||||
Region string
|
||||
|
||||
// Request timeout
|
||||
//
|
||||
// Optional. Default is 0 (no timeout)
|
||||
RequestTimeout time.Duration
|
||||
|
||||
// Reset clears any existing keys in existing Bucket
|
||||
//
|
||||
// Optional. Default is false
|
||||
Reset bool
|
||||
|
||||
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||
//
|
||||
// Optional. Default is Credentials{}
|
||||
Credentials Credentials
|
||||
|
||||
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||
//
|
||||
// Optional. Default is 3
|
||||
MaxAttempts int
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
AccessKey string
|
||||
SecretAccessKey string
|
||||
}
|
||||
|
||||
// ConfigDefault is the default config
|
||||
var ConfigDefault = Config{
|
||||
Bucket: "",
|
||||
Region: "",
|
||||
Endpoint: "",
|
||||
Credentials: Credentials{},
|
||||
MaxAttempts: 3,
|
||||
RequestTimeout: 0,
|
||||
Reset: false,
|
||||
}
|
||||
|
||||
// Helper function to set default values
|
||||
func configDefault(config ...Config) Config {
|
||||
// Return default config if nothing provided
|
||||
if len(config) < 1 {
|
||||
return ConfigDefault
|
||||
}
|
||||
|
||||
// Override default config
|
||||
cfg := config[0]
|
||||
|
||||
// Set default values
|
||||
if cfg.Bucket == "" {
|
||||
cfg.Bucket = ConfigDefault.Bucket
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
12
s3/go.mod
Normal file
12
s3/go.mod
Normal file
@@ -0,0 +1,12 @@
|
||||
module github.com/gofiber/storage/s3
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.14
|
||||
github.com/aws/aws-sdk-go-v2/config v1.17.5
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.18
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.31
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.9
|
||||
github.com/gofiber/utils v0.1.2
|
||||
)
|
54
s3/go.sum
Normal file
54
s3/go.sum
Normal file
@@ -0,0 +1,54 @@
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.14 h1:db6GvO4Z2UqHt5gvT0lr6J5x5P+oQ7bdRzczVaRekMU=
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.14/go.mod h1:s/G+UV29dECbF5rf+RNj1xhlmvoNurGSr+McVSRj59w=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.7 h1:/kxQjtZc7j67TMW/aFJfpsrlvFhsq3lNbX41qN5Tro4=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.7/go.mod h1:KvHyNlxCjo9Y1Fsz+6Ex9OaN2jKijvMxzROxpW5Vctc=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.17.5 h1:+NS1BWvprx7nHcIk5o32LrZgifs/7Pm1V2nWjQgZ2H0=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.17.5/go.mod h1:H0cvPNDO3uExWts/9PDhD/0ne2esu1uaIulwn1vkwxM=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.18 h1:HF62tbhARhgLfvmfwUbL9qZ+dkbZYzbFdxBb3l5gr7Q=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.18/go.mod h1:O7n/CPagQ33rfG6h7vR/W02ammuc5CrsSM22cNZp9so=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15 h1:nkQ+aI0OCeYfzrBipL6ja/6VEbUnHQoZHBHtoK+Nzxw=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15/go.mod h1:Oz2/qWINxIgSmoZT9adpxJy2UhpcOAI3TIyWgYMVSz0=
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.31 h1:Ggf7rvFS1s3/Nauv2mokAY+RfKsCAHvfiiZJoYd0lV0=
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.31/go.mod h1:Iv2xOFdy8aFIxVKEdzo9puLXFaGNnjx5xzGYIlGzhuY=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21 h1:gRIXnmAVNyoRQywdNtpAkgY+f30QNzgF53Q5OobNZZs=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21/go.mod h1:XsmHMV9c512xgsW01q7H0ut+UQQQpWX8QsFbdLHDwaU=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15 h1:noAhOo2mMDyYhTx99aYPvQw16T3fQ/DiKAv9fzpIKH8=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15/go.mod h1:kjJ4CyD9M3Wq88GYg3IPfj67Rs0Uvz8aXK7MJ8BvE4I=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22 h1:nF+E8HfYpOMw6M5oA9efB602VC00IHNQnB5CmFvZPvA=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22/go.mod h1:tltHVGy977LrSOgRR5aV9+miyno/Gul/uJNPKS7FzP4=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.12 h1:i0Tig01XGhXo/ki1BZUbRMhusGVCScEvaWdlFRWxAKk=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.12/go.mod h1:QPoxYMISvteeDH4A89gGWWlCA/Bz6oUDF7hGdPdOPuE=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8 h1:NpixDFjwr1BZg2459mX07NZnVYGGp62Lb6AtVGOLNlo=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8/go.mod h1:MJUgrBPfGB4yk2uWoImVqd9cklry1hATyJV/7gJ6JTk=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.16 h1:kHc3TqW5kJ9Vfd9YEwywrNrL87DItpvAohlP+OuzABY=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.16/go.mod h1:U/9ZCgIx6x6NTdFRt60qO3gxUxBx4gRi+S/Yc/n+7vc=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15 h1:xlf0J6DUgAj/ocvKQxCmad8Bu1lJuRbt5Wu+4G1xw1g=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15/go.mod h1:ZVJ7ejRl4+tkWMuCwjXoy0jd8fF5u3RCyWjSVjUIvQE=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.15 h1:v9f7NY7D19ssE2EM+m9yT1m5zdWHuRAsZaFh24GAkOk=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.15/go.mod h1:gXfPo3nMoCbJKTZKDxv3rUhcYJjYT/K++jEqcWHjD/Q=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.9 h1:imVonvre+AHMcDc3B9bPHHy5ZgjIkkYc/jyDBK8FHFw=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.9/go.mod h1:0Gfmg8gjPhVPy/IXkLAmyKZbAue+2s11BWKH+oXggmg=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.21 h1:7jUFr+7F4MzIjCZzy7ygRtXFQcQ0kAbT0gUvtUeAdyU=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.21/go.mod h1:q8nYq51W3gpZempYsAD83fPRlrOTMCwN+Ahg4BKFTXQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3 h1:UTTPNP3/WzZa7hoHP3Szb/Yl0bM3NoBrf5ABy1OArUM=
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3/go.mod h1:+IF75RMJh0+zqTGXGshyEGRsU2ImqWv6UuHGkHl6kEo=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.17 h1:LVM2jzEQ8mhb2dhrFl4PJ3sa5+KcKT01dsMk2Ma9/FU=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.17/go.mod h1:bQujK1n0V1D1Gz5uII1jaB1WDvhj4/T3tElsJnVXCR0=
|
||||
github.com/aws/smithy-go v1.13.2 h1:TBLKyeJfXTrTXRHmsv4qWt9IQGYyWThLYaJWSahTOGE=
|
||||
github.com/aws/smithy-go v1.13.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user