mirror of
https://github.com/gofiber/storage.git
synced 2025-09-27 21:02:20 +08:00
Compare commits
159 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
20ba96f664 | ||
![]() |
e8a33f952c | ||
![]() |
c850eaff51 | ||
![]() |
2bd20cfa5a | ||
![]() |
2ee234e829 | ||
![]() |
1137fb9036 | ||
![]() |
a9dc413939 | ||
![]() |
825eb938c2 | ||
![]() |
e5eb169055 | ||
![]() |
4e6f1c95ff | ||
![]() |
c010712741 | ||
![]() |
161724ceae | ||
![]() |
6627d9d1ee | ||
![]() |
d533947dca | ||
![]() |
595b1917f3 | ||
![]() |
f112c6ddff | ||
![]() |
070dec8c74 | ||
![]() |
8125d5ae39 | ||
![]() |
45e450a3d8 | ||
![]() |
737624d914 | ||
![]() |
1401f6b804 | ||
![]() |
8c679bf3a2 | ||
![]() |
fc7eb4fd27 | ||
![]() |
7486445385 | ||
![]() |
dfdfd7fbf3 | ||
![]() |
87862b1ac6 | ||
![]() |
bbfc356c01 | ||
![]() |
d8d446b1a5 | ||
![]() |
6ba900f18c | ||
![]() |
dc7bef5d10 | ||
![]() |
dff3b2aa26 | ||
![]() |
560664ab5a | ||
![]() |
68c1b99eac | ||
![]() |
998df25440 | ||
![]() |
b59617e2a6 | ||
![]() |
c6162ed666 | ||
![]() |
31f94813cf | ||
![]() |
1f256f5391 | ||
![]() |
a299404c1b | ||
![]() |
72b47afe1e | ||
![]() |
ce744287b7 | ||
![]() |
9f14918a5a | ||
![]() |
11aacc8bd1 | ||
![]() |
01da118ae2 | ||
![]() |
94d968b7f7 | ||
![]() |
57c24a378b | ||
![]() |
fdea0f9267 | ||
![]() |
58364534e9 | ||
![]() |
bc10416921 | ||
![]() |
c30115270c | ||
![]() |
2c315e1ce7 | ||
![]() |
ff64bffed1 | ||
![]() |
34200e124b | ||
![]() |
20a6c8a79b | ||
![]() |
d2569fbe93 | ||
![]() |
bf76d31f6c | ||
![]() |
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 |
76
.github/dependabot.yml
vendored
76
.github/dependabot.yml
vendored
@@ -2,129 +2,93 @@
|
|||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/" # Location of package manifests
|
directory: "/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/arangodb/" # Location of package manifests
|
directory: "/arangodb/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/badger/" # Location of package manifests
|
directory: "/badger/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/dynamodb/" # Location of package manifests
|
directory: "/dynamodb/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/memcache/" # Location of package manifests
|
directory: "/memcache/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/memory/" # Location of package manifests
|
directory: "/memory/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/mongodb/" # Location of package manifests
|
directory: "/mongodb/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/mysql/" # Location of package manifests
|
directory: "/mysql/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/postgres/" # Location of package manifests
|
directory: "/postgres/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/redis/" # Location of package manifests
|
directory: "/redis/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/sqlite3/" # Location of package manifests
|
directory: "/sqlite3/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/ristretto/" # Location of package manifests
|
directory: "/ristretto/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/s3/" # Location of package manifests
|
directory: "/s3/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/bbolt/" # Location of package manifests
|
directory: "/bbolt/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
|
3
.github/release-drafter.yml
vendored
3
.github/release-drafter.yml
vendored
@@ -16,6 +16,7 @@ categories:
|
|||||||
- '📒 Documentation'
|
- '📒 Documentation'
|
||||||
change-template: '- $TITLE (#$NUMBER)'
|
change-template: '- $TITLE (#$NUMBER)'
|
||||||
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||||
|
sort-by: 'title'
|
||||||
version-resolver:
|
version-resolver:
|
||||||
major:
|
major:
|
||||||
labels:
|
labels:
|
||||||
@@ -90,4 +91,6 @@ autolabeler:
|
|||||||
template: |
|
template: |
|
||||||
$CHANGES
|
$CHANGES
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
||||||
|
|
||||||
Thank you $CONTRIBUTORS for making this update possible.
|
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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
# We must fetch at least the immediate parents so that if this is
|
# We must fetch at least the immediate parents so that if this is
|
||||||
# a pull request then we can checkout the head.
|
# a pull request then we can checkout the head.
|
||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- 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
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
with:
|
with:
|
||||||
languages: go
|
languages: go
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# 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)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -51,4 +51,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
||||||
|
39
.github/workflows/dependabot_automerge.yml
vendored
Normal file
39
.github/workflows/dependabot_automerge.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Dependabot auto-merge
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
wait_for_checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Wait for check is finished
|
||||||
|
uses: lewagon/wait-on-check-action@v1.1.2
|
||||||
|
id: wait_for_checks
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
running-workflow-name: wait_for_checks
|
||||||
|
check-regexp: Tests
|
||||||
|
repo-token: ${{ secrets.PR_TOKEN }}
|
||||||
|
wait-interval: 10
|
||||||
|
dependabot:
|
||||||
|
needs: [wait_for_checks]
|
||||||
|
name: Dependabot auto-merge
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||||
|
steps:
|
||||||
|
- name: Dependabot metadata
|
||||||
|
id: metadata
|
||||||
|
uses: dependabot/fetch-metadata@v1.3.4
|
||||||
|
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 review --approve "$PR_URL"
|
||||||
|
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
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Golint
|
- name: Run Golint
|
||||||
uses: reviewdog/action-golangci-lint@v1
|
uses: reviewdog/action-golangci-lint@v2
|
||||||
with:
|
with:
|
||||||
golangci_lint_flags: "--tests=false"
|
golangci_lint_flags: "--tests=false"
|
||||||
|
4
.github/workflows/security.yml
vendored
4
.github/workflows/security.yml
vendored
@@ -5,9 +5,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '^1.17.6'
|
go-version: '^1.17.6'
|
||||||
- name: Install Gosec
|
- name: Install Gosec
|
||||||
|
98
.github/workflows/test-arangodb.yml
vendored
98
.github/workflows/test-arangodb.yml
vendored
@@ -1,49 +1,51 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: ArangoDB
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests ArangoDB"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
arangodb:
|
arangodb:
|
||||||
image: 'arangodb:latest'
|
image: 'arangodb:latest'
|
||||||
env:
|
env:
|
||||||
ARANGO_NO_AUTH: 1
|
ARANGO_NO_AUTH: 1
|
||||||
ports:
|
ports:
|
||||||
- '8529:8529'
|
- '8529:8529'
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
- name: Run Test
|
||||||
- name: Run Test
|
run: cd ./arangodb && go test ./... -v -race
|
||||||
run: cd ./arangodb && go test ./... -v -race
|
|
||||||
|
82
.github/workflows/test-bbolt.yml
vendored
82
.github/workflows/test-bbolt.yml
vendored
@@ -1,40 +1,44 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Bbolt
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Bbolt"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.16.x
|
- 1.14.x
|
||||||
- 1.17.x
|
- 1.16.x
|
||||||
platform:
|
- 1.19.x
|
||||||
- ubuntu-latest
|
platform:
|
||||||
- windows-latest
|
- ubuntu-latest
|
||||||
steps:
|
- windows-latest
|
||||||
- name: Install Go
|
steps:
|
||||||
uses: actions/setup-go@v1
|
- name: Install Go
|
||||||
with:
|
uses: actions/setup-go@v3
|
||||||
go-version: '${{ matrix.go-version }}'
|
with:
|
||||||
- name: Setup Golang caches
|
go-version: '${{ matrix.go-version }}'
|
||||||
uses: actions/cache@v3
|
- name: Setup Golang caches
|
||||||
with:
|
uses: actions/cache@v3
|
||||||
# In order:
|
with:
|
||||||
# * Module download cache
|
# In order:
|
||||||
# * Build cache (Linux)
|
# * Module download cache
|
||||||
# * Build cache (Mac)
|
# * Build cache (Linux)
|
||||||
# * Build cache (Windows)
|
# * Build cache (Mac)
|
||||||
path: |
|
# * Build cache (Windows)
|
||||||
~/go/pkg/mod
|
path: |
|
||||||
~/.cache/go-build
|
~/go/pkg/mod
|
||||||
~/Library/Caches/go-build
|
~/.cache/go-build
|
||||||
~\AppData\Local\go-build
|
~/Library/Caches/go-build
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
~\AppData\Local\go-build
|
||||||
restore-keys: |
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
restore-keys: |
|
||||||
- name: Fetch Repository
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
uses: actions/checkout@v2
|
- name: Fetch Repository
|
||||||
- name: Run Test
|
uses: actions/checkout@v3
|
||||||
run: cd ./bbolt && go mod tidy && go test ./... -v -race
|
- name: Run Test
|
||||||
|
run: cd ./bbolt && go mod tidy && go test ./... -v -race
|
||||||
|
94
.github/workflows/test-dynamodb.yml
vendored
94
.github/workflows/test-dynamodb.yml
vendored
@@ -1,47 +1,49 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: DynamoDB
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests DynamoDB"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mongo:
|
mongo:
|
||||||
image: 'amazon/dynamodb-local:latest'
|
image: 'amazon/dynamodb-local:latest'
|
||||||
ports:
|
ports:
|
||||||
- '8000:8000'
|
- '8000:8000'
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
- name: Run Test
|
||||||
- name: Run Test
|
run: cd ./dynamodb && go test ./... -v -race
|
||||||
run: cd ./dynamodb && go test ./... -v -race
|
|
||||||
|
94
.github/workflows/test-memcache.yml
vendored
94
.github/workflows/test-memcache.yml
vendored
@@ -1,47 +1,49 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Memcache
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Memcache"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mongo:
|
mongo:
|
||||||
image: 'memcached:latest'
|
image: 'memcached:latest'
|
||||||
ports:
|
ports:
|
||||||
- '11211:11211'
|
- '11211:11211'
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
- name: Run Test
|
||||||
- name: Run Test
|
run: cd ./memcache && go test ./... -v -race
|
||||||
run: cd ./memcache && go test ./... -v -race
|
|
||||||
|
94
.github/workflows/test-mongodb.yml
vendored
94
.github/workflows/test-mongodb.yml
vendored
@@ -1,47 +1,49 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: MongoDB
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Mongodb"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mongo:
|
mongo:
|
||||||
image: 'mongo:latest'
|
image: 'mongo:latest'
|
||||||
ports:
|
ports:
|
||||||
- '27017:27017'
|
- '27017:27017'
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
- name: Run Test
|
||||||
- name: Run Test
|
run: cd ./mongodb && go test ./... -v -race
|
||||||
run: cd ./mongodb && go test ./... -v -race
|
|
||||||
|
118
.github/workflows/test-mysql.yml
vendored
118
.github/workflows/test-mysql.yml
vendored
@@ -1,59 +1,61 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: MySQL
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests MySQL"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: 'mysql:latest'
|
image: 'mysql:latest'
|
||||||
env:
|
env:
|
||||||
MYSQL_DATABASE: fiber
|
MYSQL_DATABASE: fiber
|
||||||
MYSQL_USER: username
|
MYSQL_USER: username
|
||||||
MYSQL_PASSWORD: password
|
MYSQL_PASSWORD: password
|
||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
ports:
|
ports:
|
||||||
- '3306:3306'
|
- '3306:3306'
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
|
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
|
||||||
5s --health-retries 5
|
5s --health-retries 5
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
- name: Run Test
|
||||||
- name: Run Test
|
run: cd ./mysql && go test ./... -v -race
|
||||||
run: cd ./mysql && go test ./... -v -race
|
env:
|
||||||
env:
|
MYSQL_USERNAME: username
|
||||||
MYSQL_USERNAME: username
|
MYSQL_PASSWORD: password
|
||||||
MYSQL_PASSWORD: password
|
MYSQL_DATABASE: fiber
|
||||||
MYSQL_DATABASE: fiber
|
|
||||||
|
116
.github/workflows/test-postgres.yml
vendored
116
.github/workflows/test-postgres.yml
vendored
@@ -1,58 +1,60 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Postgres
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Postgres"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: 'postgres:latest'
|
image: 'postgres:latest'
|
||||||
ports:
|
ports:
|
||||||
- '5432:5432'
|
- '5432:5432'
|
||||||
env:
|
env:
|
||||||
POSTGRES_DB: fiber
|
POSTGRES_DB: fiber
|
||||||
POSTGRES_USER: username
|
POSTGRES_USER: username
|
||||||
POSTGRES_PASSWORD: password
|
POSTGRES_PASSWORD: password
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
|
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
- name: Run Test
|
||||||
- name: Run Test
|
run: cd ./postgres && go test ./... -v -race
|
||||||
run: cd ./postgres && go test ./... -v -race
|
env:
|
||||||
env:
|
POSTGRES_DATABASE: fiber
|
||||||
POSTGRES_DATABASE: fiber
|
POSTGRES_USERNAME: username
|
||||||
POSTGRES_USERNAME: username
|
POSTGRES_PASSWORD: password
|
||||||
POSTGRES_PASSWORD: password
|
|
||||||
|
110
.github/workflows/test-redis.yml
vendored
110
.github/workflows/test-redis.yml
vendored
@@ -1,60 +1,62 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Redis
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Redis"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Fetch Repository
|
||||||
- name: Fetch Repository
|
uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Setup Redis
|
- name: Setup Redis
|
||||||
uses: shogo82148/actions-setup-redis@v1
|
uses: shogo82148/actions-setup-redis@v1
|
||||||
with:
|
with:
|
||||||
redis-version: '6.x'
|
redis-version: '6.x'
|
||||||
auto-start: 'false'
|
auto-start: 'false'
|
||||||
redis-port: '6379'
|
redis-port: '6379'
|
||||||
redis-tls-port: '6380'
|
redis-tls-port: '6380'
|
||||||
|
|
||||||
- name: Run Redis
|
- name: Run Redis
|
||||||
run: |
|
run: |
|
||||||
redis-server --tls-port 6380 --port 6379 \
|
redis-server --tls-port 6380 --port 6379 \
|
||||||
--tls-cert-file ./redis/tests/tls/redis.crt \
|
--tls-cert-file ./redis/tests/tls/redis.crt \
|
||||||
--tls-key-file ./redis/tests/tls/redis.key \
|
--tls-key-file ./redis/tests/tls/redis.key \
|
||||||
--tls-ca-cert-file ./redis/tests/tls/ca.crt&
|
--tls-ca-cert-file ./redis/tests/tls/ca.crt&
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
|
||||||
- name: Setup Golang caches
|
- name: Setup Golang caches
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
# In order:
|
# In order:
|
||||||
# * Module download cache
|
# * Module download cache
|
||||||
# * Build cache (Linux)
|
# * Build cache (Linux)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Windows)
|
# * Build cache (Windows)
|
||||||
path: |
|
path: |
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
~/.cache/go-build
|
~/.cache/go-build
|
||||||
~/Library/Caches/go-build
|
~/Library/Caches/go-build
|
||||||
~\AppData\Local\go-build
|
~\AppData\Local\go-build
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./redis && go test ./... -v -race
|
run: cd ./redis && go test ./... -v -race
|
||||||
|
82
.github/workflows/test-ristretto.yml
vendored
82
.github/workflows/test-ristretto.yml
vendored
@@ -1,40 +1,44 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Ristretto
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Ristretto"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.16.x
|
- 1.14.x
|
||||||
- 1.17.x
|
- 1.16.x
|
||||||
platform:
|
- 1.19.x
|
||||||
- ubuntu-latest
|
platform:
|
||||||
- windows-latest
|
- ubuntu-latest
|
||||||
steps:
|
- windows-latest
|
||||||
- name: Install Go
|
steps:
|
||||||
uses: actions/setup-go@v1
|
- name: Install Go
|
||||||
with:
|
uses: actions/setup-go@v3
|
||||||
go-version: '${{ matrix.go-version }}'
|
with:
|
||||||
- name: Setup Golang caches
|
go-version: '${{ matrix.go-version }}'
|
||||||
uses: actions/cache@v3
|
- name: Setup Golang caches
|
||||||
with:
|
uses: actions/cache@v3
|
||||||
# In order:
|
with:
|
||||||
# * Module download cache
|
# In order:
|
||||||
# * Build cache (Linux)
|
# * Module download cache
|
||||||
# * Build cache (Mac)
|
# * Build cache (Linux)
|
||||||
# * Build cache (Windows)
|
# * Build cache (Mac)
|
||||||
path: |
|
# * Build cache (Windows)
|
||||||
~/go/pkg/mod
|
path: |
|
||||||
~/.cache/go-build
|
~/go/pkg/mod
|
||||||
~/Library/Caches/go-build
|
~/.cache/go-build
|
||||||
~\AppData\Local\go-build
|
~/Library/Caches/go-build
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
~\AppData\Local\go-build
|
||||||
restore-keys: |
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
restore-keys: |
|
||||||
- name: Fetch Repository
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
uses: actions/checkout@v2
|
- name: Fetch Repository
|
||||||
- name: Run Test
|
uses: actions/checkout@v3
|
||||||
run: cd ./ristretto && go mod tidy && go test ./... -v -race
|
- name: Run Test
|
||||||
|
run: cd ./ristretto && go mod tidy && go test ./... -v -race
|
||||||
|
98
.github/workflows/test-s3.yml
vendored
98
.github/workflows/test-s3.yml
vendored
@@ -1,51 +1,53 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: S3
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests S3"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
steps:
|
||||||
steps:
|
- name: Install MinIO
|
||||||
- name: Install MinIO
|
run: |
|
||||||
run: |
|
docker run -d -p 9000:9000 --name minio minio/minio server /data
|
||||||
docker run -d -p 9000:9000 --name minio minio/minio server /data
|
|
||||||
|
|
||||||
export AWS_ACCESS_KEY_ID=minioadmin
|
export AWS_ACCESS_KEY_ID=minioadmin
|
||||||
export AWS_SECRET_ACCESS_KEY=minioadmin
|
export AWS_SECRET_ACCESS_KEY=minioadmin
|
||||||
export AWS_EC2_METADATA_DISABLED=true
|
export AWS_EC2_METADATA_DISABLED=true
|
||||||
|
|
||||||
aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://testbucket
|
aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://testbucket
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
- name: Setup Golang caches
|
- name: Setup Golang caches
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
# In order:
|
# In order:
|
||||||
# * Module download cache
|
# * Module download cache
|
||||||
# * Build cache (Linux)
|
# * Build cache (Linux)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Windows)
|
# * Build cache (Windows)
|
||||||
path: |
|
path: |
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
~/.cache/go-build
|
~/.cache/go-build
|
||||||
~/Library/Caches/go-build
|
~/Library/Caches/go-build
|
||||||
~\AppData\Local\go-build
|
~\AppData\Local\go-build
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./s3 && go test ./... -v -race
|
run: cd ./s3 && go test ./... -v -race
|
||||||
|
97
.github/workflows/test.yml
vendored
97
.github/workflows/test.yml
vendored
@@ -1,46 +1,53 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Local Storage
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Local Storage"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.16.x
|
||||||
- 1.16.x
|
- 1.19.x
|
||||||
- 1.17.x
|
platform:
|
||||||
platform:
|
- ubuntu-latest
|
||||||
- ubuntu-latest
|
- windows-latest
|
||||||
- windows-latest
|
runs-on: '${{ matrix.platform }}'
|
||||||
runs-on: '${{ matrix.platform }}'
|
steps:
|
||||||
steps:
|
- name: Install Go
|
||||||
- name: Install Go
|
uses: actions/setup-go@v3
|
||||||
uses: actions/setup-go@v1
|
with:
|
||||||
with:
|
go-version: '${{ matrix.go-version }}'
|
||||||
go-version: '${{ matrix.go-version }}'
|
- name: Setup Golang caches
|
||||||
- name: Setup Golang caches
|
uses: actions/cache@v3
|
||||||
uses: actions/cache@v3
|
with:
|
||||||
with:
|
# In order:
|
||||||
# In order:
|
# * Module download cache
|
||||||
# * Module download cache
|
# * Build cache (Linux)
|
||||||
# * Build cache (Linux)
|
# * Build cache (Mac)
|
||||||
# * Build cache (Mac)
|
# * Build cache (Windows)
|
||||||
# * Build cache (Windows)
|
path: |
|
||||||
path: |
|
~/go/pkg/mod
|
||||||
~/go/pkg/mod
|
~/.cache/go-build
|
||||||
~/.cache/go-build
|
~/Library/Caches/go-build
|
||||||
~/Library/Caches/go-build
|
~\AppData\Local\go-build
|
||||||
~\AppData\Local\go-build
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
restore-keys: |
|
||||||
restore-keys: |
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Test Badger
|
- name: Test Badger
|
||||||
run: cd ./badger && go test ./... -v -race
|
run: cd ./badger && go test ./... -v -race
|
||||||
- name: Test Memory
|
- name: Test Memory
|
||||||
run: cd ./memory && go test ./... -v -race
|
run: cd ./memory && go test ./... -v -race
|
||||||
- name: Test SQLite3
|
- name: Test SQLite3 - with -race check
|
||||||
run: cd ./sqlite3 && go test ./... -v -race
|
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
|
||||||
|
@@ -57,6 +57,9 @@ type Storage interface {
|
|||||||
* [Badger](/badger) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
* [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">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</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">
|
* [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">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/DynamoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
@@ -83,7 +86,4 @@ type Storage interface {
|
|||||||
</a>
|
</a>
|
||||||
* [S3](/s3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22S3%22">
|
* [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">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/S3?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>
|
</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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() driver.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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
|
||||||
|
}
|
||||||
|
@@ -132,3 +132,7 @@ func Test_ARANGODB_Non_UTF8(t *testing.T) {
|
|||||||
func Test_ARANGODB_Close(t *testing.T) {
|
func Test_ARANGODB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
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
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/arangodb/go-driver v1.3.2
|
github.com/arangodb/go-driver v1.4.0
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v0.1.2
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
github.com/arangodb/go-driver v1.3.2 h1:07cmMqPqEl+/MlosjFtVVakEbkPqBSUvw9S9/atX0+4=
|
github.com/arangodb/go-driver v1.4.0 h1:uNCbVYkr5ZP3hIVUP6wqjOVyhMYOL9NDmR762tIeYP0=
|
||||||
github.com/arangodb/go-driver v1.3.2/go.mod h1:5GAx3XvK72DJPhJgyjZOtYAGc4SpY7rZDb3LyhCvLcQ=
|
github.com/arangodb/go-driver v1.4.0/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 h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g=
|
||||||
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
|
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=
|
github.com/coreos/go-iptables v0.4.3/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
|
||||||
|
@@ -19,6 +19,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *badger.DB
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -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) {
|
func Test_Badger_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Badger_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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *bbolt.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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:
|
||||||
@@ -64,7 +65,7 @@ type Config struct {
|
|||||||
// Timeout is the amount of time to wait to obtain a file lock.
|
// Timeout is the amount of time to wait to obtain a file lock.
|
||||||
// Only available on Darwin and Linux.
|
// Only available on Darwin and Linux.
|
||||||
//
|
//
|
||||||
// Optional. Default is 0 (no timeout)
|
// Optional. Default is 60 * time.Second.
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
|
||||||
// Open database in read-only mode.
|
// Open database in read-only mode.
|
||||||
@@ -85,7 +86,7 @@ type Config struct {
|
|||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Database: "fiber.db",
|
Database: "fiber.db",
|
||||||
Bucket: "fiber_storage",
|
Bucket: "fiber_storage",
|
||||||
Timeout: 0,
|
Timeout: 60 * time.Second,
|
||||||
ReadOnly: false,
|
ReadOnly: false,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
}
|
}
|
||||||
|
@@ -104,3 +104,8 @@ func (s *Storage) Reset() error {
|
|||||||
func (s *Storage) Close() error {
|
func (s *Storage) Close() error {
|
||||||
return s.conn.Close()
|
return s.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *bbolt.DB {
|
||||||
|
return s.conn
|
||||||
|
}
|
||||||
|
@@ -95,3 +95,7 @@ func Test_Bbolt_Reset(t *testing.T) {
|
|||||||
func Test_Bbolt_Close(t *testing.T) {
|
func Test_Bbolt_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,7 +17,7 @@ type Config struct {
|
|||||||
// Timeout is the amount of time to wait to obtain a file lock.
|
// Timeout is the amount of time to wait to obtain a file lock.
|
||||||
// Only available on Darwin and Linux.
|
// Only available on Darwin and Linux.
|
||||||
//
|
//
|
||||||
// Optional. Default is 0 (no timeout)
|
// Optional. Default is set to 60 * time.Second.
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
|
||||||
// Open database in read-only mode.
|
// Open database in read-only mode.
|
||||||
@@ -35,7 +35,7 @@ type Config struct {
|
|||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Database: "fiber.db",
|
Database: "fiber.db",
|
||||||
Bucket: "fiber_storage",
|
Bucket: "fiber_storage",
|
||||||
Timeout: 0,
|
Timeout: 60 * time.Second,
|
||||||
ReadOnly: false,
|
ReadOnly: false,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
}
|
}
|
||||||
|
@@ -23,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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *awsdynamodb.Client
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -264,3 +264,8 @@ func returnAWSConfig(cfg Config) (aws.Config, error) {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *awsdynamodb.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -105,3 +105,7 @@ func Test_DynamoDB_Reset(t *testing.T) {
|
|||||||
func Test_DynamoDB_Close(t *testing.T) {
|
func Test_DynamoDB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -3,10 +3,10 @@ module github.com/gofiber/storage/dynamodb
|
|||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go-v2 v1.16.4
|
github.com/aws/aws-sdk-go-v2 v1.16.16
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.15.7
|
github.com/aws/aws-sdk-go-v2/config v1.17.8
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.2
|
github.com/aws/aws-sdk-go-v2/credentials v1.12.21
|
||||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.2
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.0
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.5
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.1
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v0.1.2
|
||||||
)
|
)
|
||||||
|
@@ -1,41 +1,43 @@
|
|||||||
github.com/aws/aws-sdk-go-v2 v1.16.4 h1:swQTEQUyJF/UkEA94/Ga55miiKFoXmm/Zd67XHgmjSg=
|
github.com/aws/aws-sdk-go-v2 v1.16.16 h1:M1fj4FE2lB4NzRb9Y0xdWsn2P0+2UHVxwKyOa4YJNjk=
|
||||||
github.com/aws/aws-sdk-go-v2 v1.16.4/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU=
|
github.com/aws/aws-sdk-go-v2 v1.16.16/go.mod h1:SwiyXi/1zTUZ6KIAmLK5V5ll8SiURNUYOqTerZPaF9k=
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.15.7 h1:PrzhYjDpWnGSpjedmEapldQKPW4x8cCNzUI8XOho1CM=
|
github.com/aws/aws-sdk-go-v2/config v1.17.8 h1:b9LGqNnOdg9vR4Q43tBTVWk4J6F+W774MSchvKJsqnE=
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.15.7/go.mod h1:exERlvqx1OoUHrxQpMgrmfSW0H6B1+r3xziZD3bBXRg=
|
github.com/aws/aws-sdk-go-v2/config v1.17.8/go.mod h1:UkCI3kb0sCdvtjiXYiU4Zx5h07BOpgBTtkPu/49r+kA=
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.2 h1:tX4EHQFU4+O9at5QjnwIKb/Qgv7MbgbUNtqTRF0Vu2M=
|
github.com/aws/aws-sdk-go-v2/credentials v1.12.21 h1:4tjlyCD0hRGNQivh5dN8hbP30qQhMLBE/FgQR1vHHWM=
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.2/go.mod h1:/XWqDVuzclEKvzileqtD7/t+wIhOogv//6JFlKEe0Wc=
|
github.com/aws/aws-sdk-go-v2/credentials v1.12.21/go.mod h1:O+4XyAt4e+oBAoIwNUYkRg3CVMscaIJdmZBOcPgJ8D8=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.2 h1:DvvtcTzxaQ2Pj0KHKRzsPV4oI8HG4MquzOYhPlQX5Ak=
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.0 h1:bKbdstt7+PzIRSIXZ11Yo8Qh8t0AHn6jEYUfsbVcLjE=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.2/go.mod h1:vS7AGBSFmHpshyfIf67o62U7Hx2pwqghK7VFKWQwVuI=
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.0/go.mod h1:+CBJZMhsb1pTUcB/NTdS505bDX10xS4xnPMqDZj2Ptw=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.5 h1:YPxclBeE07HsLQE8vtjC8T2emcTjM9nzqsnDi2fv5UM=
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17 h1:r08j4sbZu/RVi+BNxkBJwPMUYY3P8mgSDuKkZ/ZN1lE=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.5/go.mod h1:WAPnuhG5IQ/i6DETFl5NmX3kKqCzw7aau9NHAGcm4QE=
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17/go.mod h1:yIkQcCDYNsZfXpd5UX2Cy+sWA1jPgIhGTw9cOBzfVnQ=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.11 h1:gsqHplNh1DaQunEKZISK56wlpbCg0yKxNVvGWCFuF1k=
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23 h1:s4g/wnzMf+qepSNgTvaQQHNxyMLKSawNhKCPNy++2xY=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.11/go.mod h1:tmUB6jakq5DFNcXsXOA/ZQ7/C8VnSKYkx58OI7Fh79g=
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23/go.mod h1:2DFxAQ9pfIRy0imBCJv+vZ2X6RKxves6fbnEuSry6b4=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.5 h1:PLFj+M2PgIDHG//hw3T0O0KLI4itVtAjtxrZx4AHPLg=
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17 h1:/K482T5A3623WJgWT8w1yRAFK4RzGzEl7y39yhtn9eA=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.5/go.mod h1:fV1AaS2gFc1tM0RCb015FJ0pvWVUfJZANzjwoO4YakM=
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17/go.mod h1:pRwaTYCJemADaqCbUAxltMoHKata7hmB5PjEXeu0kfg=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.12 h1:j0VqrjtgsY1Bx27tD0ysay36/K4kFMWRp9K3ieO9nLU=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.24 h1:wj5Rwc05hvUSvKuOF29IYb9QrCLjU+rHAy/x/o0DK2c=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.12/go.mod h1:00c7+ALdPh4YeEUPXJzyU0Yy01nPGOq2+9rUaz05z9g=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.24/go.mod h1:jULHjqqjDlbyTa7pfM7WICATnOv+iOhjletM3N0Xbu8=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.5 h1:tXJao3ARBuz1eBvBxbycMbLudRoCyBi/K3SoWYtraYw=
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.1 h1:1QpTkQIAaZpR387it1L+erjB5bStGFCJRvmXsodpPEU=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.5/go.mod h1:cgX8pdAf5SIWPyACqtk9XIRFcCfpp+YdSFRyg0EcB0M=
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.1/go.mod h1:BZhn/C3z13ULTSstVi2Kymc62bgjFh/JwLO9Tm2OFYI=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.5 h1:8iA9hJOA1x5Y+71JFfTnN7qGe2IZpnToRWdS85Q3sVc=
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.20 h1:V9q4A0qnUfDsfivspY1LQRQTOG3Y9FLHvXIaTbcU7XM=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.5/go.mod h1:HqsSXgiAga9ASwy5BFJikIZ0jiyOd9+Wo/gtahNjZWI=
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.20/go.mod h1:7qWU48SMzlrfOlNhHpazW3psFWlOIWrq4SmOr2/ESmk=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 h1:T4pFel53bkHjL2mMo+4DKE6r6AuoZnM0fg7k1/ratr4=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.9 h1:Lh1AShsuIJTwMkoxVCAYPJgNG5H+eN6SmoUn8nOZ5wE=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1/go.mod h1:GeUru+8VzrTXV/83XyMJ80KpH8xO89VPoUileyNQ+tc=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.9/go.mod h1:a9j48l6yL5XINLHLcOKInjdvknN+vWqPBxqeIDw7ktw=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.5 h1:5luSEBzszJUfcjtGExZ6+T8h/fc0Vq7foE3D2b4LrP8=
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.17 h1:o0Ia3nb56m8+8NvhbCDiSBiZRNUwIknVWobx5vks0Vk=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.5/go.mod h1:yu4bJTJjxrsTWxt/Hn90WT5lhGV6auJNyey1+dVW2yA=
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.17/go.mod h1:WJD9FbkwzM2a1bZ36ntH6+5Jc+x41Q4K2AcLeHDLAS8=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.5 h1:gRW1ZisKc93EWEORNJRvy/ZydF3o6xLSveJHdi1Oa0U=
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.17 h1:Jrd/oMh0PKQc6+BowB+pLEwLIgaQF29eYbe7E1Av9Ug=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.5/go.mod h1:ZbkttHXaVn3bBo/wpJbQGiiIWR90eTBUVBrEHUEQlho=
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.17/go.mod h1:4nYOrY41Lrbk2170/BGkcJKBhws9Pfn8MG3aGqjjeFI=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.5 h1:TfJ/zuOYvHnxkvohSwAF3Ppn9KT/SrGZuOZHTPy8Guw=
|
github.com/aws/aws-sdk-go-v2/service/sso v1.11.23 h1:pwvCchFUEnlceKIgPUouBJwK81aCkQ8UDMORfeFtW10=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.5/go.mod h1:TFVe6Rr2joVLsYQ1ABACXgOC6lXip/qpX2x5jWg/A9w=
|
github.com/aws/aws-sdk-go-v2/service/sso v1.11.23/go.mod h1:/w0eg9IhFGjGyyncHIQrXtU8wvNsTJOP0R6PPj0wf80=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.6 h1:aYToU0/iazkMY67/BYLt3r6/LT/mUtarLAF5mGof1Kg=
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.6 h1:OwhhKc1P9ElfWbMKPIbMMZBV6hzJlL2JKD76wNNVzgQ=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.6/go.mod h1:rP1rEOKAGZoXp4iGDxSXFvODAtXpm34Egf0lL0eshaQ=
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.6/go.mod h1:csZuQY65DAdFBt1oIjO5hhBR49kQqop4+lcuCjf2arA=
|
||||||
github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE=
|
github.com/aws/aws-sdk-go-v2/service/sts v1.16.19 h1:9pPi0PsFNAGILFfPCk8Y0iyEBGc6lu6OQ97U7hmdesg=
|
||||||
github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM=
|
github.com/aws/aws-sdk-go-v2/service/sts v1.16.19/go.mod h1:h4J3oPZQbxLhzGnk+j9dfYHi5qIOVJ5kczZd658/ydM=
|
||||||
|
github.com/aws/smithy-go v1.13.3 h1:l7LYxGuzK6/K+NzJ2mC+VvLUbae0sL3bXU//04MkmnA=
|
||||||
|
github.com/aws/smithy-go v1.13.3/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 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
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 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
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 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||||
@@ -43,8 +45,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
|
|||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
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 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
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/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 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
|
2
go.mod
2
go.mod
@@ -1,3 +1,3 @@
|
|||||||
module github.com/gofiber/storage
|
module github.com/gofiber/storage
|
||||||
|
|
||||||
go 1.14
|
go 1.14
|
||||||
|
@@ -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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *mc.Client
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -122,3 +122,8 @@ func (s *Storage) releaseItem(item *mc.Item) {
|
|||||||
s.items.Put(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) {
|
func Test_Memcache_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() map[string]entry
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
32
memory/internal/time.go
Normal file
32
memory/internal/time.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
timestampTimer sync.Once
|
||||||
|
// Timestamp please start the timer function before you use this value
|
||||||
|
// please load the value with atomic `atomic.LoadUint32(&utils.Timestamp)`
|
||||||
|
Timestamp uint32
|
||||||
|
)
|
||||||
|
|
||||||
|
// StartTimeStampUpdater starts a concurrent function which stores the timestamp to an atomic value per second,
|
||||||
|
// which is much better for performance than determining it at runtime each time
|
||||||
|
func StartTimeStampUpdater() {
|
||||||
|
timestampTimer.Do(func() {
|
||||||
|
// set initial value
|
||||||
|
atomic.StoreUint32(&Timestamp, uint32(time.Now().Unix()))
|
||||||
|
go func(sleep time.Duration) {
|
||||||
|
ticker := time.NewTicker(sleep)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for t := range ticker.C {
|
||||||
|
// update timestamp
|
||||||
|
atomic.StoreUint32(&Timestamp, uint32(t.Unix()))
|
||||||
|
}
|
||||||
|
}(1 * time.Second) // duration
|
||||||
|
})
|
||||||
|
}
|
47
memory/internal/time_test.go
Normal file
47
memory/internal/time_test.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync/atomic"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func checkTimeStamp(t testing.TB, expectedCurrent, actualCurrent uint32) {
|
||||||
|
// test with some buffer in front and back of the expectedCurrent time -> because of the timing on the work machine
|
||||||
|
utils.AssertEqual(t, true, actualCurrent >= expectedCurrent-1 || actualCurrent <= expectedCurrent+1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_TimeStampUpdater(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
StartTimeStampUpdater()
|
||||||
|
|
||||||
|
now := uint32(time.Now().Unix())
|
||||||
|
checkTimeStamp(t, now, atomic.LoadUint32(&Timestamp))
|
||||||
|
// one second later
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
checkTimeStamp(t, now+1, atomic.LoadUint32(&Timestamp))
|
||||||
|
// two seconds later
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
checkTimeStamp(t, now+2, atomic.LoadUint32(&Timestamp))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_CalculateTimestamp(b *testing.B) {
|
||||||
|
StartTimeStampUpdater()
|
||||||
|
|
||||||
|
var res uint32
|
||||||
|
b.Run("fiber", func(b *testing.B) {
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
res = atomic.LoadUint32(&Timestamp)
|
||||||
|
}
|
||||||
|
checkTimeStamp(b, uint32(time.Now().Unix()), res)
|
||||||
|
})
|
||||||
|
b.Run("default", func(b *testing.B) {
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
res = uint32(time.Now().Unix())
|
||||||
|
}
|
||||||
|
checkTimeStamp(b, uint32(time.Now().Unix()), res)
|
||||||
|
})
|
||||||
|
}
|
@@ -2,7 +2,10 @@ package memory
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/storage/memory/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage interface that is implemented by storage providers
|
// Storage interface that is implemented by storage providers
|
||||||
@@ -14,8 +17,9 @@ type Storage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type entry struct {
|
type entry struct {
|
||||||
data []byte
|
data []byte
|
||||||
expiry int64
|
// max value is 4294967295 -> Sun Feb 07 2106 06:28:15 GMT+0000
|
||||||
|
expiry uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new memory storage
|
// New creates a new memory storage
|
||||||
@@ -31,6 +35,7 @@ func New(config ...Config) *Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start garbage collector
|
// Start garbage collector
|
||||||
|
internal.StartTimeStampUpdater()
|
||||||
go store.gc()
|
go store.gc()
|
||||||
|
|
||||||
return store
|
return store
|
||||||
@@ -44,14 +49,13 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
|||||||
s.mux.RLock()
|
s.mux.RLock()
|
||||||
v, ok := s.db[key]
|
v, ok := s.db[key]
|
||||||
s.mux.RUnlock()
|
s.mux.RUnlock()
|
||||||
if !ok || v.expiry != 0 && v.expiry <= time.Now().Unix() {
|
if !ok || v.expiry != 0 && v.expiry <= atomic.LoadUint32(&internal.Timestamp) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.data, nil
|
return v.data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set key with value
|
|
||||||
// Set key with value
|
// Set key with value
|
||||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
// Ain't Nobody Got Time For That
|
// Ain't Nobody Got Time For That
|
||||||
@@ -59,9 +63,9 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var expire int64
|
var expire uint32
|
||||||
if exp != 0 {
|
if exp != 0 {
|
||||||
expire = time.Now().Add(exp).Unix()
|
expire = uint32(exp.Seconds()) + atomic.LoadUint32(&internal.Timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mux.Lock()
|
s.mux.Lock()
|
||||||
@@ -99,20 +103,31 @@ func (s *Storage) Close() error {
|
|||||||
func (s *Storage) gc() {
|
func (s *Storage) gc() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
var expired []string
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.done:
|
case <-s.done:
|
||||||
return
|
return
|
||||||
case t := <-ticker.C:
|
case <-ticker.C:
|
||||||
now := t.Unix()
|
expired = expired[:0]
|
||||||
s.mux.Lock()
|
s.mux.RLock()
|
||||||
for id, v := range s.db {
|
for id, v := range s.db {
|
||||||
if v.expiry != 0 && v.expiry < now {
|
if v.expiry != 0 && v.expiry < atomic.LoadUint32(&internal.Timestamp) {
|
||||||
delete(s.db, id)
|
expired = append(expired, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
s.mux.RUnlock()
|
||||||
|
s.mux.Lock()
|
||||||
|
for i := range expired {
|
||||||
|
delete(s.db, expired[i])
|
||||||
|
}
|
||||||
s.mux.Unlock()
|
s.mux.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() map[string]entry {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -119,3 +119,35 @@ func Test_Memory_Reset(t *testing.T) {
|
|||||||
func Test_Memory_Close(t *testing.T) {
|
func Test_Memory_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Memory_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// go test -v -run=^$ -bench=Benchmark_Memory -benchmem -count=4
|
||||||
|
func Benchmark_Memory(b *testing.B) {
|
||||||
|
keyLength := 1000
|
||||||
|
keys := make([]string, keyLength)
|
||||||
|
for i := 0; i < keyLength; i++ {
|
||||||
|
keys[i] = utils.UUID()
|
||||||
|
}
|
||||||
|
value := []byte("joe")
|
||||||
|
|
||||||
|
ttl := 2 * time.Second
|
||||||
|
b.Run("fiber_memory", func(b *testing.B) {
|
||||||
|
d := New()
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
for _, key := range keys {
|
||||||
|
d.Set(key, value, ttl)
|
||||||
|
}
|
||||||
|
for _, key := range keys {
|
||||||
|
_, _ = d.Get(key)
|
||||||
|
}
|
||||||
|
for _, key := range keys {
|
||||||
|
d.Delete(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *mongo.Database
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-stack/stack v1.8.1 // indirect
|
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v0.1.2
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||||
go.mongodb.org/mongo-driver v1.9.1
|
go.mongodb.org/mongo-driver v1.10.3
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
|
||||||
golang.org/x/text v0.3.7 // indirect
|
|
||||||
)
|
)
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
|
||||||
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
|
|
||||||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
|
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
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.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
@@ -18,6 +15,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
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 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
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/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
@@ -30,46 +28,39 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
|||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
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/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||||
github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w=
|
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
|
||||||
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
|
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||||
github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc=
|
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
|
||||||
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
|
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=
|
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
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=
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
||||||
go.mongodb.org/mongo-driver v1.9.1 h1:m078y9v7sBItkt1aaoe2YlvWEXcD263e1a4E1fBrJ1c=
|
go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA=
|
||||||
go.mongodb.org/mongo-driver v1.9.1/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
go.mongodb.org/mongo-driver v1.10.3/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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
||||||
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-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
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-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
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/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-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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
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-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
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.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.6/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 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
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-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
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 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
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 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
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.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)
|
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) {
|
func Test_MongoDB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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,36 @@ store := mysql.New(mysql.Config{
|
|||||||
Reset: false,
|
Reset: false,
|
||||||
GCInterval: 10 * time.Second,
|
GCInterval: 10 * time.Second,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Initialize custom config using connection string
|
||||||
|
store := mysql.New(mysql.Config{
|
||||||
|
ConnectionURI: "<username>:<pw>@tcp(<HOST>:<port>)/<dbname>"
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Initialize custom config using sql db connection
|
||||||
|
db, _ := sql.Open("mysql", "<username>:<pw>@tcp(<HOST>:<port>)/<dbname>")
|
||||||
|
store := mysql.New(mysql.Config{
|
||||||
|
Db: db,
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// DB Will override ConnectionURI and all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is nil
|
||||||
|
Db *sql.DB
|
||||||
|
|
||||||
|
// 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
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -98,6 +124,7 @@ type Config struct {
|
|||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 3306,
|
Port: 3306,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
|
@@ -1,12 +1,23 @@
|
|||||||
package mysql
|
package mysql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// DB Will override ConnectionURI and all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is nil
|
||||||
|
Db *sql.DB
|
||||||
|
|
||||||
|
// 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
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -58,6 +69,8 @@ type Config struct {
|
|||||||
|
|
||||||
// ConfigDefault is the default config
|
// ConfigDefault is the default config
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
Db: nil,
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 3306,
|
Port: 3306,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
@@ -70,6 +83,9 @@ var ConfigDefault = Config{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) dsn() string {
|
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)
|
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", c.Username, c.Password, c.Host, c.Port, c.Database)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,19 +40,27 @@ var (
|
|||||||
|
|
||||||
// New creates a new storage
|
// New creates a new storage
|
||||||
func New(config ...Config) *Storage {
|
func New(config ...Config) *Storage {
|
||||||
|
var err error
|
||||||
|
var db *sql.DB
|
||||||
|
|
||||||
// Set default config
|
// Set default config
|
||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
// Create db
|
if cfg.Db != nil {
|
||||||
db, err := sql.Open("mysql", cfg.dsn())
|
// Use passed db
|
||||||
if err != nil {
|
db = cfg.Db
|
||||||
panic(err)
|
} else {
|
||||||
}
|
// Create db
|
||||||
|
db, err = sql.Open("mysql", cfg.dsn())
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Set options
|
// Set options
|
||||||
db.SetMaxOpenConns(cfg.maxOpenConns)
|
db.SetMaxOpenConns(cfg.maxOpenConns)
|
||||||
db.SetMaxIdleConns(cfg.maxIdleConns)
|
db.SetMaxIdleConns(cfg.maxIdleConns)
|
||||||
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
||||||
|
}
|
||||||
|
|
||||||
// Ping database to ensure a connection has been made
|
// Ping database to ensure a connection has been made
|
||||||
if err := db.Ping(); err != nil {
|
if err := db.Ping(); err != nil {
|
||||||
@@ -165,6 +173,11 @@ func (s *Storage) Close() error {
|
|||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
// gcTicker starts the gc ticker
|
// gcTicker starts the gc ticker
|
||||||
func (s *Storage) gcTicker() {
|
func (s *Storage) gcTicker() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
@@ -2,11 +2,12 @@ package mysql
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gofiber/utils"
|
"github.com/gofiber/utils"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New(Config{
|
var testStore = New(Config{
|
||||||
@@ -16,6 +17,36 @@ var testStore = New(Config{
|
|||||||
Reset: true,
|
Reset: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
func Test_MYSQL_New(t *testing.T) {
|
||||||
|
newConfigStore := New(Config{
|
||||||
|
Database: os.Getenv("MYSQL_DATABASE"),
|
||||||
|
Username: os.Getenv("MYSQL_USERNAME"),
|
||||||
|
Password: os.Getenv("MYSQL_PASSWORD"),
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
utils.AssertEqual(t, true, newConfigStore.db != nil)
|
||||||
|
newConfigStore.Close()
|
||||||
|
|
||||||
|
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", os.Getenv("MYSQL_USERNAME"), os.Getenv("MYSQL_PASSWORD"), "127.0.0.1", 3306, os.Getenv("MYSQL_DATABASE"))
|
||||||
|
newConfigStore = New(Config{
|
||||||
|
ConnectionURI: dsn,
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
utils.AssertEqual(t, true, newConfigStore.db != nil)
|
||||||
|
newConfigStore.Close()
|
||||||
|
|
||||||
|
db, _ := sql.Open("mysql", dsn)
|
||||||
|
newConfigStore = New(Config{
|
||||||
|
Db: db,
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
utils.AssertEqual(t, true, newConfigStore.db != nil)
|
||||||
|
newConfigStore.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func Test_MYSQL_Set(t *testing.T) {
|
func Test_MYSQL_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
@@ -162,3 +193,7 @@ func Test_MYSQL_Non_UTF8(t *testing.T) {
|
|||||||
func Test_MYSQL_Close(t *testing.T) {
|
func Test_MYSQL_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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:
|
||||||
@@ -49,12 +50,24 @@ store := postgres.New(postgres.Config{
|
|||||||
GCInterval: 10 * time.Second,
|
GCInterval: 10 * time.Second,
|
||||||
SslMode: "disable",
|
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,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
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
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -105,6 +118,7 @@ type Config struct {
|
|||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
|
@@ -6,6 +6,11 @@ import (
|
|||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
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
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -90,6 +95,7 @@ type Config struct {
|
|||||||
|
|
||||||
// ConfigDefault is the default config
|
// ConfigDefault is the default config
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
|
@@ -4,5 +4,5 @@ go 1.14
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v0.1.2
|
||||||
github.com/lib/pq v1.10.6
|
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 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
|
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||||
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
@@ -46,26 +46,31 @@ func New(config ...Config) *Storage {
|
|||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
// Create data source name
|
// Create data source name
|
||||||
var dsn string = "postgresql://"
|
var dsn string
|
||||||
if cfg.Username != "" {
|
if cfg.ConnectionURI != "" {
|
||||||
dsn += url.QueryEscape(cfg.Username)
|
dsn = cfg.ConnectionURI
|
||||||
}
|
|
||||||
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 {
|
} else {
|
||||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
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)
|
||||||
}
|
}
|
||||||
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=%s",
|
|
||||||
url.QueryEscape(cfg.Database),
|
|
||||||
int64(cfg.timeout.Seconds()),
|
|
||||||
cfg.SslMode)
|
|
||||||
|
|
||||||
// Create db
|
// Create db
|
||||||
db, err := sql.Open("postgres", dsn)
|
db, err := sql.Open("postgres", dsn)
|
||||||
@@ -184,6 +189,11 @@ func (s *Storage) Close() error {
|
|||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
// gcTicker starts the gc ticker
|
// gcTicker starts the gc ticker
|
||||||
func (s *Storage) gcTicker() {
|
func (s *Storage) gcTicker() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
@@ -177,3 +177,7 @@ func Test_SslRequiredMode(t *testing.T) {
|
|||||||
func Test_Postgres_Close(t *testing.T) {
|
func Test_Postgres_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Postgres_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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *redis.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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:
|
||||||
@@ -49,7 +50,8 @@ store := redis.New(redis.Config{
|
|||||||
Database: 0,
|
Database: 0,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
TLSConfig: nil,
|
TLSConfig: nil,
|
||||||
}
|
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||||
|
})
|
||||||
|
|
||||||
// or just the url with all information
|
// or just the url with all information
|
||||||
store = redis.New(redis.Config{
|
store = redis.New(redis.Config{
|
||||||
@@ -86,11 +88,11 @@ type Config struct {
|
|||||||
// Optional. Default is 0
|
// Optional. Default is 0
|
||||||
Database int
|
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.
|
// 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>
|
// Example: redis://<user>:<pass>@localhost:6379/<db>
|
||||||
// Optional. Default is ""
|
// Optional. Default is ""
|
||||||
URL string
|
URL string
|
||||||
|
|
||||||
// Reset clears any existing keys in existing Collection
|
// Reset clears any existing keys in existing Collection
|
||||||
//
|
//
|
||||||
@@ -101,6 +103,11 @@ type Config struct {
|
|||||||
//
|
//
|
||||||
// Optional. Default is nil
|
// Optional. Default is nil
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
|
||||||
|
// Maximum number of socket connections.
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||||
|
PoolSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -116,5 +123,6 @@ var ConfigDefault = Config{
|
|||||||
Database: 0,
|
Database: 0,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
TLSConfig: nil,
|
TLSConfig: nil,
|
||||||
|
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
package redis
|
package redis
|
||||||
|
|
||||||
import "crypto/tls"
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -43,6 +46,11 @@ type Config struct {
|
|||||||
// TLS Config to use. When set TLS will be negotiated.
|
// TLS Config to use. When set TLS will be negotiated.
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
|
||||||
|
// Maximum number of socket connections.
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||||
|
PoolSize int
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// Adaptor related config options //
|
// Adaptor related config options //
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
@@ -60,6 +68,7 @@ var ConfigDefault = Config{
|
|||||||
Database: 0,
|
Database: 0,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
TLSConfig: nil,
|
TLSConfig: nil,
|
||||||
|
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to set default values
|
// Helper function to set default values
|
||||||
|
@@ -19,16 +19,18 @@ func New(config ...Config) *Storage {
|
|||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
// Create new redis client
|
// Create new redis client
|
||||||
|
|
||||||
var options *redis.Options
|
var options *redis.Options
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if cfg.URL != "" {
|
if cfg.URL != "" {
|
||||||
options, err = redis.ParseURL(cfg.URL)
|
options, err = redis.ParseURL(cfg.URL)
|
||||||
options.TLSConfig = cfg.TLSConfig
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.TLSConfig = cfg.TLSConfig
|
||||||
|
options.PoolSize = cfg.PoolSize
|
||||||
} else {
|
} else {
|
||||||
options = &redis.Options{
|
options = &redis.Options{
|
||||||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
||||||
@@ -36,6 +38,7 @@ func New(config ...Config) *Storage {
|
|||||||
Username: cfg.Username,
|
Username: cfg.Username,
|
||||||
Password: cfg.Password,
|
Password: cfg.Password,
|
||||||
TLSConfig: cfg.TLSConfig,
|
TLSConfig: cfg.TLSConfig,
|
||||||
|
PoolSize: cfg.PoolSize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +74,6 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
|||||||
return val, err
|
return val, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set key with value
|
|
||||||
// Set key with value
|
// Set key with value
|
||||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
// Ain't Nobody Got Time For That
|
// Ain't Nobody Got Time For That
|
||||||
@@ -99,3 +101,8 @@ func (s *Storage) Reset() error {
|
|||||||
func (s *Storage) Close() error {
|
func (s *Storage) Close() error {
|
||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *redis.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -123,6 +123,10 @@ func Test_Redis_Close(t *testing.T) {
|
|||||||
utils.AssertEqual(t, nil, testStore.Close())
|
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) {
|
func Test_Redis_Initalize_WithURL(t *testing.T) {
|
||||||
testStoreUrl := New(Config{
|
testStoreUrl := New(Config{
|
||||||
URL: "redis://localhost:6379",
|
URL: "redis://localhost:6379",
|
||||||
|
@@ -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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *ristretto.Cache
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -89,3 +89,8 @@ func (s *Storage) Close() error {
|
|||||||
s.cache.Close()
|
s.cache.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *ristretto.Cache {
|
||||||
|
return s.cache
|
||||||
|
}
|
||||||
|
@@ -126,3 +126,7 @@ func Test_Ristretto_Reset(t *testing.T) {
|
|||||||
func Test_Ristretto_Close(t *testing.T) {
|
func Test_Ristretto_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Ristretto_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -20,6 +20,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *s3.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### 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:
|
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:
|
||||||
|
10
s3/go.mod
10
s3/go.mod
@@ -3,10 +3,10 @@ module github.com/gofiber/storage/s3
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go-v2 v1.13.0
|
github.com/aws/aws-sdk-go-v2 v1.16.16
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.13.1
|
github.com/aws/aws-sdk-go-v2/config v1.17.8
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.8.0
|
github.com/aws/aws-sdk-go-v2/credentials v1.12.21
|
||||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.9.1
|
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.34
|
||||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.24.1
|
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.11
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v0.1.2
|
||||||
)
|
)
|
||||||
|
77
s3/go.sum
77
s3/go.sum
@@ -1,42 +1,47 @@
|
|||||||
github.com/aws/aws-sdk-go-v2 v1.13.0 h1:1XIXAfxsEmbhbj5ry3D3vX+6ZcUYvIqSm4CWWEuGZCA=
|
github.com/aws/aws-sdk-go-v2 v1.16.16 h1:M1fj4FE2lB4NzRb9Y0xdWsn2P0+2UHVxwKyOa4YJNjk=
|
||||||
github.com/aws/aws-sdk-go-v2 v1.13.0/go.mod h1:L6+ZpqHaLbAaxsqV0L4cvxZY7QupWJB4fhkf8LXvC7w=
|
github.com/aws/aws-sdk-go-v2 v1.16.16/go.mod h1:SwiyXi/1zTUZ6KIAmLK5V5ll8SiURNUYOqTerZPaF9k=
|
||||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.2.0 h1:scBthy70MB3m4LCMFaBcmYCyR2XWOz6MxSfdSu/+fQo=
|
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.8 h1:tcFliCWne+zOuUfKNRn8JdFBuWPDuISDH08wD2ULkhk=
|
||||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.2.0/go.mod h1:oZHzg1OVbuCiRTY0oRPM+c2HQvwnFCGJwKeSqqAJ/yM=
|
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.8/go.mod h1:JTnlBSot91steJeti4ryyu/tLd4Sk84O5W22L7O2EQU=
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.13.1 h1:yLv8bfNoT4r+UvUKQKqRtdnvuWGMK5a82l4ru9Jvnuo=
|
github.com/aws/aws-sdk-go-v2/config v1.17.8 h1:b9LGqNnOdg9vR4Q43tBTVWk4J6F+W774MSchvKJsqnE=
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.13.1/go.mod h1:Ba5Z4yL/UGbjQUzsiaN378YobhFo0MLfueXGiOsYtEs=
|
github.com/aws/aws-sdk-go-v2/config v1.17.8/go.mod h1:UkCI3kb0sCdvtjiXYiU4Zx5h07BOpgBTtkPu/49r+kA=
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.8.0 h1:8Ow0WcyDesGNL0No11jcgb1JAtE+WtubqXjgxau+S0o=
|
github.com/aws/aws-sdk-go-v2/credentials v1.12.21 h1:4tjlyCD0hRGNQivh5dN8hbP30qQhMLBE/FgQR1vHHWM=
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.8.0/go.mod h1:gnMo58Vwx3Mu7hj1wpcG8DI0s57c9o42UQ6wgTQT5to=
|
github.com/aws/aws-sdk-go-v2/credentials v1.12.21/go.mod h1:O+4XyAt4e+oBAoIwNUYkRg3CVMscaIJdmZBOcPgJ8D8=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.10.0 h1:NITDuUZO34mqtOwFWZiXo7yAHj7kf+XPE+EiKuCBNUI=
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17 h1:r08j4sbZu/RVi+BNxkBJwPMUYY3P8mgSDuKkZ/ZN1lE=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.10.0/go.mod h1:I6/fHT/fH460v09eg2gVrd8B/IqskhNdpcLH0WNO3QI=
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17/go.mod h1:yIkQcCDYNsZfXpd5UX2Cy+sWA1jPgIhGTw9cOBzfVnQ=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.9.1 h1:oUCLhAKNaXyTqdJyw+KEjDVVBs1V5mCy8YDLMi08LL8=
|
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.34 h1:1PNtaCM+2ruo1dfYL2RweUdtbuPvinjAejjNcPa/RQY=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.9.1/go.mod h1:pB38jI+AdaPoLAgaL9bwxDdy6rjwO6LIArBZDLjq6zs=
|
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.34/go.mod h1:+Six+CXNHYllXam32j+YW8ixk82+am345ei89kEz8p4=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.4 h1:CRiQJ4E2RhfDdqbie1ZYDo8QtIo75Mk7oTdJSfwJTMQ=
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23 h1:s4g/wnzMf+qepSNgTvaQQHNxyMLKSawNhKCPNy++2xY=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.4/go.mod h1:XHgQ7Hz2WY2GAn//UXHofLfPXWh+s62MbMOijrg12Lw=
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23/go.mod h1:2DFxAQ9pfIRy0imBCJv+vZ2X6RKxves6fbnEuSry6b4=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.2.0 h1:3ADoioDMOtF4uiK59vCpplpCwugEU+v4ZFD29jDL3RQ=
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17 h1:/K482T5A3623WJgWT8w1yRAFK4RzGzEl7y39yhtn9eA=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.2.0/go.mod h1:BsCSJHx5DnDXIrOcqB8KN1/B+hXLG/bi4Y6Vjcx/x9E=
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17/go.mod h1:pRwaTYCJemADaqCbUAxltMoHKata7hmB5PjEXeu0kfg=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.5 h1:ixotxbfTCFpqbuwFv/RcZwyzhkxPSYDYEMcj4niB5Uk=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.24 h1:wj5Rwc05hvUSvKuOF29IYb9QrCLjU+rHAy/x/o0DK2c=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.5/go.mod h1:R3sWUqPcfXSiF/LSFJhjyJmpg9uV6yP2yv3YZZjldVI=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.24/go.mod h1:jULHjqqjDlbyTa7pfM7WICATnOv+iOhjletM3N0Xbu8=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.7.0 h1:F1diQIOkNn8jcez4173r+PLPdkWK7chy74r3fKpDrLI=
|
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.14 h1:ZSIPAkAsCCjYrhqfw2+lNzWDzxzHXEckFkTePL5RSWQ=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.7.0/go.mod h1:8ctElVINyp+SjhoZZceUAZw78glZH6R8ox5MVNu5j2s=
|
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.14/go.mod h1:AyGgqiKv9ECM6IZeNQtdT8NnMvUb3/2wokeq2Fgryto=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.7.0 h1:4QAOB3KrvI1ApJK14sliGr3Ie2pjyvNypn/lfzDHfUw=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.9 h1:Lh1AShsuIJTwMkoxVCAYPJgNG5H+eN6SmoUn8nOZ5wE=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.7.0/go.mod h1:K/qPe6AP2TGYv4l6n7c88zh9jWBDf6nHhvg1fx/EWfU=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.9/go.mod h1:a9j48l6yL5XINLHLcOKInjdvknN+vWqPBxqeIDw7ktw=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.11.0 h1:XAe+PDnaBELHr25qaJKfB415V4CKFWE8H+prUreql8k=
|
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.18 h1:BBYoNQt2kUZUUK4bIPsKrCcjVPUMNsgQpNAwhznK/zo=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.11.0/go.mod h1:RMlgnt1LbOT2BxJ3cdw+qVz7KL84714LFkWtF6sLI7A=
|
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.18/go.mod h1:NS55eQ4YixUJPTC+INxi2/jCqe1y2Uw3rnh9wEOVJxY=
|
||||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.24.1 h1:zAU2P99CLTz8kUGl+IptU2ycAXuMaLAvgIv+UH4U8pY=
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.17 h1:Jrd/oMh0PKQc6+BowB+pLEwLIgaQF29eYbe7E1Av9Ug=
|
||||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.24.1/go.mod h1:oIUXg/5F0x0gy6nkwEnlxZboueddwPEKO6Xl+U6/3a0=
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.17/go.mod h1:4nYOrY41Lrbk2170/BGkcJKBhws9Pfn8MG3aGqjjeFI=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.9.0 h1:1qLJeQGBmNQW3mBNzK2CFmrQNmoXWrscPqsrAaU1aTA=
|
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.17 h1:HfVVR1vItaG6le+Bpw6P4midjBDMKnjMyZnw9MXYUcE=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.9.0/go.mod h1:vCV4glupK3tR7pw7ks7Y4jYRL86VvxS+g5qk04YeWrU=
|
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.17/go.mod h1:YqMdV+gEKCQ59NrB7rzrJdALeBIsYiVi8Inj3+KcqHI=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.14.0 h1:ksiDXhvNYg0D2/UFkLejsaz3LqpW5yjNQ8Nx9Sn2c0E=
|
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.11 h1:3/gm/JTX9bX8CpzTgIlrtYpB3EVBDxyg/GY/QdcIEZw=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.14.0/go.mod h1:u0xMJKDvvfocRjiozsoZglVNXRG19043xzp3r2ivLIk=
|
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.11/go.mod h1:fmgDANqTUCxciViKl9hb/zD5LFbvPINFRgWhDbR+vZo=
|
||||||
github.com/aws/smithy-go v1.10.0 h1:gsoZQMNHnX+PaghNw4ynPsyGP7aUCqx5sY2dlPQsZ0w=
|
github.com/aws/aws-sdk-go-v2/service/sso v1.11.23 h1:pwvCchFUEnlceKIgPUouBJwK81aCkQ8UDMORfeFtW10=
|
||||||
github.com/aws/smithy-go v1.10.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
|
github.com/aws/aws-sdk-go-v2/service/sso v1.11.23/go.mod h1:/w0eg9IhFGjGyyncHIQrXtU8wvNsTJOP0R6PPj0wf80=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.6 h1:OwhhKc1P9ElfWbMKPIbMMZBV6hzJlL2JKD76wNNVzgQ=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.6/go.mod h1:csZuQY65DAdFBt1oIjO5hhBR49kQqop4+lcuCjf2arA=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/sts v1.16.19 h1:9pPi0PsFNAGILFfPCk8Y0iyEBGc6lu6OQ97U7hmdesg=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/sts v1.16.19/go.mod h1:h4J3oPZQbxLhzGnk+j9dfYHi5qIOVJ5kczZd658/ydM=
|
||||||
|
github.com/aws/smithy-go v1.13.3 h1:l7LYxGuzK6/K+NzJ2mC+VvLUbae0sL3bXU//04MkmnA=
|
||||||
|
github.com/aws/smithy-go v1.13.3/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 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
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 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 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||||
@@ -44,8 +49,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
|
|||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
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 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 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
5
s3/s3.go
5
s3/s3.go
@@ -159,6 +159,11 @@ func (s *Storage) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *s3.Client {
|
||||||
|
return s.svc
|
||||||
|
}
|
||||||
|
|
||||||
// Context for making requests will timeout if a non-zero timeout is configured
|
// Context for making requests will timeout if a non-zero timeout is configured
|
||||||
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
||||||
if s.requestTimeout > 0 {
|
if s.requestTimeout > 0 {
|
||||||
|
@@ -105,3 +105,7 @@ func Test_S3_Reset(t *testing.T) {
|
|||||||
func Test_S3_Close(t *testing.T) {
|
func Test_S3_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_S3_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) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
SQLite3 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:
|
SQLite3 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:
|
||||||
|
@@ -4,5 +4,5 @@ go 1.14
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v0.1.2
|
||||||
github.com/mattn/go-sqlite3 v1.14.13
|
github.com/mattn/go-sqlite3 v1.14.15
|
||||||
)
|
)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/mattn/go-sqlite3 v1.14.13 h1:1tj15ngiFfcZzii7yd82foL+ks+ouQcj8j/TPq3fk1I=
|
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
|
||||||
github.com/mattn/go-sqlite3 v1.14.13/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
|
@@ -169,3 +169,8 @@ func (s *Storage) gcTicker() {
|
|||||||
func (s *Storage) gc(t time.Time) {
|
func (s *Storage) gc(t time.Time) {
|
||||||
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -159,3 +159,7 @@ func Test_SQLite3_Non_UTF8(t *testing.T) {
|
|||||||
func Test_SQLite3_Close(t *testing.T) {
|
func Test_SQLite3_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_SQLite3_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
Reference in New Issue
Block a user