mirror of
https://github.com/gofiber/storage.git
synced 2025-09-27 04:46:08 +08:00
Compare commits
264 Commits
sqlite3/v2
...
redis/v3.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5b6559e084 | ||
![]() |
32a3153566 | ||
![]() |
b6cf4057d0 | ||
![]() |
d5968313b3 | ||
![]() |
7638e00caa | ||
![]() |
25737614cf | ||
![]() |
ffe12feafa | ||
![]() |
71c101a0fa | ||
![]() |
a00477e510 | ||
![]() |
c3b4b6e96c | ||
![]() |
ae8f210306 | ||
![]() |
139b0f4870 | ||
![]() |
8749583563 | ||
![]() |
54fa28a305 | ||
![]() |
ca5ced95d7 | ||
![]() |
5c018e302d | ||
![]() |
716f5a4878 | ||
![]() |
464c871e79 | ||
![]() |
56a8596fe9 | ||
![]() |
8ba0110b24 | ||
![]() |
75ce232c9c | ||
![]() |
602deafe0a | ||
![]() |
07fab67bb1 | ||
![]() |
6b21d0af38 | ||
![]() |
9c99c74835 | ||
![]() |
05c797f133 | ||
![]() |
894f364785 | ||
![]() |
b607828b9d | ||
![]() |
32c87e29aa | ||
![]() |
ee8aa518e5 | ||
![]() |
aebce6444e | ||
![]() |
3ee7537cc8 | ||
![]() |
7091428842 | ||
![]() |
6d79796597 | ||
![]() |
fbf0bbef5c | ||
![]() |
50bea20332 | ||
![]() |
22f4401661 | ||
![]() |
0e92f332da | ||
![]() |
7921dc7e37 | ||
![]() |
0b9f4aebc8 | ||
![]() |
2143a67c8d | ||
![]() |
3b5d81397c | ||
![]() |
af89d59508 | ||
![]() |
74f7e9b4c9 | ||
![]() |
ddac78a1dd | ||
![]() |
0591ba2589 | ||
![]() |
f602540e53 | ||
![]() |
05194dded6 | ||
![]() |
957cba4743 | ||
![]() |
2a41f5c60f | ||
![]() |
f6eab90d0b | ||
![]() |
f415c93d8b | ||
![]() |
cf8e97a71b | ||
![]() |
ac0c464e5b | ||
![]() |
4457e96f9b | ||
![]() |
ddb765f758 | ||
![]() |
cd80e17ce8 | ||
![]() |
edb77f865f | ||
![]() |
a2e3e4fced | ||
![]() |
c3431ff1af | ||
![]() |
62ebac1d4f | ||
![]() |
3f4bff91cd | ||
![]() |
fc00b7501c | ||
![]() |
2ba3adef60 | ||
![]() |
fba0b33855 | ||
![]() |
f33ba7493c | ||
![]() |
1a9f3e144e | ||
![]() |
0732a00253 | ||
![]() |
2f5ae09380 | ||
![]() |
1d0a80e362 | ||
![]() |
7e70887486 | ||
![]() |
99e619ca77 | ||
![]() |
875a5f3081 | ||
![]() |
23cac43c89 | ||
![]() |
6e44e3c729 | ||
![]() |
8a2be493cb | ||
![]() |
b5a1f8aec4 | ||
![]() |
d7b4cc8c6c | ||
![]() |
318be60fa9 | ||
![]() |
56cbe84675 | ||
![]() |
91db8c2e5d | ||
![]() |
e02ca45688 | ||
![]() |
f864d67dbc | ||
![]() |
863767bc9f | ||
![]() |
dca7968160 | ||
![]() |
2fd96adf12 | ||
![]() |
ec64c27225 | ||
![]() |
0dd355a984 | ||
![]() |
495f9835f2 | ||
![]() |
eb70c9cef1 | ||
![]() |
93c051e1a7 | ||
![]() |
e86e48703c | ||
![]() |
145a7fe255 | ||
![]() |
ba555c5a34 | ||
![]() |
b2f5e6ceb7 | ||
![]() |
5eb19f802b | ||
![]() |
23131b83cc | ||
![]() |
2ec67be1e9 | ||
![]() |
e0807d0fb3 | ||
![]() |
25c0384af3 | ||
![]() |
a10c5eb812 | ||
![]() |
5cb28ee173 | ||
![]() |
b486d160a8 | ||
![]() |
afd4517c53 | ||
![]() |
dc9461d2cc | ||
![]() |
433533050c | ||
![]() |
f9e45829b1 | ||
![]() |
d4e50f8263 | ||
![]() |
6b04025154 | ||
![]() |
17f8641ece | ||
![]() |
3780da9230 | ||
![]() |
5f6130f3d0 | ||
![]() |
a5acb4cc84 | ||
![]() |
27086258a6 | ||
![]() |
83194711c3 | ||
![]() |
d809bc6240 | ||
![]() |
51a3d39536 | ||
![]() |
c2a09a1e85 | ||
![]() |
11ea30d1ed | ||
![]() |
8f916fde3c | ||
![]() |
26aac40a50 | ||
![]() |
9f2fbc07fa | ||
![]() |
502cb1dd74 | ||
![]() |
c92df2a45b | ||
![]() |
f0b304a0c6 | ||
![]() |
9ad80e96c2 | ||
![]() |
3e53b6f96f | ||
![]() |
d18325dea7 | ||
![]() |
46c9ec665a | ||
![]() |
d77dda57c2 | ||
![]() |
133e1b134b | ||
![]() |
bdf3fafbac | ||
![]() |
a8098ce577 | ||
![]() |
807d903176 | ||
![]() |
0c546d9a05 | ||
![]() |
6939eda25d | ||
![]() |
be00cc356c | ||
![]() |
5fd61e7460 | ||
![]() |
a82ac381aa | ||
![]() |
a0500b170a | ||
![]() |
0bc7d51380 | ||
![]() |
eb86e00a79 | ||
![]() |
d33d3cae34 | ||
![]() |
e410768f7f | ||
![]() |
421b7f81fd | ||
![]() |
747f025819 | ||
![]() |
66e0f69437 | ||
![]() |
4b59c5aa07 | ||
![]() |
f7dbcd1fca | ||
![]() |
499d8aa343 | ||
![]() |
aeb7a24789 | ||
![]() |
946562e2a5 | ||
![]() |
558ec79281 | ||
![]() |
f113998db1 | ||
![]() |
f39724354c | ||
![]() |
db1dd2bf6a | ||
![]() |
36dd674d93 | ||
![]() |
55eca1c7b2 | ||
![]() |
d17795a9a9 | ||
![]() |
68d59280d8 | ||
![]() |
f8afad537f | ||
![]() |
468d82d9f7 | ||
![]() |
54245b2520 | ||
![]() |
1af49ff41d | ||
![]() |
a21d4daae0 | ||
![]() |
7825d579b4 | ||
![]() |
2e4b0128fa | ||
![]() |
a19da2b7c9 | ||
![]() |
57e79dffb1 | ||
![]() |
8c18ced1a7 | ||
![]() |
8dd8253afb | ||
![]() |
29370b8740 | ||
![]() |
4501c4f5cd | ||
![]() |
192b1a1bd1 | ||
![]() |
abc64d7e19 | ||
![]() |
6c47c82c78 | ||
![]() |
edb86a96cc | ||
![]() |
0f229274e6 | ||
![]() |
78cfcf3206 | ||
![]() |
e41f3e4131 | ||
![]() |
0170bdc737 | ||
![]() |
d38f0f35f9 | ||
![]() |
c1055478ef | ||
![]() |
88ce7d5d82 | ||
![]() |
7eec5856a3 | ||
![]() |
e357a9c813 | ||
![]() |
967b2258b9 | ||
![]() |
f5c4a78fb1 | ||
![]() |
7e2c6a3e62 | ||
![]() |
89c473aac7 | ||
![]() |
c9efab145d | ||
![]() |
89be8f9d56 | ||
![]() |
a5b0a78828 | ||
![]() |
6be213707b | ||
![]() |
0e55883f05 | ||
![]() |
033c8f432d | ||
![]() |
dc9bb23ade | ||
![]() |
629c25208d | ||
![]() |
bf6aa0132c | ||
![]() |
4dfe51aa01 | ||
![]() |
e735c69371 | ||
![]() |
ae41d2f5c1 | ||
![]() |
dc00bab703 | ||
![]() |
d06fbfc7f3 | ||
![]() |
e09d83368c | ||
![]() |
1ddcc7b3fc | ||
![]() |
db6c457d5c | ||
![]() |
1e3b3f6a5e | ||
![]() |
26c755f312 | ||
![]() |
095dbdbf59 | ||
![]() |
f9a87273bb | ||
![]() |
b6dbad7d88 | ||
![]() |
8400db5161 | ||
![]() |
2e2f6ca4de | ||
![]() |
04d063e759 | ||
![]() |
e50171cdf4 | ||
![]() |
ffd79887c1 | ||
![]() |
994023df1e | ||
![]() |
e8756d084b | ||
![]() |
919f7f5ae7 | ||
![]() |
f98f6ff9e0 | ||
![]() |
b70ea3d72a | ||
![]() |
6eba76bd26 | ||
![]() |
fee5f98406 | ||
![]() |
551552f67f | ||
![]() |
6cff923227 | ||
![]() |
1399f55ed4 | ||
![]() |
79fdc2ef78 | ||
![]() |
f4a12a2a3b | ||
![]() |
edf7bf23e3 | ||
![]() |
1887a32ca2 | ||
![]() |
a1405af086 | ||
![]() |
de487d56be | ||
![]() |
5fd9819f5f | ||
![]() |
b86255479c | ||
![]() |
67218b0d19 | ||
![]() |
cdad22386e | ||
![]() |
cb6a705473 | ||
![]() |
e0523db53d | ||
![]() |
c49bca76d7 | ||
![]() |
3d598445e3 | ||
![]() |
949c597508 | ||
![]() |
ca32702aa0 | ||
![]() |
0ccc5d3faa | ||
![]() |
4c8f4dcdfc | ||
![]() |
d64fa185db | ||
![]() |
cd33dc926f | ||
![]() |
fd63105282 | ||
![]() |
dda7fcf987 | ||
![]() |
b597a36454 | ||
![]() |
b2636aa4c1 | ||
![]() |
b3fe37dd3d | ||
![]() |
d62aeb54b9 | ||
![]() |
dab578a096 | ||
![]() |
68fe393de4 | ||
![]() |
4493457cfa | ||
![]() |
5b49d3629c | ||
![]() |
244330f96e | ||
![]() |
7f002b3158 | ||
![]() |
d3d3a58f6e | ||
![]() |
bec8bb64e1 | ||
![]() |
580a711cb1 | ||
![]() |
23de4dd79e | ||
![]() |
21eb34fec7 |
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@@ -68,6 +68,12 @@ updates:
|
|||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/minio/" # Location of package manifests
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/mongodb/" # Location of package manifests
|
directory: "/mongodb/" # Location of package manifests
|
||||||
labels:
|
labels:
|
||||||
@@ -134,3 +140,9 @@ updates:
|
|||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/scylladb/" # Location of package manifests
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
50
.github/release-drafter-minio.yml
vendored
Normal file
50
.github/release-drafter-minio.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name-template: 'Minio - v$RESOLVED_VERSION'
|
||||||
|
tag-template: 'minio/v$RESOLVED_VERSION'
|
||||||
|
tag-prefix: minio/v
|
||||||
|
include-paths:
|
||||||
|
- minio
|
||||||
|
categories:
|
||||||
|
- title: '❗ Breaking Changes'
|
||||||
|
labels:
|
||||||
|
- '❗ BreakingChange'
|
||||||
|
- title: '🚀 New'
|
||||||
|
labels:
|
||||||
|
- '✏️ Feature'
|
||||||
|
- title: '🧹 Updates'
|
||||||
|
labels:
|
||||||
|
- '🧹 Updates'
|
||||||
|
- '🤖 Dependencies'
|
||||||
|
- title: '🐛 Fixes'
|
||||||
|
labels:
|
||||||
|
- '☢️ Bug'
|
||||||
|
- title: '📚 Documentation'
|
||||||
|
labels:
|
||||||
|
- '📒 Documentation'
|
||||||
|
change-template: '- $TITLE (#$NUMBER)'
|
||||||
|
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||||
|
exclude-contributors:
|
||||||
|
- dependabot
|
||||||
|
- dependabot[bot]
|
||||||
|
version-resolver:
|
||||||
|
major:
|
||||||
|
labels:
|
||||||
|
- 'major'
|
||||||
|
- '❗ BreakingChange'
|
||||||
|
minor:
|
||||||
|
labels:
|
||||||
|
- 'minor'
|
||||||
|
- '✏️ Feature'
|
||||||
|
patch:
|
||||||
|
labels:
|
||||||
|
- 'patch'
|
||||||
|
- '📒 Documentation'
|
||||||
|
- '☢️ Bug'
|
||||||
|
- '🤖 Dependencies'
|
||||||
|
- '🧹 Updates'
|
||||||
|
default: patch
|
||||||
|
template: |
|
||||||
|
$CHANGES
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...minio/v$RESOLVED_VERSION
|
||||||
|
|
||||||
|
Thank you $CONTRIBUTORS for making this update possible.
|
43
.github/release-drafter-scylladb.yml
vendored
Normal file
43
.github/release-drafter-scylladb.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name-template: 'ScyllaDb - v$RESOLVED_VERSION'
|
||||||
|
tag-template: 'scylladb/v$RESOLVED_VERSION'
|
||||||
|
tag-prefix: scylladb/v
|
||||||
|
include-paths:
|
||||||
|
- scylladb
|
||||||
|
categories:
|
||||||
|
- title: '🚀 New'
|
||||||
|
labels:
|
||||||
|
- '✏️ Feature'
|
||||||
|
- title: '🧹 Updates'
|
||||||
|
labels:
|
||||||
|
- '🧹 Updates'
|
||||||
|
- '🤖 Dependencies'
|
||||||
|
- title: '🐛 Fixes'
|
||||||
|
labels:
|
||||||
|
- '☢️ Bug'
|
||||||
|
- title: '📚 Documentation'
|
||||||
|
labels:
|
||||||
|
- '📒 Documentation'
|
||||||
|
change-template: '- $TITLE (#$NUMBER)'
|
||||||
|
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||||
|
version-resolver:
|
||||||
|
major:
|
||||||
|
labels:
|
||||||
|
- 'major'
|
||||||
|
minor:
|
||||||
|
labels:
|
||||||
|
- 'minor'
|
||||||
|
- '✏️ Feature'
|
||||||
|
patch:
|
||||||
|
labels:
|
||||||
|
- 'patch'
|
||||||
|
- '📒 Documentation'
|
||||||
|
- '☢️ Bug'
|
||||||
|
- '🤖 Dependencies'
|
||||||
|
- '🧹 Updates'
|
||||||
|
default: patch
|
||||||
|
template: |
|
||||||
|
$CHANGES
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...scylladb/v$RESOLVED_VERSION
|
||||||
|
|
||||||
|
Thank you $CONTRIBUTORS for making this update possible.
|
6
.github/scripts/gen-test-certs.sh
vendored
6
.github/scripts/gen-test-certs.sh
vendored
@@ -7,6 +7,8 @@
|
|||||||
# ./tls/client.{crt,key} A certificate restricted for SSL client usage.
|
# ./tls/client.{crt,key} A certificate restricted for SSL client usage.
|
||||||
# ./tls/server.{crt,key} A certificate restricted for SSL server usage.
|
# ./tls/server.{crt,key} A certificate restricted for SSL server usage.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
generate_cert() {
|
generate_cert() {
|
||||||
local name=$1
|
local name=$1
|
||||||
local cn="$2"
|
local cn="$2"
|
||||||
@@ -44,6 +46,8 @@ cat > ./tls/openssl.cnf <<_END_
|
|||||||
[ server_cert ]
|
[ server_cert ]
|
||||||
keyUsage = digitalSignature, keyEncipherment
|
keyUsage = digitalSignature, keyEncipherment
|
||||||
nsCertType = server
|
nsCertType = server
|
||||||
|
subjectAltName = DNS:localhost"
|
||||||
|
|
||||||
[ client_cert ]
|
[ client_cert ]
|
||||||
keyUsage = digitalSignature, keyEncipherment
|
keyUsage = digitalSignature, keyEncipherment
|
||||||
nsCertType = client
|
nsCertType = client
|
||||||
@@ -51,7 +55,7 @@ _END_
|
|||||||
|
|
||||||
generate_cert server "Server-only" "-extfile ./tls/openssl.cnf -extensions server_cert"
|
generate_cert server "Server-only" "-extfile ./tls/openssl.cnf -extensions server_cert"
|
||||||
generate_cert client "Client-only" "-extfile ./tls/openssl.cnf -extensions client_cert"
|
generate_cert client "Client-only" "-extfile ./tls/openssl.cnf -extensions client_cert"
|
||||||
generate_cert redis "Generic-cert"
|
generate_cert redis "localhost" "-extfile ./tls/openssl.cnf -extensions server_cert"
|
||||||
|
|
||||||
# List generated certs
|
# List generated certs
|
||||||
ls -la ./tls
|
ls -la ./tls
|
||||||
|
175
.github/workflows/benchmark.yml
vendored
Normal file
175
.github/workflows/benchmark.yml
vendored
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "**"
|
||||||
|
- "!**.md"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "**"
|
||||||
|
- "!**.md"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
deployments: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
name: Benchmark
|
||||||
|
jobs:
|
||||||
|
Compare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
arangodb:
|
||||||
|
image: 'arangodb:latest'
|
||||||
|
env:
|
||||||
|
ARANGO_NO_AUTH: 1
|
||||||
|
ports:
|
||||||
|
- '8529:8529'
|
||||||
|
dynamodb:
|
||||||
|
image: 'amazon/dynamodb-local:latest'
|
||||||
|
ports:
|
||||||
|
- '8000:8000'
|
||||||
|
memcached:
|
||||||
|
image: 'memcached:latest'
|
||||||
|
ports:
|
||||||
|
- '11211:11211'
|
||||||
|
mongo:
|
||||||
|
image: 'mongo:latest'
|
||||||
|
ports:
|
||||||
|
- '27017:27017'
|
||||||
|
mssql:
|
||||||
|
image: 'mcmoe/mssqldocker:latest'
|
||||||
|
ports:
|
||||||
|
- '1433:1433'
|
||||||
|
env:
|
||||||
|
ACCEPT_EULA: Y
|
||||||
|
SA_PASSWORD: MsSql!1234
|
||||||
|
MSSQL_DB: master
|
||||||
|
MSSQL_USER: sa
|
||||||
|
MSSQL_PASSWORD: MsSql!1234
|
||||||
|
options: >-
|
||||||
|
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD -Q 'select 1' -b -o /dev/null"
|
||||||
|
--health-interval 1s
|
||||||
|
--health-timeout 30s
|
||||||
|
--health-start-period 10s
|
||||||
|
--health-retries 20
|
||||||
|
mysql:
|
||||||
|
image: 'mysql:latest'
|
||||||
|
env:
|
||||||
|
MYSQL_DATABASE: fiber
|
||||||
|
MYSQL_USER: username
|
||||||
|
MYSQL_PASSWORD: password
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
ports:
|
||||||
|
- '3306:3306'
|
||||||
|
options: >-
|
||||||
|
--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
|
||||||
|
5s --health-retries 5
|
||||||
|
postgres:
|
||||||
|
image: 'postgres:latest'
|
||||||
|
ports:
|
||||||
|
- '5432:5432'
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: fiber
|
||||||
|
POSTGRES_USER: username
|
||||||
|
POSTGRES_PASSWORD: "pass#w%rd"
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
steps:
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
# NOTE: Keep this in sync with the version from go.mod
|
||||||
|
go-version: "1.20.x"
|
||||||
|
|
||||||
|
- name: Install Azurite
|
||||||
|
run: |
|
||||||
|
docker run -d -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0 --blobPort 10000
|
||||||
|
|
||||||
|
- name: Install Coherence
|
||||||
|
run: |
|
||||||
|
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5
|
||||||
|
sleep 30
|
||||||
|
|
||||||
|
- name: Install couchbase
|
||||||
|
run: |
|
||||||
|
docker run --name couchbase -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11207:11207 -p 11210:11210 -p 11280:11280 -p 18091-18097:18091-18097 couchbase:enterprise-7.1.1
|
||||||
|
sleep 10
|
||||||
|
docker exec --tty couchbase couchbase-cli cluster-init -c localhost:8091 --cluster-username admin --cluster-password 123456 --cluster-ramsize 256 --services data
|
||||||
|
sleep 10
|
||||||
|
docker exec --tty couchbase couchbase-cli bucket-create -c localhost:8091 --username admin --password 123456 --bucket fiber_storage --bucket-type couchbase --bucket-ramsize 100 --enable-flush 1
|
||||||
|
|
||||||
|
- name: Install etcd
|
||||||
|
run: |
|
||||||
|
docker run -d --name Etcd-server \
|
||||||
|
--publish 2379:2379 \
|
||||||
|
--publish 2380:2380 \
|
||||||
|
--env ALLOW_NONE_AUTHENTICATION=yes \
|
||||||
|
--env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379 \
|
||||||
|
bitnami/etcd:latest
|
||||||
|
|
||||||
|
- name: Install MinIO
|
||||||
|
run: |
|
||||||
|
docker run -d --restart always -p 9000:9000 --name storage-minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server /data
|
||||||
|
|
||||||
|
- name: Install ScyllaDb
|
||||||
|
run: |
|
||||||
|
docker run --name scylladb -p 9042:9042 -p 19042:19042 -p 9160:9160 -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9180:9180 -d scylladb/scylla:latest --broadcast-address 127.0.0.1 --listen-address 0.0.0.0 --broadcast-rpc-address 127.0.0.1
|
||||||
|
sleep 15 # Wait for ScyllaDb to initialize
|
||||||
|
|
||||||
|
- name: Setup Redis
|
||||||
|
uses: shogo82148/actions-setup-redis@v1
|
||||||
|
with:
|
||||||
|
redis-version: '7.x'
|
||||||
|
auto-start: 'false'
|
||||||
|
|
||||||
|
- name: Run Redis
|
||||||
|
run: |
|
||||||
|
redis-server --port 6379 &
|
||||||
|
|
||||||
|
- name: Run Benchmarks
|
||||||
|
run: |
|
||||||
|
set -o pipefail
|
||||||
|
for d in */ ; do
|
||||||
|
[[ $d == "tls/" ]] && continue
|
||||||
|
|
||||||
|
cd "$d"
|
||||||
|
go test ./... -benchmem -run=^$ -bench . | tee -a ../output.txt
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
MSSQL_DATABASE: master
|
||||||
|
MSSQL_USERNAME: sa
|
||||||
|
MSSQL_PASSWORD: MsSql!1234
|
||||||
|
MYSQL_USERNAME: username
|
||||||
|
MYSQL_PASSWORD: password
|
||||||
|
MYSQL_DATABASE: fiber
|
||||||
|
POSTGRES_DATABASE: fiber
|
||||||
|
POSTGRES_USERNAME: username
|
||||||
|
POSTGRES_PASSWORD: "pass#w%rd"
|
||||||
|
|
||||||
|
- name: Get Previous Benchmark Results
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ./cache
|
||||||
|
key: ${{ runner.os }}-benchmark
|
||||||
|
|
||||||
|
- name: Save Benchmark Results
|
||||||
|
uses: benchmark-action/github-action-benchmark@v1.18.0
|
||||||
|
with:
|
||||||
|
tool: "go"
|
||||||
|
output-file-path: output.txt
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
benchmark-data-dir-path: "benchmarks"
|
||||||
|
alert-threshold: "300%"
|
||||||
|
fail-on-alert: true
|
||||||
|
comment-on-alert: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
||||||
|
#summary-always: ${{ github.event_name != 'push' && github.event_name != 'workflow_dispatch' }}
|
||||||
|
auto-push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
||||||
|
save-data-file: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
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.
|
||||||
|
2
.github/workflows/golangci-lint.yml
vendored
2
.github/workflows/golangci-lint.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: reviewdog/action-golangci-lint@v2
|
uses: reviewdog/action-golangci-lint@v2
|
||||||
with:
|
with:
|
||||||
|
10
.github/workflows/gosec.yml
vendored
10
.github/workflows/gosec.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
@@ -72,6 +72,10 @@ jobs:
|
|||||||
working-directory: ./memory
|
working-directory: ./memory
|
||||||
run: gosec ./...
|
run: gosec ./...
|
||||||
# -----
|
# -----
|
||||||
|
- name: Run Gosec (minio)
|
||||||
|
working-directory: ./minio
|
||||||
|
run: gosec ./...
|
||||||
|
# -----
|
||||||
- name: Run Gosec (mongodb)
|
- name: Run Gosec (mongodb)
|
||||||
working-directory: ./mongodb
|
working-directory: ./mongodb
|
||||||
run: gosec ./...
|
run: gosec ./...
|
||||||
@@ -120,3 +124,7 @@ jobs:
|
|||||||
working-directory: ./rueidis
|
working-directory: ./rueidis
|
||||||
run: gosec ./...
|
run: gosec ./...
|
||||||
# -----
|
# -----
|
||||||
|
- name: Run Gosec (scylladb)
|
||||||
|
working-directory: ./scylladb
|
||||||
|
run: gosec ./...
|
||||||
|
# -----
|
||||||
|
2
.github/workflows/govulncheck.yml
vendored
2
.github/workflows/govulncheck.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
19
.github/workflows/release-drafter-memory.yml
vendored
Normal file
19
.github/workflows/release-drafter-memory.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Release Drafter Memory
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# branches to consider in the event; optional, defaults to all
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'memory/**'
|
||||||
|
jobs:
|
||||||
|
draft_release_memcache:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
with:
|
||||||
|
config-name: release-drafter-memory.yml
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
19
.github/workflows/release-drafter-minio.yml
vendored
Normal file
19
.github/workflows/release-drafter-minio.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Release Drafter Minio
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# branches to consider in the event; optional, defaults to all
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'minio/**'
|
||||||
|
jobs:
|
||||||
|
draft_release_minio:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
with:
|
||||||
|
config-name: release-drafter-minio.yml
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
19
.github/workflows/release-drafter-scylladb.yml
vendored
Normal file
19
.github/workflows/release-drafter-scylladb.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Release Drafter ScyllaDb
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# branches to consider in the event; optional, defaults to all
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'scylladb/**'
|
||||||
|
jobs:
|
||||||
|
draft_release_scylladb:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
with:
|
||||||
|
config-name: release-drafter-scylladb.yml
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
4
.github/workflows/sync-docs.yml
vendored
4
.github/workflows/sync-docs.yml
vendored
@@ -17,13 +17,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: Setup Node.js environment
|
- name: Setup Node.js environment
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
|
|
||||||
|
2
.github/workflows/test-arangodb.yml
vendored
2
.github/workflows/test-arangodb.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-azureblob.yml
vendored
2
.github/workflows/test-azureblob.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker run -d -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0 --blobPort 10000
|
docker run -d -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0 --blobPort 10000
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-badger.yml
vendored
2
.github/workflows/test-badger.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-bbolt.yml
vendored
2
.github/workflows/test-bbolt.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-coherence.yml
vendored
2
.github/workflows/test-coherence.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Startup Coherence
|
- name: Startup Coherence
|
||||||
run: |
|
run: |
|
||||||
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5
|
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5
|
||||||
|
2
.github/workflows/test-couchbase.yml
vendored
2
.github/workflows/test-couchbase.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install couchbase
|
- name: Install couchbase
|
||||||
run: |
|
run: |
|
||||||
docker run --name couchbase -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11207:11207 -p 11210:11210 -p 11280:11280 -p 18091-18097:18091-18097 couchbase:enterprise-7.1.1
|
docker run --name couchbase -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11207:11207 -p 11210:11210 -p 11280:11280 -p 18091-18097:18091-18097 couchbase:enterprise-7.1.1
|
||||||
|
2
.github/workflows/test-dynamodb.yml
vendored
2
.github/workflows/test-dynamodb.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-etcd.yml
vendored
2
.github/workflows/test-etcd.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install etcd
|
- name: Install etcd
|
||||||
run: |
|
run: |
|
||||||
docker run -d --name Etcd-server \
|
docker run -d --name Etcd-server \
|
||||||
|
2
.github/workflows/test-memcache.yml
vendored
2
.github/workflows/test-memcache.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-memory.yml
vendored
2
.github/workflows/test-memory.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
33
.github/workflows/test-minio.yml
vendored
Normal file
33
.github/workflows/test-minio.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'minio/**'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'minio/**'
|
||||||
|
name: "Tests Minio"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.19.x
|
||||||
|
- 1.20.x
|
||||||
|
- 1.21.x
|
||||||
|
steps:
|
||||||
|
- name: Install MinIO
|
||||||
|
run: |
|
||||||
|
docker run -d --restart always -p 9000:9000 --name storage-minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server /data
|
||||||
|
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./minio && go test ./... -v -race
|
2
.github/workflows/test-mongodb.yml
vendored
2
.github/workflows/test-mongodb.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-mssql.yml
vendored
2
.github/workflows/test-mssql.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-mysql.yml
vendored
2
.github/workflows/test-mysql.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-pebble.yml
vendored
2
.github/workflows/test-pebble.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-postgres.yml
vendored
2
.github/workflows/test-postgres.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
33
.github/workflows/test-redis.yml
vendored
33
.github/workflows/test-redis.yml
vendored
@@ -23,25 +23,40 @@ jobs:
|
|||||||
- '7.x'
|
- '7.x'
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Generate TLS certs
|
||||||
|
run: ./.github/scripts/gen-test-certs.sh
|
||||||
|
|
||||||
|
- name: Add Custom CA cert
|
||||||
|
run: sudo cp /home/runner/work/storage/storage/tls/ca.crt /usr/local/share/ca-certificates/custom.crt
|
||||||
|
|
||||||
|
- name: Trust Custom CA Cert
|
||||||
|
run: sudo update-ca-certificates
|
||||||
|
|
||||||
- name: Setup Redis
|
- name: Setup Redis
|
||||||
uses: shogo82148/actions-setup-redis@v1
|
uses: shogo82148/actions-setup-redis@v1
|
||||||
with:
|
with:
|
||||||
redis-version: ${{ matrix.redis }}
|
redis-version: ${{ matrix.redis }}
|
||||||
auto-start: 'false'
|
auto-start: 'false'
|
||||||
redis-port: '6379'
|
|
||||||
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 /home/runner/work/storage/storage/tls/redis.crt \
|
||||||
--tls-key-file ./redis/tests/tls/redis.key \
|
--tls-key-file /home/runner/work/storage/storage/tls/redis.key \
|
||||||
--tls-ca-cert-file ./redis/tests/tls/ca.crt&
|
--tls-ca-cert-file /home/runner/work/storage/storage/tls/ca.crt &
|
||||||
|
|
||||||
|
- name: Run Redis instance with MTLS disabled
|
||||||
|
run: |
|
||||||
|
redis-server --tls-port 16380 --port 16379 \
|
||||||
|
--tls-cert-file /home/runner/work/storage/storage/tls/redis.crt \
|
||||||
|
--tls-key-file /home/runner/work/storage/storage/tls/redis.key \
|
||||||
|
--tls-ca-cert-file /home/runner/work/storage/storage/tls/ca.crt \
|
||||||
|
--tls-auth-clients no &
|
||||||
|
|
||||||
- name: Setup Redis Cluster
|
- name: Setup Redis Cluster
|
||||||
uses: vishnudxb/redis-cluster@1.0.8
|
uses: vishnudxb/redis-cluster@1.0.9
|
||||||
with:
|
with:
|
||||||
master1-port: 7000
|
master1-port: 7000
|
||||||
master2-port: 7001
|
master2-port: 7001
|
||||||
@@ -49,6 +64,10 @@ jobs:
|
|||||||
slave1-port: 7003
|
slave1-port: 7003
|
||||||
slave2-port: 7004
|
slave2-port: 7004
|
||||||
slave3-port: 7005
|
slave3-port: 7005
|
||||||
|
sleep-duration: 10
|
||||||
|
|
||||||
|
- name: Wait for Redis to Start
|
||||||
|
run: sleep 15
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
|
2
.github/workflows/test-ristretto.yml
vendored
2
.github/workflows/test-ristretto.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
5
.github/workflows/test-rueidis.yml
vendored
5
.github/workflows/test-rueidis.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
|||||||
- '7.x'
|
- '7.x'
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Generate TLS certs
|
- name: Generate TLS certs
|
||||||
run: ./.github/scripts/gen-test-certs.sh
|
run: ./.github/scripts/gen-test-certs.sh
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
--tls-ca-cert-file /home/runner/work/storage/storage/tls/ca.crt &
|
--tls-ca-cert-file /home/runner/work/storage/storage/tls/ca.crt &
|
||||||
|
|
||||||
- name: Setup Redis Cluster
|
- name: Setup Redis Cluster
|
||||||
uses: vishnudxb/redis-cluster@1.0.8
|
uses: vishnudxb/redis-cluster@1.0.9
|
||||||
with:
|
with:
|
||||||
master1-port: 7000
|
master1-port: 7000
|
||||||
master2-port: 7001
|
master2-port: 7001
|
||||||
@@ -51,6 +51,7 @@ jobs:
|
|||||||
slave1-port: 7003
|
slave1-port: 7003
|
||||||
slave2-port: 7004
|
slave2-port: 7004
|
||||||
slave3-port: 7005
|
slave3-port: 7005
|
||||||
|
sleep-duration: 10
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
|
11
.github/workflows/test-s3.yml
vendored
11
.github/workflows/test-s3.yml
vendored
@@ -20,16 +20,9 @@ jobs:
|
|||||||
- 1.21.x
|
- 1.21.x
|
||||||
steps:
|
steps:
|
||||||
- name: Install MinIO
|
- name: Install MinIO
|
||||||
run: |
|
run: docker run -d --restart always -p 9000:9000 --name storage-minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server /data
|
||||||
docker run -d -p 9000:9000 --name minio minio/minio server /data
|
|
||||||
|
|
||||||
export AWS_ACCESS_KEY_ID=minioadmin
|
|
||||||
export AWS_SECRET_ACCESS_KEY=minioadmin
|
|
||||||
export AWS_EC2_METADATA_DISABLED=true
|
|
||||||
|
|
||||||
aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://testbucket
|
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
39
.github/workflows/test-scylladb.yml
vendored
Normal file
39
.github/workflows/test-scylladb.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'scylladb/**'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'scylladb/**'
|
||||||
|
|
||||||
|
name: "Tests ScyllaDb"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.20.x
|
||||||
|
- 1.21.x
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Run ScyllaDb
|
||||||
|
run: |
|
||||||
|
docker run --name scylladb -p 9042:9042 -p 19042:19042 -p 9160:9160 -p 10000:10000 -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9180:9180 -d scylladb/scylla:latest --broadcast-address 127.0.0.1 --listen-address 0.0.0.0 --broadcast-rpc-address 127.0.0.1
|
||||||
|
sleep 30 # Wait for ScyllaDb to initialize
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./scylladb && go test ./... -v -race
|
2
.github/workflows/test-sqlite3.yml
vendored
2
.github/workflows/test-sqlite3.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
@@ -60,6 +60,7 @@ type Storage interface {
|
|||||||
- [Etcd](./etcd/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Etcd%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-etcd.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [Etcd](./etcd/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Etcd%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-etcd.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [Memcache](./memcache/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Memcache%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memcache.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [Memcache](./memcache/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Memcache%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memcache.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [Memory](./memory/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Local+Storage%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memory.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [Memory](./memory/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Local+Storage%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memory.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
|
- [Minio](./minio/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Minio%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-minio.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [MongoDB](./mongodb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Mongodb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mongodb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [MongoDB](./mongodb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Mongodb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mongodb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [MSSQL](./mssql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MSSQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mssql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [MSSQL](./mssql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MSSQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mssql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [MySQL](./mysql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MySQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mysql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [MySQL](./mysql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MySQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mysql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
@@ -68,5 +69,6 @@ type Storage interface {
|
|||||||
- [Redis](./redis/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Redis%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-redis.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [Redis](./redis/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Redis%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-redis.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [Rueidis](./rueidis/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+rueidis%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-rueidis.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [Rueidis](./rueidis/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+rueidis%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-rueidis.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [S3](./s3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+S3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-s3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [S3](./s3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+S3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-s3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
|
- [ScyllaDB](./scylladb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+scylladb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-scylladb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
- [SQLite3](./sqlite3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Sqlite3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-sqlite3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
- [SQLite3](./sqlite3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Sqlite3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-sqlite3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ var testStore = New(Config{
|
|||||||
Reset: true,
|
Reset: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
func Test_ARANGODB_Set(t *testing.T) {
|
func Test_ArangoDB_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -21,7 +21,7 @@ func Test_ARANGODB_Set(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Upsert(t *testing.T) {
|
func Test_ArangoDB_Upsert(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -34,7 +34,7 @@ func Test_ARANGODB_Upsert(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Get(t *testing.T) {
|
func Test_ArangoDB_Get(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -48,7 +48,7 @@ func Test_ARANGODB_Get(t *testing.T) {
|
|||||||
require.Equal(t, val, result)
|
require.Equal(t, val, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Set_Expiration(t *testing.T) {
|
func Test_ArangoDB_Set_Expiration(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -61,7 +61,7 @@ func Test_ARANGODB_Set_Expiration(t *testing.T) {
|
|||||||
time.Sleep(1100 * time.Millisecond)
|
time.Sleep(1100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Get_Expired(t *testing.T) {
|
func Test_ArangoDB_Get_Expired(t *testing.T) {
|
||||||
key := "john"
|
key := "john"
|
||||||
|
|
||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
@@ -69,13 +69,13 @@ func Test_ARANGODB_Get_Expired(t *testing.T) {
|
|||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Get_NotExist(t *testing.T) {
|
func Test_ArangoDB_Get_NotExist(t *testing.T) {
|
||||||
result, err := testStore.Get("notexist")
|
result, err := testStore.Get("notexist")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Delete(t *testing.T) {
|
func Test_ArangoDB_Delete(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -92,7 +92,7 @@ func Test_ARANGODB_Delete(t *testing.T) {
|
|||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Reset(t *testing.T) {
|
func Test_ArangoDB_Reset(t *testing.T) {
|
||||||
val := []byte("doe")
|
val := []byte("doe")
|
||||||
|
|
||||||
err := testStore.Set("john1", val, 0)
|
err := testStore.Set("john1", val, 0)
|
||||||
@@ -113,7 +113,7 @@ func Test_ARANGODB_Reset(t *testing.T) {
|
|||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Non_UTF8(t *testing.T) {
|
func Test_ArangoDB_Non_UTF8(t *testing.T) {
|
||||||
val := []byte("0xF5")
|
val := []byte("0xF5")
|
||||||
|
|
||||||
err := testStore.Set("0xF6", val, 0)
|
err := testStore.Set("0xF6", val, 0)
|
||||||
@@ -124,10 +124,49 @@ func Test_ARANGODB_Non_UTF8(t *testing.T) {
|
|||||||
require.Equal(t, val, result)
|
require.Equal(t, val, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Close(t *testing.T) {
|
func Test_ArangoDB_Close(t *testing.T) {
|
||||||
require.Nil(t, testStore.Close())
|
require.Nil(t, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ARANGODB_Conn(t *testing.T) {
|
func Test_ArangoDB_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_ArangoDB_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_ArangoDB_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_ArangoDB_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -3,7 +3,7 @@ module github.com/gofiber/storage/arangodb/v2
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/arangodb/go-driver v1.6.0
|
github.com/arangodb/go-driver v1.6.1
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.3
|
github.com/gofiber/utils/v2 v2.0.0-beta.3
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
github.com/arangodb/go-driver v1.6.0 h1:NFWj/idqXZxhFVueihMSI2R9NotNIsgvNfM/xmpekb4=
|
github.com/arangodb/go-driver v1.6.1 h1:bnhrpbA4U1NU13JOWs5sWWYMtQwdjKT0+jkl8dSndyY=
|
||||||
github.com/arangodb/go-driver v1.6.0/go.mod h1:HQmdGkvNMVBTE3SIPSQ8T/ZddC6iwNsfMR+dDJQxIsI=
|
github.com/arangodb/go-driver v1.6.1/go.mod h1:ywucwwi34GBxxXFWw/ym+7/66//L4K9abxk/sFJro2k=
|
||||||
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/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=
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
package azureblob
|
package azureblob
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror"
|
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStore() *Storage {
|
var testStore *Storage
|
||||||
return New(Config{
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(Config{
|
||||||
Account: "devstoreaccount1",
|
Account: "devstoreaccount1",
|
||||||
Container: "test",
|
Container: "test",
|
||||||
Endpoint: "http://127.0.0.1:10000/devstoreaccount1",
|
Endpoint: "http://127.0.0.1:10000/devstoreaccount1",
|
||||||
@@ -16,7 +19,13 @@ func newStore() *Storage {
|
|||||||
Account: "devstoreaccount1",
|
Account: "devstoreaccount1",
|
||||||
Key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
|
Key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
|
||||||
},
|
},
|
||||||
|
Reset: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_AzureBlob_Get(t *testing.T) {
|
func Test_AzureBlob_Get(t *testing.T) {
|
||||||
@@ -24,7 +33,6 @@ func Test_AzureBlob_Get(t *testing.T) {
|
|||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
testStore := newStore()
|
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -40,7 +48,6 @@ func Test_AzureBlob_Set(t *testing.T) {
|
|||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
|
|
||||||
testStore := newStore()
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
@@ -50,7 +57,6 @@ func Test_AzureBlob_Delete(t *testing.T) {
|
|||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
testStore := newStore()
|
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -73,7 +79,6 @@ func Test_AzureBlob_Override(t *testing.T) {
|
|||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
testStore := newStore()
|
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -83,7 +88,6 @@ func Test_AzureBlob_Override(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_AzureBlob_Get_NotExist(t *testing.T) {
|
func Test_AzureBlob_Get_NotExist(t *testing.T) {
|
||||||
testStore := newStore()
|
|
||||||
result, err := testStore.Get("notexist")
|
result, err := testStore.Get("notexist")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if bloberror.HasCode(err, bloberror.BlobNotFound) {
|
if bloberror.HasCode(err, bloberror.BlobNotFound) {
|
||||||
@@ -96,7 +100,6 @@ func Test_AzureBlob_Get_NotExist(t *testing.T) {
|
|||||||
|
|
||||||
func Test_AzureBlob_Reset(t *testing.T) {
|
func Test_AzureBlob_Reset(t *testing.T) {
|
||||||
val := []byte("doe")
|
val := []byte("doe")
|
||||||
testStore := newStore()
|
|
||||||
|
|
||||||
err := testStore.Set("john1", val, 0)
|
err := testStore.Set("john1", val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -127,11 +130,48 @@ func Test_AzureBlob_Reset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_S3_Conn(t *testing.T) {
|
func Test_S3_Conn(t *testing.T) {
|
||||||
testStore := newStore()
|
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_AzureBlob_Close(t *testing.T) {
|
func Test_AzureBlob_Close(t *testing.T) {
|
||||||
testStore := newStore()
|
|
||||||
require.Nil(t, testStore.Close())
|
require.Nil(t, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_AzureBlob_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_AzureBlob_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_AzureBlob_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -3,7 +3,7 @@ module github.com/gofiber/storage/azureblob/v2
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ require (
|
|||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.17.0 // indirect
|
||||||
golang.org/x/text v0.12.0 // indirect
|
golang.org/x/text v0.13.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
@@ -4,8 +4,8 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybI
|
|||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
|
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0 h1:nVocQV40OQne5613EeLayJiRAJuKlBGy+m22qWG+WRg=
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+3LoSsYf9YMjkupeAnHMX8O9mmY=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0/go.mod h1:7QJP7dr2wznCMeqIrhMgWGf7XpAQnVrJqDm9nvV3Cu4=
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4=
|
||||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY=
|
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY=
|
||||||
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=
|
||||||
@@ -18,12 +18,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
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.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
@@ -7,7 +7,9 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New()
|
var testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
func Test_Badger_Set(t *testing.T) {
|
func Test_Badger_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
@@ -118,3 +120,42 @@ func Test_Badger_Close(t *testing.T) {
|
|||||||
func Test_Badger_Conn(t *testing.T) {
|
func Test_Badger_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Badger_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Badger_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Badger_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -25,8 +25,8 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.11.0 // indirect
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
@@ -142,8 +142,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@@ -158,8 +158,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
@@ -1,12 +1,25 @@
|
|||||||
package bbolt
|
package bbolt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New()
|
var testStore *Storage
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(Config{
|
||||||
|
Bucket: "fiber-bucket",
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Bbolt_Set(t *testing.T) {
|
func Test_Bbolt_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
@@ -96,3 +109,42 @@ func Test_Bbolt_Close(t *testing.T) {
|
|||||||
func Test_Bbolt_Conn(t *testing.T) {
|
func Test_Bbolt_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Bbolt_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Bbolt_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Bbolt_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -5,7 +5,7 @@ go 1.19
|
|||||||
require (
|
require (
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.3
|
github.com/gofiber/utils/v2 v2.0.0-beta.3
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
go.etcd.io/bbolt v1.3.7
|
go.etcd.io/bbolt v1.3.8
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
@@ -8,8 +8,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
|
go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
|
||||||
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
|
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
|
||||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package bbolt
|
package bbolt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"github.com/gofiber/utils/v2"
|
"github.com/gofiber/utils/v2"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
@@ -15,6 +16,11 @@ func createBucket(cfg Config, conn *bbolt.DB) error {
|
|||||||
|
|
||||||
func removeBucket(cfg Config, conn *bbolt.DB) error {
|
func removeBucket(cfg Config, conn *bbolt.DB) error {
|
||||||
return conn.Update(func(tx *bbolt.Tx) error {
|
return conn.Update(func(tx *bbolt.Tx) error {
|
||||||
return tx.DeleteBucket(utils.UnsafeBytes(cfg.Bucket))
|
err := tx.DeleteBucket(utils.UnsafeBytes(cfg.Bucket))
|
||||||
|
if errors.Is(err, bbolt.ErrBucketNotFound) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
defaultScopeName = "default-store"
|
defaultScopeName = "default-store"
|
||||||
defaultTimeout = time.Duration(30) * time.Millisecond
|
defaultTimeout = time.Duration(30) * time.Second
|
||||||
|
defaultAddress = "localhost:1408"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage represents an implementation of Coherence storage provider.
|
// Storage represents an implementation of Coherence storage provider.
|
||||||
@@ -42,30 +43,20 @@ type Config struct {
|
|||||||
|
|
||||||
// DefaultConfig defines default options.
|
// DefaultConfig defines default options.
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
Address: "localhost:1408",
|
Address: defaultAddress,
|
||||||
Timeout: time.Duration(30) * time.Millisecond,
|
Timeout: defaultTimeout,
|
||||||
ScopeName: defaultScopeName,
|
ScopeName: defaultScopeName,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new [Storage] given a [coherence.Session].
|
// New returns a new [Storage] given a [Config].
|
||||||
func New(config ...Config) (*Storage, error) {
|
func New(config ...Config) (*Storage, error) {
|
||||||
var (
|
cfg := setupConfig(config...)
|
||||||
scopeName = defaultScopeName
|
|
||||||
cfg = DefaultConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(config) == 1 {
|
|
||||||
cfg = config[0]
|
|
||||||
}
|
|
||||||
options := make([]func(session *coh.SessionOptions), 0)
|
options := make([]func(session *coh.SessionOptions), 0)
|
||||||
|
|
||||||
// apply any config values
|
// apply any config values as Coherence options
|
||||||
if cfg.Address != "" {
|
options = append(options, coh.WithAddress(cfg.Address))
|
||||||
options = append(options, coh.WithAddress(cfg.Address))
|
|
||||||
} else {
|
|
||||||
cfg.Address = DefaultConfig.Address
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.TLSConfig != nil {
|
if cfg.TLSConfig != nil {
|
||||||
options = append(options, coh.WithTLSConfig(cfg.TLSConfig))
|
options = append(options, coh.WithTLSConfig(cfg.TLSConfig))
|
||||||
@@ -73,13 +64,7 @@ func New(config ...Config) (*Storage, error) {
|
|||||||
options = append(options, coh.WithPlainText())
|
options = append(options, coh.WithPlainText())
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Timeout != defaultTimeout {
|
options = append(options, coh.WithRequestTimeout(cfg.Timeout))
|
||||||
options = append(options, coh.WithReadyTimeout(cfg.Timeout))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.ScopeName != defaultScopeName {
|
|
||||||
scopeName = cfg.ScopeName
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the Coherence session
|
// create the Coherence session
|
||||||
session, err := coh.NewSession(context.Background(), options...)
|
session, err := coh.NewSession(context.Background(), options...)
|
||||||
@@ -87,7 +72,7 @@ func New(config ...Config) (*Storage, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
store, err := newCoherenceStorage(session, scopeName)
|
store, err := newCoherenceStorage(session, cfg.ScopeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -100,6 +85,29 @@ func New(config ...Config) (*Storage, error) {
|
|||||||
return store, nil
|
return store, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setupConfig sets the default config.
|
||||||
|
func setupConfig(config ...Config) Config {
|
||||||
|
// if nothing provided then use the default config values
|
||||||
|
if len(config) == 0 {
|
||||||
|
return DefaultConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := config[0]
|
||||||
|
|
||||||
|
// Check for any invalid default values and overwrite them
|
||||||
|
if cfg.Address == "" {
|
||||||
|
cfg.Address = DefaultConfig.Address
|
||||||
|
}
|
||||||
|
if cfg.ScopeName == "" {
|
||||||
|
cfg.ScopeName = DefaultConfig.ScopeName
|
||||||
|
}
|
||||||
|
if cfg.Timeout == 0 {
|
||||||
|
cfg.Timeout = DefaultConfig.Timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
// newCoherenceStorage returns a new Coherence [Storage].
|
// newCoherenceStorage returns a new Coherence [Storage].
|
||||||
func newCoherenceStorage(session *coh.Session, cacheName string) (*Storage, error) {
|
func newCoherenceStorage(session *coh.Session, cacheName string) (*Storage, error) {
|
||||||
nc, err := coh.GetNamedCache[string, []byte](session, "fiber$"+cacheName)
|
nc, err := coh.GetNamedCache[string, []byte](session, "fiber$"+cacheName)
|
||||||
|
@@ -4,7 +4,8 @@ package coherence
|
|||||||
* Copyright © 2023, Oracle and/or its affiliates.
|
* Copyright © 2023, Oracle and/or its affiliates.
|
||||||
*/
|
*/
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/utils"
|
"github.com/stretchr/testify/require"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -17,152 +18,145 @@ var (
|
|||||||
value2 = []byte("value2")
|
value2 = []byte("value2")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var testStore *Storage
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore, _ = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newTestStore returns a new Coherence Store and ensures it is reset.
|
||||||
|
func newTestStore(t testing.TB, config ...Config) (*Storage, error) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
testStore, err := New(config...)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = testStore.Reset()
|
||||||
|
|
||||||
|
return testStore, err
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Coherence_Set_And_Get(t *testing.T) {
|
func Test_Coherence_Set_And_Get(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
err := testStore.Set(key1, value1, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set(key1, value1, 0)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value1, val)
|
require.Equal(t, value1, val)
|
||||||
|
|
||||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
require.NotNil(t, testStore.Conn())
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Coherence_Set_Override(t *testing.T) {
|
func Test_Coherence_Set_Override(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
err := testStore.Set(key1, value1, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set(key1, value1, 0)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
err = testStore.Set(key1, value2, 0)
|
err = testStore.Set(key1, value2, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value2, val)
|
require.Equal(t, value2, val)
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Coherence_Set_With_Reset(t *testing.T) {
|
func Test_Coherence_Set_With_Reset(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
err := testStore.Set(key1, value1, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set(key1, value1, 0)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value1, val)
|
require.Equal(t, value1, val)
|
||||||
|
|
||||||
// get a new store but reset it, so the subsequent Get will return nil
|
// get a new store but reset it, so the subsequent Get will return nil
|
||||||
testStore, err = newTestStore(t, Config{Reset: true})
|
testStore2, err := newTestStore(t, Config{Reset: true})
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore2.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(val) == 0)
|
require.True(t, len(val) == 0)
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
require.Equal(t, nil, testStore2.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Coherence_Set_With_Expiry(t *testing.T) {
|
func Test_Coherence_Set_With_Expiry(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
// set with an expiry of 5 seconds
|
// set with an expiry of 5 seconds
|
||||||
err = testStore.Set(key1, value1, time.Duration(5)*time.Second)
|
err := testStore.Set(key1, value1, time.Duration(5)*time.Second)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
time.Sleep(time.Duration(6) * time.Second)
|
time.Sleep(time.Duration(6) * time.Second)
|
||||||
|
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(val) == 0)
|
require.True(t, len(val) == 0)
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Coherence_Get_Missing(t *testing.T) {
|
func Test_Coherence_Get_Missing(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
val, err := testStore.Get(missingKey)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(val) == 0)
|
||||||
val, err = testStore.Get(missingKey)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
utils.AssertEqual(t, true, len(val) == 0)
|
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Coherence_Reset(t *testing.T) {
|
func Test_Coherence_Reset(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
err := testStore.Set(key1, value1, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set(key1, value1, 0)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
err = testStore.Set(key2, value2, 0)
|
err = testStore.Set(key2, value2, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// check the keys exist
|
// check the keys exist
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value1, val)
|
require.Equal(t, value1, val)
|
||||||
|
|
||||||
val, err = testStore.Get(key2)
|
val, err = testStore.Get(key2)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value2, val)
|
require.Equal(t, value2, val)
|
||||||
|
|
||||||
// reset the store, this should remove both entries
|
// reset the store, this should remove both entries
|
||||||
err = testStore.Reset()
|
err = testStore.Reset()
|
||||||
|
|
||||||
// check the keys have expired
|
// check the keys have expired
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(val) == 0)
|
require.True(t, len(val) == 0)
|
||||||
|
|
||||||
val, err = testStore.Get(key2)
|
val, err = testStore.Get(key2)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(val) == 0)
|
require.True(t, len(val) == 0)
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Coherence_Set_And_Delete(t *testing.T) {
|
func Test_Coherence_Set_And_Delete(t *testing.T) {
|
||||||
var val []byte
|
var val []byte
|
||||||
|
|
||||||
testStore, err := newTestStore(t)
|
err := testStore.Set(key1, value1, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set(key1, value1, 0)
|
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
err = testStore.Delete(key1)
|
err = testStore.Delete(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// ensure the key has gone
|
// ensure the key has gone
|
||||||
val, err = testStore.Get(key1)
|
val, err = testStore.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(val) == 0)
|
require.True(t, len(val) == 0)
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore.Close(), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCoherenceWithScope ensures we can create multiple session stores with multiple scopes.
|
// TestCoherenceWithScope ensures we can create multiple session stores with multiple scopes.
|
||||||
@@ -171,37 +165,66 @@ func Test_Coherence_With_Scope(t *testing.T) {
|
|||||||
|
|
||||||
// create two session stores with different scopes
|
// create two session stores with different scopes
|
||||||
testStore1, err := newTestStore(t, Config{ScopeName: "scope1"})
|
testStore1, err := newTestStore(t, Config{ScopeName: "scope1"})
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testStore2, err := newTestStore(t, Config{ScopeName: "scope2"})
|
testStore2, err := newTestStore(t, Config{ScopeName: "scope2"})
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// ensure we can put the same key with different values in each scope
|
// ensure we can put the same key with different values in each scope
|
||||||
err = testStore1.Set(key1, value1, 0)
|
err = testStore1.Set(key1, value1, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore2.Set(key1, value2, 0)
|
err = testStore2.Set(key1, value2, 0)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// ensure the value of "key1" is different for each store
|
// ensure the value of "key1" is different for each store
|
||||||
val, err = testStore1.Get(key1)
|
val, err = testStore1.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value1, val)
|
require.Equal(t, value1, val)
|
||||||
|
|
||||||
val, err = testStore2.Get(key1)
|
val, err = testStore2.Get(key1)
|
||||||
utils.AssertEqual(t, err, nil)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, value2, val)
|
require.Equal(t, value2, val)
|
||||||
|
|
||||||
utils.AssertEqual(t, testStore1.Close(), nil)
|
require.NoError(t, testStore1.Close())
|
||||||
utils.AssertEqual(t, testStore2.Close(), nil)
|
require.NoError(t, testStore2.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTestStore returns a new Coherence Store and ensures it is reset.
|
func Benchmark_Coherence_Set(b *testing.B) {
|
||||||
func newTestStore(t *testing.T, config ...Config) (*Storage, error) {
|
b.ReportAllocs()
|
||||||
testStore, err := New(config...)
|
b.ResetTimer()
|
||||||
utils.AssertEqual(t, err, nil)
|
|
||||||
|
|
||||||
err = testStore.Reset()
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
return testStore, err
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Coherence_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Coherence_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
|
@@ -2,17 +2,25 @@ module github.com/gofiber/storage/coherence
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require github.com/oracle/coherence-go-client v1.0.1
|
require (
|
||||||
|
github.com/oracle/coherence-go-client v1.0.3
|
||||||
require google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
|
github.com/stretchr/testify v1.8.4
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/kr/text v0.2.0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gofiber/utils v1.1.0
|
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/uuid v1.3.1 // indirect
|
github.com/google/uuid v1.3.1 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.11.0 // indirect
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
golang.org/x/text v0.12.0 // indirect
|
golang.org/x/text v0.13.0 // indirect
|
||||||
google.golang.org/grpc v1.57.0 // indirect
|
google.golang.org/grpc v1.58.3 // indirect
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
|
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/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
@@ -7,22 +8,33 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
github.com/oracle/coherence-go-client v1.0.1 h1:MJ9S46+G8DHg/b3c/XB+mGA58wmTE0HdBCH1t+WrIBs=
|
github.com/oracle/coherence-go-client v1.0.3 h1:P8Rzgo21BAaJsKzemzMCFY9I27PdKBpr5ZqrHhZ7zPg=
|
||||||
github.com/oracle/coherence-go-client v1.0.1/go.mod h1:tdIKuX6brsdTCARlbxeRYiOF0TA4tA8ujHO4BCS1mjk=
|
github.com/oracle/coherence-go-client v1.0.3/go.mod h1:IAk8etsxzhUK6YaGzbInR1LYlh+1fiG85bGpyvzY0QY=
|
||||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
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=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
|
||||||
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
|
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
|
||||||
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
|
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@@ -7,123 +7,139 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetCouchbase_ShouldReturnNoError(t *testing.T) {
|
func newTestStore(t testing.TB) *Storage {
|
||||||
testStorage := New(Config{
|
t.Helper()
|
||||||
|
return New(Config{
|
||||||
Username: "admin",
|
Username: "admin",
|
||||||
Password: "123456",
|
Password: "123456",
|
||||||
Host: "127.0.0.1:8091",
|
Host: "127.0.0.1:8091",
|
||||||
Bucket: "fiber_storage",
|
Bucket: "fiber_storage",
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("test"), 0)
|
func TestSetCouchbase_ShouldReturnNoError(t *testing.T) {
|
||||||
|
testStore := newTestStore(t)
|
||||||
|
|
||||||
|
err := testStore.Set("test", []byte("test"), 0)
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCouchbase_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) {
|
func TestGetCouchbase_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
|
||||||
Host: "127.0.0.1:8091",
|
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
|
||||||
|
|
||||||
val, err := testStorage.Get("not_found_key")
|
val, err := testStore.Get("not_found_key")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(val))
|
require.Zero(t, len(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) {
|
func TestSetAndGet_GetShouldReturn_SetValueWithoutError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
|
||||||
Host: "127.0.0.1:8091",
|
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 0)
|
err := testStore.Set("test", []byte("fiber_test_value"), 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
val, err := testStorage.Get("test")
|
val, err := testStore.Get("test")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, val, []byte("fiber_test_value"))
|
require.Equal(t, val, []byte("fiber_test_value"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) {
|
func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
|
||||||
Host: "127.0.0.1:8091",
|
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 3*time.Second)
|
err := testStore.Set("test", []byte("fiber_test_value"), 3*time.Second)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
time.Sleep(6 * time.Second)
|
time.Sleep(6 * time.Second)
|
||||||
|
|
||||||
val, err := testStorage.Get("test")
|
val, err := testStore.Get("test")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(val))
|
require.Zero(t, len(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) {
|
func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
|
||||||
Host: "127.0.0.1:8091",
|
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 0)
|
err := testStore.Set("test", []byte("fiber_test_value"), 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStorage.Delete("test")
|
err = testStore.Delete("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = testStorage.Get("test")
|
_, err = testStore.Get("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) {
|
func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
|
||||||
Host: "127.0.0.1:8091",
|
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 0)
|
err := testStore.Set("test", []byte("fiber_test_value"), 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStorage.Reset()
|
err = testStore.Reset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = testStorage.Get("test")
|
_, err = testStore.Get("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClose_CloseShouldReturn_NoError(t *testing.T) {
|
func TestClose_CloseShouldReturn_NoError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
|
||||||
Host: "127.0.0.1:8091",
|
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Close()
|
err := testStore.Close()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetConn_ReturnsNotNill(t *testing.T) {
|
func TestGetConn_ReturnsNotNil(t *testing.T) {
|
||||||
testStorage := New(Config{
|
testStore := newTestStore(t)
|
||||||
Username: "admin",
|
|
||||||
Password: "123456",
|
require.True(t, testStore.Conn() != nil)
|
||||||
Host: "127.0.0.1:8091",
|
}
|
||||||
Bucket: "fiber_storage",
|
|
||||||
})
|
func Benchmark_Couchbase_Set(b *testing.B) {
|
||||||
require.True(t, testStorage.Conn() != nil)
|
testStore := newTestStore(b)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Couchbase_Get(b *testing.B) {
|
||||||
|
testStore := newTestStore(b)
|
||||||
|
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Couchbase_SetAndDelete(b *testing.B) {
|
||||||
|
testStore := newTestStore(b)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
|
@@ -3,15 +3,15 @@ module github.com/gofiber/storage/couchbase/v2
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/couchbase/gocb/v2 v2.6.3
|
github.com/couchbase/gocb/v2 v2.6.5
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/couchbase/gocbcore/v10 v10.2.3 // indirect
|
github.com/couchbase/gocbcore/v10 v10.2.9 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/uuid v1.3.0 // indirect
|
github.com/google/uuid v1.3.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
github.com/couchbase/gocb/v2 v2.6.3 h1:5RsMo+RRfK0mVxHLAfpBz3/tHlgXZb1WBNItLk9Ab+c=
|
github.com/couchbase/gocb/v2 v2.6.5 h1:xaZu29o8UJEV1ZQ3n2s9jcRCUHz/JsQ6+y6JBnVsy5A=
|
||||||
github.com/couchbase/gocb/v2 v2.6.3/go.mod h1:yF5F6BHTZ/ZowhEuZbySbXrlI4rHd1TIhm5azOaMbJU=
|
github.com/couchbase/gocb/v2 v2.6.5/go.mod h1:0vFM09y+VPhnXeNrIb8tS0wKHGpJvjJBrJnriWEiwGs=
|
||||||
github.com/couchbase/gocbcore/v10 v10.2.3 h1:PEkRSNSkKjUBXx82Ucr094+anoiCG5GleOOQZOHo6D4=
|
github.com/couchbase/gocbcore/v10 v10.2.9 h1:zph/+ceu3JtZEDKhJMTRc6lGrahq+mnlQY/1dSepJuE=
|
||||||
github.com/couchbase/gocbcore/v10 v10.2.3/go.mod h1:lYQIIk+tzoMcwtwU5GzPbDdqEkwkH3isI2rkSpfL0oM=
|
github.com/couchbase/gocbcore/v10 v10.2.9/go.mod h1:lYQIIk+tzoMcwtwU5GzPbDdqEkwkH3isI2rkSpfL0oM=
|
||||||
github.com/couchbaselabs/gocaves/client v0.0.0-20230307083111-cc3960c624b1/go.mod h1:AVekAZwIY2stsJOMWLAS/0uA/+qdp7pjO8EHnl61QkY=
|
github.com/couchbaselabs/gocaves/client v0.0.0-20230307083111-cc3960c624b1/go.mod h1:AVekAZwIY2stsJOMWLAS/0uA/+qdp7pjO8EHnl61QkY=
|
||||||
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259 h1:2TXy68EGEzIMHOx9UvczR5ApVecwCfQZ0LjkmwMI6g4=
|
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259 h1:2TXy68EGEzIMHOx9UvczR5ApVecwCfQZ0LjkmwMI6g4=
|
||||||
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259/go.mod h1:AVekAZwIY2stsJOMWLAS/0uA/+qdp7pjO8EHnl61QkY=
|
github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259/go.mod h1:AVekAZwIY2stsJOMWLAS/0uA/+qdp7pjO8EHnl61QkY=
|
||||||
@@ -10,8 +10,9 @@ 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/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||||
|
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
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=
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
package dynamodb
|
package dynamodb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New(
|
var testStore *Storage
|
||||||
Config{
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(Config{
|
||||||
Table: "fiber_storage",
|
Table: "fiber_storage",
|
||||||
Endpoint: "http://localhost:8000/",
|
Endpoint: "http://localhost:8000/",
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
@@ -15,8 +18,14 @@ var testStore = New(
|
|||||||
AccessKey: "dummy",
|
AccessKey: "dummy",
|
||||||
SecretAccessKey: "dummy",
|
SecretAccessKey: "dummy",
|
||||||
},
|
},
|
||||||
},
|
Reset: true,
|
||||||
)
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_DynamoDB_Set(t *testing.T) {
|
func Test_DynamoDB_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
@@ -106,3 +115,42 @@ func Test_DynamoDB_Close(t *testing.T) {
|
|||||||
func Test_DynamoDB_Conn(t *testing.T) {
|
func Test_DynamoDB_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_DynamoDB_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_DynamoDB_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_DynamoDB_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -3,27 +3,27 @@ module github.com/gofiber/storage/dynamodb/v2
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go-v2 v1.21.0
|
github.com/aws/aws-sdk-go-v2 v1.22.1
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.18.36
|
github.com/aws/aws-sdk-go-v2/config v1.22.0
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.13.35
|
github.com/aws/aws-sdk-go-v2/credentials v1.15.1
|
||||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.39
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.12.0
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.5
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.5.0 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.5 // indirect
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.17.0 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 // indirect
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.35 // indirect
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.1 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sso v1.17.0 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.0 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sts v1.25.0 // indirect
|
||||||
github.com/aws/smithy-go v1.14.2 // indirect
|
github.com/aws/smithy-go v1.16.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
@@ -1,42 +1,41 @@
|
|||||||
github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc=
|
github.com/aws/aws-sdk-go-v2 v1.22.1 h1:sjnni/AuoTXxHitsIdT0FwmqUuNUuHtufcVDErVFT9U=
|
||||||
github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M=
|
github.com/aws/aws-sdk-go-v2 v1.22.1/go.mod h1:Kd0OJtkW3Q0M0lUWGszapWjEvrXDzRW+D21JNsroB+c=
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.18.36 h1:mLNA12PWU1Y+ueOO79QgQfKIPhc1MYKl44RmvASkJ7Q=
|
github.com/aws/aws-sdk-go-v2/config v1.22.0 h1:9Mm99OalzZRz0ab5fpodMoHBApHS6pqRNp3M9NmzvDg=
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.18.36/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ=
|
github.com/aws/aws-sdk-go-v2/config v1.22.0/go.mod h1:2eWgw5lps8fKI7LZVTrRTYP6HE6k/uEFUuTSHfXwqP0=
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8=
|
github.com/aws/aws-sdk-go-v2/credentials v1.15.1 h1:hmf6lAm9hk7uLCfapZn/jL05lm6Uwdbn1B0fgjyuf4M=
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8=
|
github.com/aws/aws-sdk-go-v2/credentials v1.15.1/go.mod h1:QTcHga3ZbQOneJuxmGBOCxiClxmp+TlvmjFexAnJ790=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.39 h1:DX/r3aNL7pIVn0K5a+ESL0Fw9ti7Rj05pblEiIJtPmQ=
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.12.0 h1:nKmTvugKsuO2bHkL0vkpHEFtRoT/ijOVx0VdP+LLjgw=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.39/go.mod h1:oTk09orqXlwSKnKf+UQhy+4Ci7aCo9x8hn0ZvPCLrns=
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.12.0/go.mod h1:vxJ/EEKuP9CCSG4lEViyU9i5gr2M0X5OIJqTcX/oxuU=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg=
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2 h1:gIeH4+o1MN/caGBWjoGQTUTIu94xD6fI5B2+TcwBf70=
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8=
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.2/go.mod h1:wLyMIo/zPOhQhPXTddpfdkSleyigtFi8iMnC+2m/SK4=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g=
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1 h1:fi1ga6WysOyYb5PAf3Exd6B5GiSNpnZim4h1rhlBqx0=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas=
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.1/go.mod h1:V5CY8wNurvPUibTi9mwqUqpiFZ5LnioKWIFUDtIzdI8=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI=
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1 h1:ZpaV/j48RlPc4AmOZuPv22pJliXjXq8/reL63YzyFnw=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw=
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.1/go.mod h1:R8aXraabD2e3qv1csxM14/X9WF4wFMIY0kH4YEtYD5M=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.5.0 h1:DqOQvIfmGkXZUVJnl9VRk0AnxyS59tCtX9k1Pyss4Ak=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.5.0/go.mod h1:VV/Kbw9Mg1GWJOT9WK+oTL3cWZiXtapnNvDSRqTZLsg=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.5 h1:EeNQ3bDA6hlx3vifHf7LT/l9dh9w7D2XgCdaD11TRU4=
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0 h1:wAG9NailFhGhg8Ngg2YeCtzGmFWc63SYqJKdvN5ZMkE=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.5/go.mod h1:X3ThW5RPV19hi7bnQ0RMAiBjZbzxj4rZlj+qdctbMWY=
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.25.0/go.mod h1:ByrosnNlEq6xkA0d+FwB4f0HH/5KWCcgBqVxAt+Rsps=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.5 h1:xoalM/e1YsT6jkLKl6KA9HUiJANwn2ypJsM9lhW2WP0=
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.17.0 h1:iTGBKvqZNU9SsQCzRiK8f0u9kVtdG4K1Q68A97JRn6w=
|
||||||
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.5/go.mod h1:7QtKdGj66zM4g5hPgxHRQgFGLGal4EgwggTw5OZH56c=
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.17.0/go.mod h1:EabdnPA1OVcrolKX/hyMSNvJv8MBCZtlAlncsg/b/rA=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 h1:m0QTSI6pZYJTk5WSKx3fm5cNW/DCicVzULBgU/6IyD0=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0 h1:CJxo7ZBbaIzmXfV3hjcx36n9V87gJsIUPJflwqEHl3Q=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14/go.mod h1:dDilntgHy9WnHXsh7dDtUPgHKEfTJIBUTHM8OWm0f/0=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.0/go.mod h1:yjVfjuY4nD1EW9i387Kau+I6V5cBA5YnC/mWNopjZrI=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.35 h1:UKjpIDLVF90RfV88XurdduMoTxPqtGHZMIDYZQM7RO4=
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1 h1:aY45T0Xk+xHHrQPlQrp8IhrgN7k4SL5VF2UXhsmI2rs=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.35/go.mod h1:B3dUg0V6eJesUTi+m27NUkj7n8hdDKYUpxj8f4+TqaQ=
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.8.1/go.mod h1:5E/dXkj2ljMIAvuYaFuYwitKJg6ULwsDbUr3g8izVB0=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI=
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.1 h1:2OXw3ppu1XsB6rqKEMV4tnecTjIY3PRV2U6IP6KPJQo=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o=
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.1/go.mod h1:FZB4AdakIqW/yERVdGJA6Z9jraax1beXfhBBnK2wwR8=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0=
|
github.com/aws/aws-sdk-go-v2/service/sso v1.17.0 h1:I/Oh3IxGPfHXiGnwM54TD6hNr/8TlUrBXAtTyGhR+zw=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4=
|
github.com/aws/aws-sdk-go-v2/service/sso v1.17.0/go.mod h1:H6NCMvDBqA+CvIaXzaSqM6LWtzv9BzZrqBOqz+PzRF8=
|
||||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY=
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.0 h1:irbXQkfVYIRaewYSXcu4yVk0m2T+JzZd0dkop7FjmO0=
|
||||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4=
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.0/go.mod h1:4wPNCkM22+oRe71oydP66K50ojDUC33XutSMi2pEF/M=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ=
|
github.com/aws/aws-sdk-go-v2/service/sts v1.25.0 h1:sYIFy8tm1xQwRvVQ4CRuBGXKIg9sHNuG6+3UAQuoujk=
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU=
|
github.com/aws/aws-sdk-go-v2/service/sts v1.25.0/go.mod h1:S/LOQUeYDfJeJpFCIJDMjy7dwL4aA33HUdVi+i7uH8k=
|
||||||
github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ=
|
github.com/aws/smithy-go v1.16.0 h1:gJZEH/Fqh+RsvlJ1Zt4tVAtV6bKkp3cC+R6FCZMNzik=
|
||||||
github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
github.com/aws/smithy-go v1.16.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE=
|
||||||
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/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
github.com/jmespath/go-jmespath v0.4.0 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=
|
||||||
|
@@ -1,110 +1,132 @@
|
|||||||
package etcd
|
package etcd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetEtcd_ShouldReturnNoError(t *testing.T) {
|
var testStore *Storage
|
||||||
testStorage := New(Config{
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(Config{
|
||||||
Endpoints: []string{"localhost:2379"},
|
Endpoints: []string{"localhost:2379"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Reset()
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSetEtcd_ShouldReturnNoError(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
|
|
||||||
err := testStorage.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetEtcd_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) {
|
func TestGetEtcd_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) {
|
||||||
testStorage := New(Config{
|
val, err := testStore.Get("not_found_key")
|
||||||
Endpoints: []string{"localhost:2379"},
|
|
||||||
})
|
|
||||||
|
|
||||||
val, err := testStorage.Get("not_found_key")
|
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(val))
|
require.Zero(t, len(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) {
|
func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
err := testStore.Set("test", []byte("fiber_test_value"), 0)
|
||||||
Endpoints: []string{"localhost:2379"},
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 0)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
val, err := testStorage.Get("test")
|
val, err := testStore.Get("test")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, val, []byte("fiber_test_value"))
|
require.Equal(t, val, []byte("fiber_test_value"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) {
|
func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) {
|
||||||
testStorage := New(Config{
|
err := testStore.Set("test", []byte("fiber_test_value"), 3*time.Second)
|
||||||
Endpoints: []string{"localhost:2379"},
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 3*time.Second)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
time.Sleep(6 * time.Second)
|
time.Sleep(6 * time.Second)
|
||||||
|
|
||||||
val, err := testStorage.Get("test")
|
val, err := testStore.Get("test")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(val))
|
require.Zero(t, len(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) {
|
func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
err := testStore.Set("test", []byte("fiber_test_value"), 0)
|
||||||
Endpoints: []string{"localhost:2379"},
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 0)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStorage.Delete("test")
|
err = testStore.Delete("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = testStorage.Get("test")
|
_, err = testStore.Get("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) {
|
func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
err := testStore.Set("test", []byte("fiber_test_value"), 0)
|
||||||
Endpoints: []string{"localhost:2379"},
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Set("test", []byte("fiber_test_value"), 0)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStorage.Reset()
|
err = testStore.Reset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = testStorage.Get("test")
|
_, err = testStore.Get("test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClose_CloseShouldReturn_NoError(t *testing.T) {
|
func TestClose_CloseShouldReturn_NoError(t *testing.T) {
|
||||||
testStorage := New(Config{
|
err := testStore.Close()
|
||||||
Endpoints: []string{"localhost:2379"},
|
|
||||||
})
|
|
||||||
|
|
||||||
err := testStorage.Close()
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetConn_ReturnsNotNill(t *testing.T) {
|
func TestGetConn_ReturnsNotNill(t *testing.T) {
|
||||||
testStorage := New(Config{
|
require.True(t, testStore.Conn() != nil)
|
||||||
Endpoints: []string{"localhost:2379"},
|
}
|
||||||
})
|
|
||||||
|
func Benchmark_Etcd_Set(b *testing.B) {
|
||||||
require.True(t, testStorage.Conn() != nil)
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Etcd_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Etcd_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
|
14
etcd/go.mod
14
etcd/go.mod
@@ -4,7 +4,7 @@ go 1.19
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
go.etcd.io/etcd/client/v3 v3.5.9
|
go.etcd.io/etcd/client/v3 v3.5.10
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -14,17 +14,17 @@ require (
|
|||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.25.0 // indirect
|
go.uber.org/zap v1.25.0 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.11.0 // indirect
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
golang.org/x/text v0.12.0 // indirect
|
golang.org/x/text v0.13.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
|
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||||
google.golang.org/grpc v1.57.0 // indirect
|
google.golang.org/grpc v1.58.3 // indirect
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
28
etcd/go.sum
28
etcd/go.sum
@@ -21,12 +21,12 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
|||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.9 h1:4wSsluwyTbGGmyjJktOf3wFQoTBIURXHnq9n/G/JQHs=
|
go.etcd.io/etcd/api/v3 v3.5.10 h1:szRajuUUbLyppkhs9K6BRtjY37l66XQQmw7oZRANE4k=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.9/go.mod h1:uyAal843mC8uUVSLWz6eHa/d971iDGnCRpmKd2Z+X8k=
|
go.etcd.io/etcd/api/v3 v3.5.10/go.mod h1:TidfmT4Uycad3NM/o25fG3J07odo4GBB9hoxaodFCtI=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.9 h1:oidDC4+YEuSIQbsR94rY9gur91UPL6DnxDCIYd2IGsE=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.10 h1:kfYIdQftBnbAq8pUWFXfpuuxFSKzlmM5cSn76JByiT0=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.9/go.mod h1:y+CzeSmkMpWN2Jyu1npecjB9BBnABxGM4pN8cGuJeL4=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.10/go.mod h1:DYivfIviIuQ8+/lCq4vcxuseg2P2XbHygkKwFo9fc8U=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.9 h1:r5xghnU7CwbUxD/fbUtRyJGaYNfDun8sp/gTr1hew6E=
|
go.etcd.io/etcd/client/v3 v3.5.10 h1:W9TXNZ+oB3MCd/8UjxHTWK5J9Nquw9fQBLJd5ne5/Ao=
|
||||||
go.etcd.io/etcd/client/v3 v3.5.9/go.mod h1:i/Eo5LrZ5IKqpbtpPDuaUnDOUv471oDg8cjQaUr2MbA=
|
go.etcd.io/etcd/client/v3 v3.5.10/go.mod h1:RVeBnDz2PUEZqTpgqwAtUd8nAPf5kjyFyND7P1VkOKc=
|
||||||
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
|
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
@@ -41,20 +41,20 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
|
|||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/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-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
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-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
@@ -69,8 +69,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:
|
|||||||
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
|
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
|
||||||
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
|
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
|
||||||
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
|
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
|
@@ -1,13 +1,25 @@
|
|||||||
package memcache
|
package memcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New()
|
var testStore *Storage
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Memcache_Set(t *testing.T) {
|
func Test_Memcache_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
@@ -118,3 +130,42 @@ func Test_Memcache_Close(t *testing.T) {
|
|||||||
func Test_Memcache_Conn(t *testing.T) {
|
func Test_Memcache_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Memcache_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Memcache_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Memcache_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -31,6 +31,7 @@ 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
|
func (s *Storage) Conn() map[string]entry
|
||||||
|
func (s *Storage) Keys() ([][]byte, error)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -2,14 +2,10 @@ module github.com/gofiber/storage/memory/v2
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require github.com/stretchr/testify v1.8.4
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.3
|
|
||||||
github.com/stretchr/testify v1.8.4
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/google/uuid v1.3.1 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
@@ -1,9 +1,5 @@
|
|||||||
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/gofiber/utils/v2 v2.0.0-beta.3 h1:pfOhUDDVjBJpkWv6C5jaDyYLvpui7zQ97zpyFFsUOKw=
|
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.3/go.mod h1:jsl17+MsKfwJjM3ONCE9Rzji/j8XNbwjhUVTjzgfDCo=
|
|
||||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
|
||||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
|
@@ -141,3 +141,29 @@ func (s *Storage) Conn() map[string]entry {
|
|||||||
defer s.mux.RUnlock()
|
defer s.mux.RUnlock()
|
||||||
return s.db
|
return s.db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return all the keys
|
||||||
|
func (s *Storage) Keys() ([][]byte, error) {
|
||||||
|
s.mux.RLock()
|
||||||
|
defer s.mux.RUnlock()
|
||||||
|
|
||||||
|
if len(s.db) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ts := atomic.LoadUint32(&internal.Timestamp)
|
||||||
|
keys := make([][]byte, 0, len(s.db))
|
||||||
|
for key, v := range s.db {
|
||||||
|
// Filter out the expired keys
|
||||||
|
if v.expiry == 0 || v.expiry > ts {
|
||||||
|
keys = append(keys, []byte(key))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Double check if no valid keys were found
|
||||||
|
if len(keys) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys, nil
|
||||||
|
}
|
||||||
|
@@ -4,26 +4,29 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gofiber/utils/v2"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New()
|
|
||||||
|
|
||||||
func Test_Storage_Memory_Set(t *testing.T) {
|
func Test_Storage_Memory_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
testStore = New()
|
||||||
val = []byte("doe")
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Set_Override(t *testing.T) {
|
func Test_Storage_Memory_Set_Override(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
testStore = New()
|
||||||
val = []byte("doe")
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
@@ -31,12 +34,17 @@ func Test_Storage_Memory_Set_Override(t *testing.T) {
|
|||||||
|
|
||||||
err = testStore.Set(key, val, 0)
|
err = testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Get(t *testing.T) {
|
func Test_Storage_Memory_Get(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
testStore = New()
|
||||||
val = []byte("doe")
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
@@ -45,53 +53,104 @@ func Test_Storage_Memory_Get(t *testing.T) {
|
|||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, val, result)
|
require.Equal(t, val, result)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Set_Expiration(t *testing.T) {
|
func Test_Storage_Memory_Set_Expiration(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
testStore = New()
|
||||||
val = []byte("doe")
|
key = "john"
|
||||||
exp = 1 * time.Second
|
val = []byte("doe")
|
||||||
|
exp = 1 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, exp)
|
err := testStore.Set(key, val, exp)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
time.Sleep(1100 * time.Millisecond)
|
time.Sleep(1100 * time.Millisecond)
|
||||||
}
|
|
||||||
|
|
||||||
func Test_Storage_Memory_Get_Expired(t *testing.T) {
|
|
||||||
key := "john"
|
|
||||||
|
|
||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Storage_Memory_Set_Long_Expiration_with_Keys(t *testing.T) {
|
||||||
|
var (
|
||||||
|
testStore = New()
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
exp = 5 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
|
err = testStore.Set(key, val, exp)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
time.Sleep(1100 * time.Millisecond)
|
||||||
|
|
||||||
|
keys, err = testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
|
|
||||||
|
time.Sleep(4000 * time.Millisecond)
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err = testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Get_NotExist(t *testing.T) {
|
func Test_Storage_Memory_Get_NotExist(t *testing.T) {
|
||||||
|
testStore := New()
|
||||||
result, err := testStore.Get("notexist")
|
result, err := testStore.Get("notexist")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Delete(t *testing.T) {
|
func Test_Storage_Memory_Delete(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
testStore = New()
|
||||||
val = []byte("doe")
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
|
|
||||||
err = testStore.Delete(key)
|
err = testStore.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err = testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Reset(t *testing.T) {
|
func Test_Storage_Memory_Reset(t *testing.T) {
|
||||||
|
testStore := New()
|
||||||
val := []byte("doe")
|
val := []byte("doe")
|
||||||
|
|
||||||
err := testStore.Set("john1", val, 0)
|
err := testStore.Set("john1", val, 0)
|
||||||
@@ -100,6 +159,10 @@ func Test_Storage_Memory_Reset(t *testing.T) {
|
|||||||
err = testStore.Set("john2", val, 0)
|
err = testStore.Set("john2", val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 2)
|
||||||
|
|
||||||
err = testStore.Reset()
|
err = testStore.Reset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -110,40 +173,60 @@ func Test_Storage_Memory_Reset(t *testing.T) {
|
|||||||
result, err = testStore.Get("john2")
|
result, err = testStore.Get("john2")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err = testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Close(t *testing.T) {
|
func Test_Storage_Memory_Close(t *testing.T) {
|
||||||
|
testStore := New()
|
||||||
require.Nil(t, testStore.Close())
|
require.Nil(t, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Storage_Memory_Conn(t *testing.T) {
|
func Test_Storage_Memory_Conn(t *testing.T) {
|
||||||
|
testStore := New()
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// go test -v -run=^$ -bench=Benchmark_Storage_Memory -benchmem -count=4
|
func Benchmark_Memory_Set(b *testing.B) {
|
||||||
func Benchmark_Storage_Memory(b *testing.B) {
|
testStore := New()
|
||||||
keyLength := 1000
|
b.ReportAllocs()
|
||||||
keys := make([]string, keyLength)
|
b.ResetTimer()
|
||||||
for i := 0; i < keyLength; i++ {
|
|
||||||
keys[i] = utils.UUID()
|
|
||||||
}
|
|
||||||
value := []byte("joe")
|
|
||||||
|
|
||||||
ttl := 2 * time.Second
|
var err error
|
||||||
b.Run("fiber_memory", func(b *testing.B) {
|
for i := 0; i < b.N; i++ {
|
||||||
d := New()
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
b.ReportAllocs()
|
}
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
require.NoError(b, err)
|
||||||
for _, key := range keys {
|
}
|
||||||
d.Set(key, value, ttl)
|
|
||||||
}
|
func Benchmark_Memory_Get(b *testing.B) {
|
||||||
for _, key := range keys {
|
testStore := New()
|
||||||
_, _ = d.Get(key)
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
}
|
require.NoError(b, err)
|
||||||
for _, key := range keys {
|
|
||||||
d.Delete(key)
|
b.ReportAllocs()
|
||||||
}
|
b.ResetTimer()
|
||||||
}
|
|
||||||
})
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Memory_SetAndDelete(b *testing.B) {
|
||||||
|
testStore := New()
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
|
137
minio/README.md
Normal file
137
minio/README.md
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
---
|
||||||
|
id: minio
|
||||||
|
title: Minio
|
||||||
|
---
|
||||||
|
|
||||||
|

|
||||||
|
[](https://gofiber.io/discord)
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
## Minio
|
||||||
|
|
||||||
|
A Minio storage driver using [minio/minio-go](https://github.com/minio/minio-go).
|
||||||
|
|
||||||
|
**Note: Requires Go 1.19 and above**
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
- [Signatures](#signatures)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Config](#config)
|
||||||
|
- [Default Config](#default-config)
|
||||||
|
|
||||||
|
### Signatures
|
||||||
|
```go
|
||||||
|
func New(config ...Config) Storage
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error)
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||||
|
func (s *Storage) Delete(key string) error
|
||||||
|
func (s *Storage) Reset() error
|
||||||
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) CheckBucket() error
|
||||||
|
func (s *Storage) CreateBucket() error
|
||||||
|
func (s *Storage) RemoveBucket() error
|
||||||
|
func (s *Storage) Conn() *minio.Client
|
||||||
|
```
|
||||||
|
### Installation
|
||||||
|
Install the Minio implementation:
|
||||||
|
```bash
|
||||||
|
go get github.com/gofiber/storage/minio
|
||||||
|
```
|
||||||
|
And then run minio on Docker
|
||||||
|
```bash
|
||||||
|
docker run -d --restart always -p 9000:9000 -p 9001:9001 --name storage-minio --volume=minio:/var/lib/minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server --console-address ":9001" /var/lib/minio
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
Import the storage package.
|
||||||
|
```go
|
||||||
|
import "github.com/gofiber/storage/minio"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use the following possibilities to create a storage:
|
||||||
|
```go
|
||||||
|
// Initialize default config
|
||||||
|
store := minio.New()
|
||||||
|
|
||||||
|
// Initialize custom config
|
||||||
|
store := minio.New(minio.Config{
|
||||||
|
Bucket: "fiber-bucket",
|
||||||
|
Endpoint: "localhost:9000",
|
||||||
|
Credentials: Credentials{
|
||||||
|
AccessKeyID: "minio-user",
|
||||||
|
SecretAccessKey: "minio-password",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Config
|
||||||
|
```go
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Bucket
|
||||||
|
// Default fiber-bucket
|
||||||
|
Bucket string
|
||||||
|
|
||||||
|
// Endpoint is a host name or an IP address
|
||||||
|
Endpoint string
|
||||||
|
|
||||||
|
// Region Set this value to override region cache
|
||||||
|
// Optional
|
||||||
|
Region string
|
||||||
|
|
||||||
|
// Token Set this value to provide x-amz-security-token (AWS S3 specific)
|
||||||
|
// Optional, Default is false
|
||||||
|
Token string
|
||||||
|
|
||||||
|
// Secure If set to true, https is used instead of http.
|
||||||
|
// Default is false
|
||||||
|
Secure bool
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Bucket
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
|
||||||
|
// Credentials Minio access key and Minio secret key.
|
||||||
|
// Need to be defined
|
||||||
|
Credentials Credentials
|
||||||
|
|
||||||
|
// GetObjectOptions Options for GET requests specifying additional options like encryption, If-Match
|
||||||
|
GetObjectOptions minio.GetObjectOptions
|
||||||
|
|
||||||
|
// PutObjectOptions
|
||||||
|
// Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation.
|
||||||
|
PutObjectOptions minio.PutObjectOptions
|
||||||
|
|
||||||
|
// ListObjectsOptions Options per to list objects
|
||||||
|
ListObjectsOptions minio.ListObjectsOptions
|
||||||
|
|
||||||
|
// RemoveObjectOptions Allows user to set options
|
||||||
|
RemoveObjectOptions minio.RemoveObjectOptions
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default Config
|
||||||
|
The default configuration lacks Bucket, Region, and Endpoint which are all required and must be overwritten:
|
||||||
|
```go
|
||||||
|
// ConfigDefault is the default config
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
Bucket: "fiber-bucket",
|
||||||
|
Endpoint: "",
|
||||||
|
Region: "",
|
||||||
|
Token: "",
|
||||||
|
Secure: false,
|
||||||
|
Reset: false,
|
||||||
|
Credentials: Credentials{},
|
||||||
|
GetObjectOptions: minio.GetObjectOptions{},
|
||||||
|
PutObjectOptions: minio.PutObjectOptions{},
|
||||||
|
ListObjectsOptions: minio.ListObjectsOptions{},
|
||||||
|
RemoveObjectOptions: minio.RemoveObjectOptions{},
|
||||||
|
}
|
||||||
|
type Credentials struct {
|
||||||
|
AccessKeyID string
|
||||||
|
SecretAccessKey string
|
||||||
|
}
|
||||||
|
```
|
88
minio/config.go
Normal file
88
minio/config.go
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package minio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Bucket
|
||||||
|
// Default fiber-bucket
|
||||||
|
Bucket string
|
||||||
|
|
||||||
|
// Endpoint is a host name or an IP address
|
||||||
|
Endpoint string
|
||||||
|
|
||||||
|
// Region Set this value to override region cache
|
||||||
|
// Optional
|
||||||
|
Region string
|
||||||
|
|
||||||
|
// Token Set this value to provide x-amz-security-token (AWS S3 specific)
|
||||||
|
// Optional, Default is false
|
||||||
|
Token string
|
||||||
|
|
||||||
|
// Secure If set to true, https is used instead of http.
|
||||||
|
// Default is false
|
||||||
|
Secure bool
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Bucket
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
|
||||||
|
// Credentials Minio access key and Minio secret key.
|
||||||
|
// Need to be defined
|
||||||
|
Credentials Credentials
|
||||||
|
|
||||||
|
// GetObjectOptions Options for GET requests specifying additional options like encryption, If-Match
|
||||||
|
GetObjectOptions minio.GetObjectOptions
|
||||||
|
|
||||||
|
// PutObjectOptions
|
||||||
|
// Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation.
|
||||||
|
PutObjectOptions minio.PutObjectOptions
|
||||||
|
|
||||||
|
// ListObjectsOptions Options per to list objects
|
||||||
|
ListObjectsOptions minio.ListObjectsOptions
|
||||||
|
|
||||||
|
// RemoveObjectOptions Allows user to set options
|
||||||
|
RemoveObjectOptions minio.RemoveObjectOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
type Credentials struct {
|
||||||
|
// AccessKeyID is like user-id that uniquely identifies your account.
|
||||||
|
AccessKeyID string
|
||||||
|
// SecretAccessKey is the password to your account.
|
||||||
|
SecretAccessKey string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigDefault is the default config
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
Bucket: "fiber-bucket",
|
||||||
|
Endpoint: "",
|
||||||
|
Region: "",
|
||||||
|
Token: "",
|
||||||
|
Secure: false,
|
||||||
|
Reset: false,
|
||||||
|
Credentials: Credentials{},
|
||||||
|
GetObjectOptions: minio.GetObjectOptions{},
|
||||||
|
PutObjectOptions: minio.PutObjectOptions{},
|
||||||
|
ListObjectsOptions: minio.ListObjectsOptions{},
|
||||||
|
RemoveObjectOptions: minio.RemoveObjectOptions{},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to set default values
|
||||||
|
func configDefault(config ...Config) Config {
|
||||||
|
// Return default config if nothing provided
|
||||||
|
if len(config) < 1 {
|
||||||
|
return ConfigDefault
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override default config
|
||||||
|
cfg := config[0]
|
||||||
|
|
||||||
|
// Set default values
|
||||||
|
if cfg.Bucket == "" {
|
||||||
|
cfg.Bucket = ConfigDefault.Bucket
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg
|
||||||
|
}
|
31
minio/go.mod
Normal file
31
minio/go.mod
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
module github.com/gofiber/storage/minio
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/minio/minio-go/v7 v7.0.63
|
||||||
|
github.com/stretchr/testify v1.8.4
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/google/uuid v1.3.1 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/compress v1.16.7 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||||
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
|
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/rs/xid v1.5.0 // indirect
|
||||||
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
|
golang.org/x/crypto v0.14.0 // indirect
|
||||||
|
golang.org/x/net v0.17.0 // indirect
|
||||||
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
|
golang.org/x/text v0.13.0 // indirect
|
||||||
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
56
minio/go.sum
Normal file
56
minio/go.sum
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||||
|
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
|
||||||
|
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
|
github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurwcbQ=
|
||||||
|
github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4=
|
||||||
|
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
||||||
|
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
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/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||||
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
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/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||||
|
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
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=
|
171
minio/minio.go
Normal file
171
minio/minio.go
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
package minio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
|
"github.com/valyala/bytebufferpool"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Storage interface that is implemented by storage providers
|
||||||
|
type Storage struct {
|
||||||
|
minio *minio.Client
|
||||||
|
cfg Config
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new storage
|
||||||
|
func New(config ...Config) *Storage {
|
||||||
|
|
||||||
|
// Set default config
|
||||||
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
|
// Minio instance
|
||||||
|
minioClient, err := minio.New(cfg.Endpoint, &minio.Options{
|
||||||
|
Creds: credentials.NewStaticV4(cfg.Credentials.AccessKeyID, cfg.Credentials.SecretAccessKey, cfg.Token),
|
||||||
|
Secure: cfg.Secure,
|
||||||
|
Region: cfg.Region,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
storage := &Storage{minio: minioClient, cfg: cfg, ctx: context.Background()}
|
||||||
|
|
||||||
|
// Reset all entries if set to true
|
||||||
|
if cfg.Reset {
|
||||||
|
if err = storage.Reset(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check bucket
|
||||||
|
err = storage.CheckBucket()
|
||||||
|
if err != nil {
|
||||||
|
// create bucket
|
||||||
|
err = storage.CreateBucket()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get value by key
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
|
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil, errors.New("the key value is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// get object
|
||||||
|
object, err := s.minio.GetObject(s.ctx, s.cfg.Bucket, key, s.cfg.GetObjectOptions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert to byte
|
||||||
|
bb := bytebufferpool.Get()
|
||||||
|
defer bytebufferpool.Put(bb)
|
||||||
|
_, err = bb.ReadFrom(object)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bb.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set key with value
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
|
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return errors.New("the key value is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// create Reader
|
||||||
|
file := bytes.NewReader(val)
|
||||||
|
|
||||||
|
// set content type
|
||||||
|
s.cfg.PutObjectOptions.ContentType = http.DetectContentType(val)
|
||||||
|
|
||||||
|
// put object
|
||||||
|
_, err := s.minio.PutObject(s.ctx, s.cfg.Bucket, key, file, file.Size(), s.cfg.PutObjectOptions)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete entry by key
|
||||||
|
func (s *Storage) Delete(key string) error {
|
||||||
|
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return errors.New("the key value is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove
|
||||||
|
err := s.minio.RemoveObject(s.ctx, s.cfg.Bucket, key, s.cfg.RemoveObjectOptions)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset all entries, including unexpired
|
||||||
|
func (s *Storage) Reset() error {
|
||||||
|
|
||||||
|
objectsCh := make(chan minio.ObjectInfo)
|
||||||
|
|
||||||
|
// Send object names that are needed to be removed to objectsCh
|
||||||
|
go func() {
|
||||||
|
defer close(objectsCh)
|
||||||
|
// List all objects from a bucket-name with a matching prefix.
|
||||||
|
for object := range s.minio.ListObjects(s.ctx, s.cfg.Bucket, s.cfg.ListObjectsOptions) {
|
||||||
|
if object.Err != nil {
|
||||||
|
log.Println(object.Err)
|
||||||
|
}
|
||||||
|
objectsCh <- object
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
opts := minio.RemoveObjectsOptions{
|
||||||
|
GovernanceBypass: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
for err := range s.minio.RemoveObjects(s.ctx, s.cfg.Bucket, objectsCh, opts) {
|
||||||
|
log.Println("Error detected during deletion: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the storage
|
||||||
|
func (s *Storage) Close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckBucket Check to see if bucket already exists
|
||||||
|
func (s *Storage) CheckBucket() error {
|
||||||
|
exists, err := s.minio.BucketExists(s.ctx, s.cfg.Bucket)
|
||||||
|
if !exists || err != nil {
|
||||||
|
return errors.New("the specified bucket does not exist")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBucket Bucket not found so Make a new bucket
|
||||||
|
func (s *Storage) CreateBucket() error {
|
||||||
|
return s.minio.MakeBucket(s.ctx, s.cfg.Bucket, minio.MakeBucketOptions{Region: s.cfg.Region})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveBucket Bucket remove if bucket is empty
|
||||||
|
func (s *Storage) RemoveBucket() error {
|
||||||
|
return s.minio.RemoveBucket(s.ctx, s.cfg.Bucket)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conn Return minio client
|
||||||
|
func (s *Storage) Conn() *minio.Client {
|
||||||
|
return s.minio
|
||||||
|
}
|
234
minio/minio_test.go
Normal file
234
minio/minio_test.go
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
package minio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
var testStore *Storage
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(
|
||||||
|
Config{
|
||||||
|
Bucket: "fiber-bucket",
|
||||||
|
Endpoint: "localhost:9000",
|
||||||
|
Credentials: Credentials{
|
||||||
|
AccessKeyID: "minio-user",
|
||||||
|
SecretAccessKey: "minio-password",
|
||||||
|
},
|
||||||
|
Reset: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Get(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, val, result)
|
||||||
|
|
||||||
|
result, err = testStore.Get("doe")
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Zero(t, len(result))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Get_Empty_Key(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
_, err := testStore.Get(key)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, "the key value is required")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Get_Not_Exists_Key(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "not-exists"
|
||||||
|
)
|
||||||
|
|
||||||
|
_, err := testStore.Get(key)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, "The specified key does not exist.")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Get_Not_Exists_Bucket(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
)
|
||||||
|
|
||||||
|
// random bucket name
|
||||||
|
testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Zero(t, len(result))
|
||||||
|
require.EqualError(t, err, "The specified bucket does not exist")
|
||||||
|
|
||||||
|
testStore.cfg.Bucket = "fiber-bucket"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Set(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Set_Empty_Key(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = ""
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, "the key value is required")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Set_Not_Exists_Bucket(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
// random bucket name
|
||||||
|
testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, "The specified bucket does not exist")
|
||||||
|
|
||||||
|
testStore.cfg.Bucket = "fiber-bucket"
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Delete(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = testStore.Delete(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Delete_Empty_Key(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = ""
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, "the key value is required")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Delete_Not_Exists_Bucket(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
)
|
||||||
|
|
||||||
|
// random bucket name
|
||||||
|
testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10)
|
||||||
|
|
||||||
|
err := testStore.Delete(key)
|
||||||
|
|
||||||
|
require.Error(t, err)
|
||||||
|
require.EqualError(t, err, "The specified bucket does not exist")
|
||||||
|
|
||||||
|
testStore.cfg.Bucket = "fiber-bucket"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Reset(t *testing.T) {
|
||||||
|
var (
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set("john1", val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = testStore.Set("john2", val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = testStore.Reset()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get("john1")
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Close(t *testing.T) {
|
||||||
|
require.NoError(t, testStore.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Minio_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Minio_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Minio_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
@@ -1,15 +1,25 @@
|
|||||||
package mongodb
|
package mongodb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New(Config{
|
var testStore *Storage
|
||||||
Reset: true,
|
|
||||||
})
|
func TestMain(m *testing.M) {
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
_ = testStore.Close()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_MongoDB_Set(t *testing.T) {
|
func Test_MongoDB_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
@@ -120,3 +130,42 @@ func Test_MongoDB_Close(t *testing.T) {
|
|||||||
func Test_MongoDB_Conn(t *testing.T) {
|
func Test_MongoDB_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_MongoDB_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_MongoDB_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_MongoDB_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -3,7 +3,7 @@ module github.com/gofiber/storage/mssql/v2
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/microsoft/go-mssqldb v1.5.0
|
github.com/microsoft/go-mssqldb v1.6.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,5 +13,6 @@ require (
|
|||||||
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
golang.org/x/crypto v0.12.0 // indirect
|
golang.org/x/crypto v0.12.0 // indirect
|
||||||
|
golang.org/x/text v0.12.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
99
mssql/go.sum
99
mssql/go.sum
@@ -1,99 +1,32 @@
|
|||||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U=
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg=
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
|
||||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o=
|
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 h1:yfJe15aSwEQ6Oo6J+gdfdulPNoZ3TEhmbhLIoxZcA+U=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 h1:T028gtTPiYt/RMUfs8nVsAL7FDQrfLlrm/NnRG/zcC4=
|
||||||
|
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 h1:HCc0+LpPfpCKs6LGGLAhwBARt9632unrVcI6i8s/8os=
|
||||||
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/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
|
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
|
||||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
|
||||||
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
|
||||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
|
||||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
|
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
|
||||||
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
|
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
github.com/microsoft/go-mssqldb v1.6.0 h1:mM3gYdVwEPFrlg/Dvr2DNVEgYFG7L42l+dGc67NNNpc=
|
||||||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU=
|
||||||
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
|
||||||
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
|
|
||||||
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
|
|
||||||
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
|
|
||||||
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
|
|
||||||
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
|
||||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
|
||||||
github.com/microsoft/go-mssqldb v1.5.0 h1:CgENxkwtOBNj3Jg6T1X209y2blCfTTcwuOlznd2k9fk=
|
|
||||||
github.com/microsoft/go-mssqldb v1.5.0/go.mod h1:lmWsjHD8XX/Txr0f8ZqgbEZSC+BZjmEQy/Ms+rLrvho=
|
|
||||||
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
|
|
||||||
github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
|
||||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
|
||||||
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.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
|
||||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
|
||||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
|
||||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
|
||||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
|
||||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.1.0/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-20201119102817-f84b799fce68/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-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
|
||||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
|
||||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
||||||
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 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@@ -173,3 +173,42 @@ func Test_MSSQL_Close(t *testing.T) {
|
|||||||
func Test_MSSQL_Conn(t *testing.T) {
|
func Test_MSSQL_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_MSSQL_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_MSSQL_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_MSSQL_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -26,7 +26,7 @@ func Test_MYSQL_New(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
require.True(t, newConfigStore.db != nil)
|
require.True(t, newConfigStore.db != nil)
|
||||||
newConfigStore.Close()
|
require.NoError(t, 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"))
|
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{
|
newConfigStore = New(Config{
|
||||||
@@ -189,3 +189,42 @@ func Test_MYSQL_Close(t *testing.T) {
|
|||||||
func Test_MYSQL_Conn(t *testing.T) {
|
func Test_MYSQL_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_MYSQL_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_MYSQL_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_MYSQL_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -8,8 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New(Config{
|
var testStore = New(Config{
|
||||||
"test.db",
|
Path: "test.db",
|
||||||
nil,
|
WriteOptions: nil,
|
||||||
})
|
})
|
||||||
|
|
||||||
func Test_Pebble_Set(t *testing.T) {
|
func Test_Pebble_Set(t *testing.T) {
|
||||||
@@ -105,3 +105,42 @@ func Test_Pebble_Close(t *testing.T) {
|
|||||||
func Test_Pebble_Conn(t *testing.T) {
|
func Test_Pebble_Conn(t *testing.T) {
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Pebble_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Pebble_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Pebble_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -3,7 +3,7 @@ module github.com/gofiber/storage/postgres/v3
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/jackc/pgx/v5 v5.4.3
|
github.com/jackc/pgx/v5 v5.5.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -6,8 +6,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
|
|||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
|
github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw=
|
||||||
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
|
github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
|
||||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
|
@@ -170,3 +170,42 @@ func Test_Postgres_Conn(t *testing.T) {
|
|||||||
func Test_Postgres_Close(t *testing.T) {
|
func Test_Postgres_Close(t *testing.T) {
|
||||||
require.Nil(t, testStore.Close())
|
require.Nil(t, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Postgres_Set(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Postgres_Get(b *testing.B) {
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Postgres_SetAndDelete(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -29,6 +29,7 @@ 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.UniversalClient
|
func (s *Storage) Conn() redis.UniversalClient
|
||||||
|
func (s *Storage) Keys() ([][]byte, error)
|
||||||
```
|
```
|
||||||
### 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:
|
||||||
@@ -86,15 +87,15 @@ tlsCfg := &tls.Config{
|
|||||||
Certificates: []tls.Certificate{cer},
|
Certificates: []tls.Certificate{cer},
|
||||||
}
|
}
|
||||||
store = redis.New(redis.Config{
|
store = redis.New(redis.Config{
|
||||||
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
|
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
|
||||||
TLSConfig: tlsCfg,
|
TLSConfig: tlsCfg,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Create a client with a Redis URL with all information.
|
// Create a client with a Redis URL with all information.
|
||||||
store = redis.New(redis.Config{
|
store = redis.New(redis.Config{
|
||||||
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
|
URL: "redis://<user>:<pass>@127.0.0.1:6379/<db>",
|
||||||
Reset: false,
|
Reset: false,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@ module github.com/gofiber/storage/redis/v3
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/redis/go-redis/v9 v9.1.0
|
github.com/redis/go-redis/v9 v9.3.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
github.com/bsm/ginkgo/v2 v2.9.5 h1:rtVBYPs3+TC5iLUVOis1B9tjLTup7Cj5IfzosKtvTJ0=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
@@ -8,8 +8,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
|
|||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
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/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY=
|
github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0=
|
||||||
github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH1cY3lZl4c=
|
github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
@@ -33,6 +33,11 @@ func New(config ...Config) *Storage {
|
|||||||
cfg.Password = options.Password
|
cfg.Password = options.Password
|
||||||
cfg.Database = options.DB
|
cfg.Database = options.DB
|
||||||
cfg.Addrs = []string{options.Addr}
|
cfg.Addrs = []string{options.Addr}
|
||||||
|
|
||||||
|
// If cfg.TLSConfig is not provided, and options returns one, use it.
|
||||||
|
if cfg.TLSConfig == nil && options.TLSConfig != nil {
|
||||||
|
cfg.TLSConfig = options.TLSConfig
|
||||||
|
}
|
||||||
} else if len(cfg.Addrs) == 0 {
|
} else if len(cfg.Addrs) == 0 {
|
||||||
// Fallback to Host and Port values if Addrs is empty
|
// Fallback to Host and Port values if Addrs is empty
|
||||||
cfg.Addrs = []string{fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)}
|
cfg.Addrs = []string{fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)}
|
||||||
@@ -69,8 +74,6 @@ func New(config ...Config) *Storage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (s *Storage) Get(key string) ([]byte, error) {
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
if len(key) <= 0 {
|
if len(key) <= 0 {
|
||||||
@@ -113,3 +116,32 @@ func (s *Storage) Close() error {
|
|||||||
func (s *Storage) Conn() redis.UniversalClient {
|
func (s *Storage) Conn() redis.UniversalClient {
|
||||||
return s.db
|
return s.db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return all the keys
|
||||||
|
func (s *Storage) Keys() ([][]byte, error) {
|
||||||
|
var keys [][]byte
|
||||||
|
var cursor uint64
|
||||||
|
var err error
|
||||||
|
|
||||||
|
for {
|
||||||
|
var batch []string
|
||||||
|
|
||||||
|
if batch, cursor, err = s.db.Scan(context.Background(), cursor, "*", 10).Result(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, key := range batch {
|
||||||
|
keys = append(keys, []byte(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
if cursor == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(keys) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys, nil
|
||||||
|
}
|
||||||
|
@@ -9,12 +9,11 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New(Config{
|
|
||||||
Reset: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
func Test_Redis_Set(t *testing.T) {
|
func Test_Redis_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
@@ -25,6 +24,9 @@ func Test_Redis_Set(t *testing.T) {
|
|||||||
|
|
||||||
func Test_Redis_Set_Override(t *testing.T) {
|
func Test_Redis_Set_Override(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
@@ -34,10 +36,17 @@ func Test_Redis_Set_Override(t *testing.T) {
|
|||||||
|
|
||||||
err = testStore.Set(key, val, 0)
|
err = testStore.Set(key, val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Get(t *testing.T) {
|
func Test_Redis_Get(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
@@ -48,10 +57,17 @@ func Test_Redis_Get(t *testing.T) {
|
|||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, val, result)
|
require.Equal(t, val, result)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Set_Expiration(t *testing.T) {
|
func Test_Redis_Expiration(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
exp = 1 * time.Second
|
exp = 1 * time.Second
|
||||||
@@ -61,17 +77,20 @@ func Test_Redis_Set_Expiration(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
time.Sleep(1100 * time.Millisecond)
|
time.Sleep(1100 * time.Millisecond)
|
||||||
}
|
|
||||||
|
|
||||||
func Test_Redis_Get_Expired(t *testing.T) {
|
|
||||||
key := "john"
|
|
||||||
|
|
||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Get_NotExist(t *testing.T) {
|
func Test_Redis_Get_NotExist(t *testing.T) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
result, err := testStore.Get("notexist")
|
result, err := testStore.Get("notexist")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
@@ -79,6 +98,9 @@ func Test_Redis_Get_NotExist(t *testing.T) {
|
|||||||
|
|
||||||
func Test_Redis_Delete(t *testing.T) {
|
func Test_Redis_Delete(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
|
testStore = New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
@@ -92,9 +114,16 @@ func Test_Redis_Delete(t *testing.T) {
|
|||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Reset(t *testing.T) {
|
func Test_Redis_Reset(t *testing.T) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
val := []byte("doe")
|
val := []byte("doe")
|
||||||
|
|
||||||
err := testStore.Set("john1", val, 0)
|
err := testStore.Set("john1", val, 0)
|
||||||
@@ -103,6 +132,10 @@ func Test_Redis_Reset(t *testing.T) {
|
|||||||
err = testStore.Set("john2", val, 0)
|
err = testStore.Set("john2", val, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, keys, 2)
|
||||||
|
|
||||||
err = testStore.Reset()
|
err = testStore.Reset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -113,13 +146,23 @@ func Test_Redis_Reset(t *testing.T) {
|
|||||||
result, err = testStore.Get("john2")
|
result, err = testStore.Get("john2")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Zero(t, len(result))
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
|
keys, err = testStore.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Close(t *testing.T) {
|
func Test_Redis_Close(t *testing.T) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
require.Nil(t, testStore.Close())
|
require.Nil(t, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Conn(t *testing.T) {
|
func Test_Redis_Conn(t *testing.T) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
require.True(t, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,17 +189,16 @@ func Test_Redis_Initalize_WithURL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_Redis_Initalize_WithURL_TLS(t *testing.T) {
|
func Test_Redis_Initalize_WithURL_TLS(t *testing.T) {
|
||||||
cer, err := tls.LoadX509KeyPair("./tests/tls/client.crt", "./tests/tls/client.key")
|
cer, err := tls.LoadX509KeyPair("/home/runner/work/storage/storage/tls/client.crt", "/home/runner/work/storage/storage/tls/client.key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tlsCfg := &tls.Config{
|
tlsCfg := &tls.Config{
|
||||||
MinVersion: tls.VersionTLS12,
|
MinVersion: tls.VersionTLS12,
|
||||||
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
|
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
|
||||||
PreferServerCipherSuites: true,
|
InsecureSkipVerify: true,
|
||||||
InsecureSkipVerify: true,
|
Certificates: []tls.Certificate{cer},
|
||||||
Certificates: []tls.Certificate{cer},
|
|
||||||
CipherSuites: []uint16{
|
CipherSuites: []uint16{
|
||||||
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||||
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
||||||
@@ -185,6 +227,83 @@ func Test_Redis_Initalize_WithURL_TLS(t *testing.T) {
|
|||||||
err = testStoreUrl.Delete(key)
|
err = testStoreUrl.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUrl.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
|
require.Nil(t, testStoreUrl.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Redis_Initalize_WithURL_TLS_Verify(t *testing.T) {
|
||||||
|
cer, err := tls.LoadX509KeyPair("/home/runner/work/storage/storage/tls/client.crt", "/home/runner/work/storage/storage/tls/client.key")
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tlsCfg := &tls.Config{
|
||||||
|
MinVersion: tls.VersionTLS12,
|
||||||
|
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
|
||||||
|
InsecureSkipVerify: false,
|
||||||
|
Certificates: []tls.Certificate{cer},
|
||||||
|
CipherSuites: []uint16{
|
||||||
|
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||||
|
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
||||||
|
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
|
||||||
|
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
testStoreUrl := New(Config{
|
||||||
|
URL: "redis://localhost:6380",
|
||||||
|
TLSConfig: tlsCfg,
|
||||||
|
})
|
||||||
|
|
||||||
|
var (
|
||||||
|
key = "clark"
|
||||||
|
val = []byte("kent")
|
||||||
|
)
|
||||||
|
|
||||||
|
err = testStoreUrl.Set(key, val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
result, err := testStoreUrl.Get(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, val, result)
|
||||||
|
|
||||||
|
err = testStoreUrl.Delete(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUrl.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
|
require.Nil(t, testStoreUrl.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Redis_Initalize_With_Secure_URL(t *testing.T) {
|
||||||
|
testStoreUrl := New(Config{
|
||||||
|
URL: "rediss://localhost:16380",
|
||||||
|
})
|
||||||
|
|
||||||
|
var (
|
||||||
|
key = "clark"
|
||||||
|
val = []byte("kent")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStoreUrl.Set(key, val, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
result, err := testStoreUrl.Get(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, val, result)
|
||||||
|
|
||||||
|
err = testStoreUrl.Delete(key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUrl.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUrl.Close())
|
require.Nil(t, testStoreUrl.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +328,10 @@ func Test_Redis_Universal_Addrs(t *testing.T) {
|
|||||||
err = testStoreUniversal.Delete(key)
|
err = testStoreUniversal.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUniversal.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUniversal.Close())
|
require.Nil(t, testStoreUniversal.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +358,10 @@ func Test_Redis_Universal_With_URL_Undefined(t *testing.T) {
|
|||||||
err = testStoreUniversal.Delete(key)
|
err = testStoreUniversal.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUniversal.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUniversal.Close())
|
require.Nil(t, testStoreUniversal.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,6 +388,10 @@ func Test_Redis_Universal_With_URL_Defined(t *testing.T) {
|
|||||||
err = testStoreUniversal.Delete(key)
|
err = testStoreUniversal.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUniversal.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUniversal.Close())
|
require.Nil(t, testStoreUniversal.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,6 +419,10 @@ func Test_Redis_Universal_With_HostPort(t *testing.T) {
|
|||||||
err = testStoreUniversal.Delete(key)
|
err = testStoreUniversal.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUniversal.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUniversal.Close())
|
require.Nil(t, testStoreUniversal.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +451,10 @@ func Test_Redis_Universal_With_HostPort_And_URL(t *testing.T) {
|
|||||||
err = testStoreUniversal.Delete(key)
|
err = testStoreUniversal.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUniversal.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUniversal.Close())
|
require.Nil(t, testStoreUniversal.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,5 +485,57 @@ func Test_Redis_Cluster(t *testing.T) {
|
|||||||
err = testStoreUniversal.Delete(key)
|
err = testStoreUniversal.Delete(key)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
keys, err := testStoreUniversal.Keys()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Nil(t, keys)
|
||||||
|
|
||||||
require.Nil(t, testStoreUniversal.Close())
|
require.Nil(t, testStoreUniversal.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Benchmark_Redis_Set(b *testing.B) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
err = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Redis_Get(b *testing.B) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
err := testStore.Set("john", []byte("doe"), 0)
|
||||||
|
require.NoError(b, err)
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err = testStore.Get("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_Redis_SetAndDelete(b *testing.B) {
|
||||||
|
testStore := New(Config{
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_ = testStore.Set("john", []byte("doe"), 0)
|
||||||
|
err = testStore.Delete("john")
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(b, err)
|
||||||
|
}
|
||||||
|
@@ -1,57 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Generate some test certificates which are used by the regression test suite:
|
|
||||||
#
|
|
||||||
# ./tls/ca.{crt,key} Self signed CA certificate.
|
|
||||||
# ./tls/redis.{crt,key} A certificate with no key usage/policy restrictions.
|
|
||||||
# ./tls/client.{crt,key} A certificate restricted for SSL client usage.
|
|
||||||
# ./tls/server.{crt,key} A certificate restricted for SSL server usage.
|
|
||||||
# ./tls/redis.dh DH Params file.
|
|
||||||
|
|
||||||
generate_cert() {
|
|
||||||
local name=$1
|
|
||||||
local cn="$2"
|
|
||||||
local opts="$3"
|
|
||||||
|
|
||||||
local keyfile=./tls/${name}.key
|
|
||||||
local certfile=./tls/${name}.crt
|
|
||||||
|
|
||||||
[ -f $keyfile ] || openssl genrsa -out $keyfile 2048
|
|
||||||
openssl req \
|
|
||||||
-new -sha256 \
|
|
||||||
-subj "/O=Redis Test/CN=$cn" \
|
|
||||||
-key $keyfile | \
|
|
||||||
openssl x509 \
|
|
||||||
-req -sha256 \
|
|
||||||
-CA ./tls/ca.crt \
|
|
||||||
-CAkey ./tls/ca.key \
|
|
||||||
-CAserial ./tls/ca.txt \
|
|
||||||
-CAcreateserial \
|
|
||||||
-days 365 \
|
|
||||||
$opts \
|
|
||||||
-out $certfile
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir -p ./tls
|
|
||||||
[ -f ./tls/ca.key ] || openssl genrsa -out ./tls/ca.key 4096
|
|
||||||
openssl req \
|
|
||||||
-x509 -new -nodes -sha256 \
|
|
||||||
-key ./tls/ca.key \
|
|
||||||
-days 3650 \
|
|
||||||
-subj '/O=Redis Test/CN=Certificate Authority' \
|
|
||||||
-out ./tls/ca.crt
|
|
||||||
|
|
||||||
cat > ./tls/openssl.cnf <<_END_
|
|
||||||
[ server_cert ]
|
|
||||||
keyUsage = digitalSignature, keyEncipherment
|
|
||||||
nsCertType = server
|
|
||||||
[ client_cert ]
|
|
||||||
keyUsage = digitalSignature, keyEncipherment
|
|
||||||
nsCertType = client
|
|
||||||
_END_
|
|
||||||
|
|
||||||
generate_cert server "Server-only" "-extfile ./tls/openssl.cnf -extensions server_cert"
|
|
||||||
generate_cert client "Client-only" "-extfile ./tls/openssl.cnf -extensions client_cert"
|
|
||||||
generate_cert redis "Generic-cert"
|
|
||||||
|
|
||||||
[ -f ./tls/redis.dh ] || openssl dhparam -out ./tls/redis.dh 2048
|
|
@@ -1,29 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIE5jCCAs4CCQCw1ymcsil7MTANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
|
||||||
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjIx
|
|
||||||
MTE0MDgyNTE0WhcNMzIxMTExMDgyNTE0WjA1MRMwEQYDVQQKDApSZWRpcyBUZXN0
|
|
||||||
MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEB
|
|
||||||
AQUAA4ICDwAwggIKAoICAQDnZXRXrYURmTc/559vMe7CZnwtKul2ZMOtS7UDPCcw
|
|
||||||
G3I1KHCxFkAxLNDhLtIENWId90Lc1mAIKtULy+RX2ORfOhYZ+JDK3sY25+53dgFq
|
|
||||||
vdPdtSpiiLklSh5XXdLcNq5sg8Zs1W514otDrfooYWqUp7BU4vZ0Cb/MWP/WEynD
|
|
||||||
ne3Aj1lpsEqV4+ydYhoki91tY9VS9y48VOZ+VC/+aCcbkm4G8FSczLZrglmnDq0v
|
|
||||||
d/ZrQ6dtALvPzKXdPA0HuqacT7VZ09d9tVOBj8xRkq5YEgUNHStkzZiRHzFXtRx5
|
|
||||||
+mH/WkkzbA1C7eUeRFxIxp+C1KZB08cg9CgdrJYs/osFttesSncOIdDieauaqkTU
|
|
||||||
wlcEY//sv/eiOv4XCIvuG+39r0ITQ4m8Amb28v0uaz2s1e8UVpk1mLuUVcpspmAf
|
|
||||||
q0UUyb3aKjkluBn5rZuHxZLP14FueojFTLIXW6sNKYGqHqh4TicogmqCQAGhd9wo
|
|
||||||
Wis21+xeOI9FgojASxugN+tY/64nwYQfCWsv8AuZegjyQ+AodGrtIHEbrAdgeYOj
|
|
||||||
heEYDePaKMau/0vc14vlOs5EssXf49QYhciRqESc+0O85rHemgqhb4Qz31V3AGf1
|
|
||||||
NP0wvqA97AmBYRLZSNc4ExvmQponOIVJY+idWiqJuRZSOeScEx0sx22MF1Nhwaw+
|
|
||||||
3QIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQDGSfsv4PsVkApOy0IYgO/ejJMqcbRF
|
|
||||||
Qv+PWcNG43qRuF0Fyg+6Gc+Ph8W3qNoh3lGm16WOdhMrMnnV3GKpIbl1z1Dr6Jtl
|
|
||||||
BRAOW+rPN8QueB7Fb2hT7QIkTDNAhoj+ks26KvzBOkQa9IrXUQZRigystOl3k1OB
|
|
||||||
BIL7c6pF9gMaskBlM5g70i+R7bb+MF1ivhB/G1QGYx97QJFdmDIr1NkcMFo/PsSN
|
|
||||||
pcm/f8i0Vh+DfM9jnywLESptyKJCO5RnMW67ep7t/IzfnNfHLZ0avf91nEP6PRtd
|
|
||||||
3ZDXcHX1rT+T9RQNcxws92x8gOvIxrJN4asLZj8A5T6tTGlhbaR77j98NH/e8m+1
|
|
||||||
MIET49DsIpIWWMW7M0CATUejHtddpFV/fXfhMXjU2/nWfzhCAXpi6BN2iE7Qihvc
|
|
||||||
RmjFrrSdqkPEuTDVFN/rdlWwz6m1/cqYBGlPEFEHkN+gEyhBf5Qa1dc1QUYDBYzW
|
|
||||||
rSR/NdH4wo21MWvJDLMb8tzp4LJJ3deW1o84UeiymjHStzJARVEX8w1/qjTohVbm
|
|
||||||
PWKPe98137BQWYQ4QUhRDeZc1h6OcWdVsNg0wwNtZ9hqNGo7n7+YzyoKFLSYm6So
|
|
||||||
D+93y5AoOZlCgtUfzUPlumMXCYcvWP0yifvnNksK7eknlen9tRuhP5vUYC+DTfrP
|
|
||||||
YpIOMlHgRIe0YA==
|
|
||||||
-----END CERTIFICATE-----
|
|
@@ -1,51 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIJKQIBAAKCAgEA52V0V62FEZk3P+efbzHuwmZ8LSrpdmTDrUu1AzwnMBtyNShw
|
|
||||||
sRZAMSzQ4S7SBDViHfdC3NZgCCrVC8vkV9jkXzoWGfiQyt7GNufud3YBar3T3bUq
|
|
||||||
Yoi5JUoeV13S3DaubIPGbNVudeKLQ636KGFqlKewVOL2dAm/zFj/1hMpw53twI9Z
|
|
||||||
abBKlePsnWIaJIvdbWPVUvcuPFTmflQv/mgnG5JuBvBUnMy2a4JZpw6tL3f2a0On
|
|
||||||
bQC7z8yl3TwNB7qmnE+1WdPXfbVTgY/MUZKuWBIFDR0rZM2YkR8xV7Ucefph/1pJ
|
|
||||||
M2wNQu3lHkRcSMafgtSmQdPHIPQoHayWLP6LBbbXrEp3DiHQ4nmrmqpE1MJXBGP/
|
|
||||||
7L/3ojr+FwiL7hvt/a9CE0OJvAJm9vL9Lms9rNXvFFaZNZi7lFXKbKZgH6tFFMm9
|
|
||||||
2io5JbgZ+a2bh8WSz9eBbnqIxUyyF1urDSmBqh6oeE4nKIJqgkABoXfcKForNtfs
|
|
||||||
XjiPRYKIwEsboDfrWP+uJ8GEHwlrL/ALmXoI8kPgKHRq7SBxG6wHYHmDo4XhGA3j
|
|
||||||
2ijGrv9L3NeL5TrORLLF3+PUGIXIkahEnPtDvOax3poKoW+EM99VdwBn9TT9ML6g
|
|
||||||
PewJgWES2UjXOBMb5kKaJziFSWPonVoqibkWUjnknBMdLMdtjBdTYcGsPt0CAwEA
|
|
||||||
AQKCAgARw2kN/gUUF8X1AuvrVlL023c25G9tpkibOg+YQvrjJ4g56nPUNFgTLlSO
|
|
||||||
pNB8gDibAktAtrhCiD84m5tY3w6Q/N2LethqqnVe66kTxJxRPGdSQsERNVu5MBpq
|
|
||||||
LIquWwhCzk7iNfQ32n9EX8uvY+MRrFnN+mpe+AygPEjPf0MagDorKRX9FgpzvT6B
|
|
||||||
ynElUxNZfWt35f/Ho+DZ286fYhF2fWQy5iooq1JpqGUHfQnwde4Vx+jHZmIEjrpA
|
|
||||||
5IY/jKWTpE7QqYGGZfAWJxrRPEhj/GYk3pNhNqM6qMFZ8U5RUtZJCv5Jk0blV2va
|
|
||||||
Sfcnow/FtFta/E3yCqw1svUIWTYEwekaJIB5n3K2vbYwFdrsfrLJ0dOu3qMW4H4A
|
|
||||||
XSzuSleswPQf3wE3HKfPL4H2RsQsl7M/1tEFZWzegT5b9jAjDPQOagKi9OoQf39f
|
|
||||||
iJlPxzt91ukcYiYLcPbV6vr3WP+8TJshV3u2gd85zdQ6N+Jm7fcbtjT8UjJYa2RQ
|
|
||||||
UM6OiNrOPEqwZcRlXbBDyIQYIBN8VMVS610NekHDgSmWNpdofmquMUoWSukL4Vl7
|
|
||||||
FA+kPgAyvoHU4nUc13rFOis71ZUYP+JzFEWdE16q72ehemFnEgRNcyTUQAlz5Wl+
|
|
||||||
SApH9ibqjXfD/jYFpHlIg+Aw6LQqo+g9m7MyNHb7MNEyVfOjhQKCAQEA9MePx+uZ
|
|
||||||
vSIDcmxNsi0lIELbpwOSwgYH8v2WWWHARVZF9i9ZQ94R+PHmVFouzOZ6AB89EqDw
|
|
||||||
c7qSX5rveJH8FurXOWu9LPIwSR0SATB67yPh2GR55vTQP9F3gHRA1nB4Wto6Uhk/
|
|
||||||
2W1WBNnO3xOcOzitvBuPHCRMK193pa6HDmKXzZHeDA3NPhaM13eGI37rpM3tqm7I
|
|
||||||
lyeZrCo2Tps+8j9qkBOQ1VaPUtc36bMZpnTlnTP3fFp7oaQKgtHnpqpQsVZuzt90
|
|
||||||
Y8UeVRe0LOWi6VOWjiasVvQl14338CNyKoi9KCu3NL4B+4OQBoxNrpEsd0/OKEXX
|
|
||||||
grCIRg12tajluwKCAQEA8gDX4wqOzmdrcqsIlACREhyubnIDEJ7WmceR+dklrs1/
|
|
||||||
aaYL0H8IVSBmszzIUiTA9kjEFCU9vls6vjguBpF49YlXQc2pmyu26zQc83X4m9n8
|
|
||||||
roO6Jdlic5lkYbUtuB6c3AE7J5vTg2Yc9oLAOMibkjLrwfgQpBfMHhUY9hWpTBFF
|
|
||||||
8tBiUFB0ZDTcdDpIWd3P20j/RSB7e28sq34k6t0KkiWkIVecEHTq4uI6TGePzvIW
|
|
||||||
vdDVAKM4nllPYUPK6jQRvJ+fsKxnqmra0MoOPIpwpvsyg888992KaKC6zL2/EWP0
|
|
||||||
axExlKVYruyo7GNsSPOZq9eJ40Txc0nHbYUO3LEYRwKCAQBUM5GyI8lu1hR5d+gC
|
|
||||||
MqViw5zrhr8lHw38+F6PwKBzOYo3dXIvdmSYTh39RkhzE5VEFXrcvZ/5L2TKnnFh
|
|
||||||
+FXPTFlc10LsAyO5Atb+sb6YJK+70FRerjg0u8lv1o23NlkwZ4FIXIcqNAIzCPmw
|
|
||||||
ov5LIOQioRhJhfLtuJlf1PmAaUnu3Q6U9upzQS6Rr/vkmfRVbMEkr5cw595k6uBj
|
|
||||||
iePNUSNHDHP17yC+Tmpdac6ZA/04ZnfrvvRoVhWHis0098FqP2E+qH9REq2sd8ry
|
|
||||||
5stzl91iaMs/3hxmWd/AK3FKUF9BQkhzTClCa69PkVPniOjS4hD4qY3I1xEJh/gd
|
|
||||||
5UuhAoIBAQCBO/4OGvdENmpk4/1CvEK8f2CPTodgetJzcOX9nP7IqKkgDDJG92/F
|
|
||||||
tfXiRdVcOJBrdVRwxaqBW0q1hl7d1xXXWa6lT2UBnoiidkP3p8pJwFF2CJaB2+L9
|
|
||||||
hK7cltqBdqehvW6PqmF7zC4vXoe0Szz5CARqo0SPvL2eWvnngI3WN2s5ThsSdMST
|
|
||||||
Nr97uhwlEZUMr6DSk5QdyLL8KfMhEUWx4jQSMiz/hNBitRkY8D0V8KZAW6NEIeX8
|
|
||||||
egkwEfnstD28kym+OXNqyIFt+lk771pVcdP6G9OdMkvVr+/RoorEiLJf8uCdVudT
|
|
||||||
EsLq6fVLx/sKj6HtIkYmoQHE9MeJB3HFAoIBAQCrl5LBfNKjqx9ijX/ghAvvHm52
|
|
||||||
T9cSJxHZ2VaIghAIwXDAA7vUpeLlXcR8zHp+TozFWpfEcZh4ztmfmEozN8Ljcutr
|
|
||||||
94VX7urIdC/JYzfJ2rzNmJdk0sgXZ+yv4LJ9RvoehIuhwQc95JLdnlEP3kNBiqUM
|
|
||||||
N7i66BLdWq015b6WCIYS8DeBfETkXRLMH2hawpB1ZmhiWQ3G49cGJU/CXt8471dC
|
|
||||||
urEwlHtCLDvZ4peTCoVtV0OgNTcE05RPO15gFIMWrHF/UoZiV+PZCHTJNzjupjNw
|
|
||||||
8xgu+EhDo62M8t+SILwNRPvusAbOLXsnTbq7xbmWR/9zPtJscBCxMCxiHkKc
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
@@ -1 +0,0 @@
|
|||||||
F93DEACFF8ACD907
|
|
@@ -1,24 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkGMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
|
||||||
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
|
||||||
Fw0yMjExMTQwODI1MTRaFw0yMzExMTQwODI1MTRaMCsxEzARBgNVBAoMClJlZGlz
|
|
||||||
IFRlc3QxFDASBgNVBAMMC0NsaWVudC1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
|
||||||
AQ8AMIIBCgKCAQEAtKcK6sWYkbgmWKV03WzmLbicEr9gMZVsoyxgNV52ciFnPQ72
|
|
||||||
2B0PEafTO4CFdzTj3titqqOtcQVVqo6uCZroBfwCYzEgozBEPvECcY/ldw1uiN9c
|
|
||||||
EyCKTAEGFqnSZwJ4UfC/JDnsNRjflLrAZ5xsQV56+yreYurY8WzCmdjpxkHQ0i0s
|
|
||||||
BBG0wdd/d4G8EYSHjOhtoqckUCeHU3Z8+WOn3LeIjK2XaAZTJHC+a9Pjj376degV
|
|
||||||
bgEQufwrTiyOimwoMVvu2biMEyPo6KXJeofaPjAMeS2uD89czV2qjPPoLrb+x1mZ
|
|
||||||
wVWK+PIiQE5cgBGhjNTEToj0xI8ZhGiqvoLTdQIDAQABoyIwIDALBgNVHQ8EBAMC
|
|
||||||
BaAwEQYJYIZIAYb4QgEBBAQDAgeAMA0GCSqGSIb3DQEBCwUAA4ICAQCSTgkiaEou
|
|
||||||
OS9K4Cq7sIPvZHmZlniti4TeMq1lgVzTjRRjSA2mP0183LrWCRouKor5ce/Zozbp
|
|
||||||
0/GNaA+Iru5Ig22dtC8M2UiQGvIRCth6oJxmM/T9VeK54pIQ3XDpyl2t3xVqh74u
|
|
||||||
1g5BvZ51X17WnuVR0Ipax1EPARkXKijvhZ1R71yd8fClXeXE4SsepUXdl80mkCKk
|
|
||||||
wFqdhArQYrNcG4lI/y4VxGbPFQ28a9L8Ru44pP8+7lHCENN4T8P7CquRpHaEIyKH
|
|
||||||
v10TLZM3V5e1cZmDmmvWmdyntQR1FIHLUNWbinLkUwhYvFQPlGqXyywUDF0Jn8x8
|
|
||||||
KyUfvUXyoi+vbKQPVHY90QPyTc6hpHfSLU+jkXFmrWn1f1h7pHRBIcCFX77CTZyY
|
|
||||||
8Qpse0xsyDb1d07DB+RhTkw9nZeNBjj9/YPWgM/Opl5C6g0w5vMQYvIkgrGZ4Xsy
|
|
||||||
8D16nIZtoP9omGzK7La7Yov69gq+/5j4IkMda4FukDs9y71/t55mlYtR/J2rQiEo
|
|
||||||
YIFdXng0CgqMZg3i+qPU9c9ptsm1y8R6RCZHyrrV4P4Z79TbUv0bHU0pc56lXFZw
|
|
||||||
M4HwFYGvc5cvSbTeqmpOKftlE743+8ZZuL1Ll/tscVehNiduHpogkPfN4Z2UNM8h
|
|
||||||
3cRF3zsnD1QdBbJuvIgaO7HsOuLiZprlSw==
|
|
||||||
-----END CERTIFICATE-----
|
|
@@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpQIBAAKCAQEAtKcK6sWYkbgmWKV03WzmLbicEr9gMZVsoyxgNV52ciFnPQ72
|
|
||||||
2B0PEafTO4CFdzTj3titqqOtcQVVqo6uCZroBfwCYzEgozBEPvECcY/ldw1uiN9c
|
|
||||||
EyCKTAEGFqnSZwJ4UfC/JDnsNRjflLrAZ5xsQV56+yreYurY8WzCmdjpxkHQ0i0s
|
|
||||||
BBG0wdd/d4G8EYSHjOhtoqckUCeHU3Z8+WOn3LeIjK2XaAZTJHC+a9Pjj376degV
|
|
||||||
bgEQufwrTiyOimwoMVvu2biMEyPo6KXJeofaPjAMeS2uD89czV2qjPPoLrb+x1mZ
|
|
||||||
wVWK+PIiQE5cgBGhjNTEToj0xI8ZhGiqvoLTdQIDAQABAoIBAQCeCzGi2QG0Ik3x
|
|
||||||
6baG7Pmm8EYipKjMWDR1wKHeruiiypReN5Q+15VSVeeXu8WH146vbBLrIUzgftFG
|
|
||||||
aJLbtljcu29/RgCOo/BgvErt/Py8HdUhC3+rACHdglvIQgPfuKp4zUz7rWz3uu4H
|
|
||||||
WSZwvsl6muSujf+GvHzVIdhR7hH/LianictHN6OBvuIk6+88LYxOvPzvOuzTs6o8
|
|
||||||
D4CdNwaWUtOm4/gV2/UXKBosbdpIoVbYAAOZPnu4gLAJV9ICnLDKMtZ+buZNEBdo
|
|
||||||
Pt3vtzN9LqmaiC1BfaH3Uqr2nhPW86VwLIr61uFGRG5Y1GS2XXOq+dgxW8BmXWMP
|
|
||||||
42J2GUlBAoGBAN+mPYJUckGFlToREOefwHsKJqPP+1aK4LjibqXZSnTtRvAur/kD
|
|
||||||
Bw/b8xGSHx/pisQU9wwtbaaVy0tbW6fMBBweOiZMJdQ3XRaH87GfPDyEmqRnUWAF
|
|
||||||
/NiyshHDmg6HK6Dm1hT4Ndd35PO1xJDsgGyqCrsMRwfAON0pfSVxdWyFAoGBAM7I
|
|
||||||
n7tBdWeTWeVVFuZdyTVOWsYO14ZRsHULd30gO+bXaXFAK7X8/5tawZ4PXJq4VD0f
|
|
||||||
rpOcsnNtuROpbh3MshsplEDuq+JQ9DlhBTiz8wVcKp9z3RCY4GQjuPNIFuVMjN6i
|
|
||||||
dsL0U+IKwMPpYnlgimW3sNygO3q/nNxrUobBITYxAoGBAKYkC7t+2iXcg1/Qf7th
|
|
||||||
jI6amtvETFUc9BXEeCgSRGKaRcF1HVqhqiRY47fg0ehWCLTjUicktDk1PAFuC6ea
|
|
||||||
Qk9VESOUG+ILgsaTFjCUNx5J78tDyUrJB+0+ylOx+Abk2T89XDnVrcG0GkwFctGq
|
|
||||||
LzkKFNChLT8Px+5bvNEM+Qs1AoGANcSjDBzkO09sU56BetsuI4dBQTjAv/Njz7tw
|
|
||||||
kX+dM9QVXdZSx1qG2E2MBN53tN9zQAWJ7mYTXMJOGpe2w1bjhP6VxyCIXyuvpW/d
|
|
||||||
3LWl3mHtz1JgTB2EU2WahN/c3DjAdG+IM/82BJPJNefsrCT3N6XA/k1Hyg4i6omZ
|
|
||||||
huKXETECgYEAqr6GHzgFy3Y4OIpobwuAKvrY2/s7bo68pF6QTqvxalkJkjkp5HyP
|
|
||||||
FobWC0GxrPfwjkRbQTRANA0vVwFP/MnCU1ag3UeoYamOmG2GnTiiYWQehovAhOyi
|
|
||||||
TK7QXf+j5o4nrRt/TRfyeZH9XevX53HIGuFRtFZbm+WMn4bPjQj7ypg=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
@@ -1,6 +0,0 @@
|
|||||||
[ server_cert ]
|
|
||||||
keyUsage = digitalSignature, keyEncipherment
|
|
||||||
nsCertType = server
|
|
||||||
[ client_cert ]
|
|
||||||
keyUsage = digitalSignature, keyEncipherment
|
|
||||||
nsCertType = client
|
|
@@ -1,23 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIID3TCCAcUCCQD5PerP+KzZBzANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
|
||||||
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjIx
|
|
||||||
MTE0MDgyNTE0WhcNMjMxMTE0MDgyNTE0WjAsMRMwEQYDVQQKDApSZWRpcyBUZXN0
|
|
||||||
MRUwEwYDVQQDDAxHZW5lcmljLWNlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
|
||||||
ggEKAoIBAQC/lqyvZ+JecRTRWFEoyfIYnxz+1HiZwFGL7BhSrPf7Y6CSDwV+A7tB
|
|
||||||
Pvu7gSQx69cfMIeS78n/pNV4P0dCgiEiOYZlqa8z1H3MVG6ZuM9uIfeubAeOvG5M
|
|
||||||
Emk9UJ3KU01XFFLCaQ9u+WPJNUQyB+hUDE92k3PQ+sh3getcgYDQm6ktt1lZOgUK
|
|
||||||
JwXPNg6E1HlLDMrf4kqsCLMHCAuI7pT0RjMrK6mNEvs7hFf487zj857Jd1XJ069l
|
|
||||||
Fhqt/LOW7jOOCEXiGtfWEJ8pApsIsc1Pdgzxh+WS1HH0qRELMv0RUJXnhw/uiE1A
|
|
||||||
TwLVUD91YwboSLIYf/E3m7zREaXwf14RAgMBAAEwDQYJKoZIhvcNAQELBQADggIB
|
|
||||||
ADZgwvnwZf+4FuUrMs7sN1CcMyZ9IIXH16Z4/nn9LjzheqvtzoEEP7fAkYjL2z48
|
|
||||||
S1iHMYfCGNHI+wijtbt4BrbvR1g0nqmGBfiJ0xHyFpU03goh4l/JiqSK9kf1SPAF
|
|
||||||
763h564PGaA7sFFKf+VR1GpvEGD6vfjm5vIs2Hn0SRF5/6dwUNZOWaCkfdBB5ddb
|
|
||||||
1mSI8g5cEEv9+7mlIEXkdRiUJHFnuIUbH9W3ivB+XWGp9/o3y1+eK68+BkcRWBSr
|
|
||||||
PkCL7V3DVj0ENV2QqovUcyu1Z1kakNubyBxs/0t84DZ2NfYSyAOr2rBn8LW8Fbfc
|
|
||||||
X2E79C0RiuT6NDjMMFPchYVXeT7Fuh/ExwkE8DYCJWNZCY+pDdas1fqSt8loPZDG
|
|
||||||
M0LNCrVdI0uR5sJnau8ihKkn4UIkCP1XkXNUL1lKR86msZibIH/SqTWAUWh2SSuG
|
|
||||||
UqMORqRksC5pobJkQDra9b2ViNCcjp/S5iq5lokxnuGu3SxQObCnei0ceBKppWy5
|
|
||||||
orkRwuSwMrDUX2bVcR4Zcjdg7kz7CPcqObZTEcadRaxVuWOIi/Jn1zYqOGEOavyT
|
|
||||||
VvEvo9DT486aLGtF9rA6o/+MydRXd1qBRgfjrV7aaBZkRm3F2ofdpLrzXnDwarei
|
|
||||||
SnXRnd4rimpcL/s09DEevDkyt2aezgS/ngP4OWM1zJOf
|
|
||||||
-----END CERTIFICATE-----
|
|
@@ -1,8 +0,0 @@
|
|||||||
-----BEGIN DH PARAMETERS-----
|
|
||||||
MIIBCAKCAQEA1nYlp0dgMjvcReATfJwuS1lAtpvaTl8/Fu1/CuQ4rCoB9fgqvlTv
|
|
||||||
jgnHRAW42FD9NwOQibol/mDAmThd8Srq/teu84w9j4CGsd3+qO+/HP16GHLACVkP
|
|
||||||
LmImh30irqfTC2JkuiRccMYmt4N93Ba8FgC+GLcEjEB0JKW/JBZ71qO8fvwvvI7h
|
|
||||||
QU4YddezMsPG3L6TDYX0cFCSrcBNKa8mGgGLtppT30UWvAH0QAlsd6jiIR1cto+T
|
|
||||||
yDAv5WYIkBlsGcH70X1EEglHz48USV0Xu5lADkiazpXvKTl3XkD6gVkrCcxHF1iE
|
|
||||||
7VEbxKaGx5HsdRw7EV6Fdxp98mGRWjBlKwIBAg==
|
|
||||||
-----END DH PARAMETERS-----
|
|
@@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpAIBAAKCAQEAv5asr2fiXnEU0VhRKMnyGJ8c/tR4mcBRi+wYUqz3+2Ogkg8F
|
|
||||||
fgO7QT77u4EkMevXHzCHku/J/6TVeD9HQoIhIjmGZamvM9R9zFRumbjPbiH3rmwH
|
|
||||||
jrxuTBJpPVCdylNNVxRSwmkPbvljyTVEMgfoVAxPdpNz0PrId4HrXIGA0JupLbdZ
|
|
||||||
WToFCicFzzYOhNR5SwzK3+JKrAizBwgLiO6U9EYzKyupjRL7O4RX+PO84/OeyXdV
|
|
||||||
ydOvZRYarfyzlu4zjghF4hrX1hCfKQKbCLHNT3YM8YflktRx9KkRCzL9EVCV54cP
|
|
||||||
7ohNQE8C1VA/dWMG6EiyGH/xN5u80RGl8H9eEQIDAQABAoIBAQCsjHdaQqWNiSrG
|
|
||||||
oFP3+Gkh46uplpJHZv4KlsgRLdbpggDLitvXcmTjjmYJqXV/wHgujvaLT4sNwta/
|
|
||||||
Rb5YF/rfaA+y3+/7LhVeQWya5edruQvo+0KTOwHbYXmGz2RNJFkzZAplLVnJCLLm
|
|
||||||
NCMHLDgB+lRW5tYYEMUbXNcsqTXqqbSj9YHJ31z4y4GMXvw/ZIqikixgJzvIKe6P
|
|
||||||
zXBkK+J9otHWO3Z3CMFoRmhI0fp/wIiOlp9Xk2QzhUIIo5mzpRP2FnVBQH6qA1Qx
|
|
||||||
HcHy/kHCNOtkebaM50tCHwSZi+w6WjKRfbTpQHCaUIjvTfVEup088iI8b+gt48Zz
|
|
||||||
noX1efhBAoGBAPwCiX71kICymFBMyfE+0KZqg95w5oOygb/UvqmfAAHL8wwAxFRB
|
|
||||||
zTG6GQE67P/nROxUm3mr3JcTgszGcNBfeB9d3J59AFIoyHCOk8fXUS4I1JOKdIdg
|
|
||||||
XIwtCcIrCkCcLrzUVZlT8mJRH0F4U/LaB0NHiRZe25AWSVUdpbA/SDlHAoGBAMKf
|
|
||||||
O9iWdGZT6YC8FnFjS+HV7mJlUmaEgGXLqwVnEXOuGKell6WS5GN9XEcP8BnUqaoi
|
|
||||||
ARCWfku18x2LgOm1WZf9voPUvGwYAOuvzFtX9d8MYQQnI+fZX7ZpRO0Pako0kQhr
|
|
||||||
4SUadVQXXJIbB6kHr3JVP7dICEn2LOmlhWLnRlnnAoGBAOzxqbuAQaxvvzwI5vp3
|
|
||||||
mBBQJ8qWlnYO+WWXLukmwQfvbYbEldOuxrJRij8Y20rEdI5MAp7EkzRMuPe2QM36
|
|
||||||
ZWQAiXVOjGWzSLpjo9kKvp4s2UobrPK4DGwT0JAKjaov7tXGQvFV95ivM1cIPs4g
|
|
||||||
ZyG/+cnZyFDSU4K+zFFJPqvzAoGAaaa5fT1H2RjqZJk2cb1evy08aKvqTH7XmOs0
|
|
||||||
Xw1xmuPCvJeXOCoC08OE6YrMY6lfpV0qSM/5pa4TWVGW3Mg259y2pKhC1Uc+kLNx
|
|
||||||
c5DPh5MXw4Jf6ofFfqes5Cf/ImNg7DpsEZFIair4dNQ5l1f1tVJz8VIoNcZu4TOa
|
|
||||||
snMsbLcCgYALyGUUdgCDZErB32O2I6o6vLQh6Lc0YqbjrGGkvuygOEUiLa5Wtjqe
|
|
||||||
AHyb9aT39jSCFEaTMKPma3T555+Lkk1Io2jYRVenoFS+O1nlRQKuIbIyuejA/SFm
|
|
||||||
z8rZ8EMT4g485CZJ3VjkoVXNXl/L61F1I9vK31Il88qgvm4y2JlYyg==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
@@ -1,24 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkFMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
|
||||||
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
|
||||||
Fw0yMjExMTQwODI1MTRaFw0yMzExMTQwODI1MTRaMCsxEzARBgNVBAoMClJlZGlz
|
|
||||||
IFRlc3QxFDASBgNVBAMMC1NlcnZlci1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
|
||||||
AQ8AMIIBCgKCAQEApvPQ66+fMPnJMf8BkGMq35EAT3FJIECqd3K/DNS2zox53gSj
|
|
||||||
P9cPuaW+JBlMUXTpGhgNKSLD8TMwJcA406A/pJScLNrdfoI9RvlKblwWWxcr2QBS
|
|
||||||
gFvEcnAYByVQb7S9gEOZev5CHGPw9Bav4jYZ+nTc+ERDuMC6HaqrjbLk1UbkuvAV
|
|
||||||
cWipYygtVFeeWx1TdHmez7n+kXcKNVojp1BbNJj5162zYXD7CnWrepA0r8b3ETEs
|
|
||||||
jTFRmJd6UgjZ/u+apf+DlIQ5UZOWPUs1okzmCjHAL0hp55Mj6lRW7F+ZEX8uC/pG
|
|
||||||
jOz/Qi2AIztZp+tYSQmyXlsEODft88D6StWKLwIDAQABoyIwIDALBgNVHQ8EBAMC
|
|
||||||
BaAwEQYJYIZIAYb4QgEBBAQDAgZAMA0GCSqGSIb3DQEBCwUAA4ICAQCEiTikIbaQ
|
|
||||||
4reQTD0pYlofKZgczg2BdnkvxVXBp/i/qNQgvIuedKFsAHvNTOtEm4zc5cxspFvW
|
|
||||||
bEZFMObHYTmRKVJzKawCQOp7uV3+StzqpV46uERn/HVH5PhToapH0ZA/vXp9dB8U
|
|
||||||
rCX9FQ9Wp/NeH1fzpToGuXgUUCo3jUKpkwJhxc0OH220/l6xmbN23ivY5UTt2z9v
|
|
||||||
x6S0gtkCD7VH7x5xxGu2T2HsJGbTefV/dknYcAYvZa5hy2wg4PyPlGSYD/UEZzVs
|
|
||||||
hJQDg3QTXvqFjdc8ZlPBoG1X028T28tiDgUuTwhH2trvY9qjk9VAVax9Wi3mkmYj
|
|
||||||
XfuSzgE/WexXrCljYAaPndUOwrd47XejlilcFCg5Otq5oPsWvFB+aSPyHHQJLG9B
|
|
||||||
ZHa1hFP2aV/amfMQxAj9dv7StrpdWHXTk1dvryQqyt3oZl87fUDPsBrmjOgdieFn
|
|
||||||
aGcx5NzCOQG6X6GwF15pdMaA4h51kZuZqM5hkpJOfYZb19eQ0O3YzdsN92Wue4iW
|
|
||||||
URiFFWbdZWeO5lykmwBDqNFP/4XIrgczEq62/Uzyt62dfKL7f93BfAiT2qtdtKqk
|
|
||||||
mHoya5ng+uav2TAGbHQgrNQYBJm9sB5MFwRYUWnrvWlig2whOzT/PGNohbc1JKkC
|
|
||||||
KSW2kUmwl+vdLoKe59o8TMfu/gn3BN+A/g==
|
|
||||||
-----END CERTIFICATE-----
|
|
@@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEogIBAAKCAQEApvPQ66+fMPnJMf8BkGMq35EAT3FJIECqd3K/DNS2zox53gSj
|
|
||||||
P9cPuaW+JBlMUXTpGhgNKSLD8TMwJcA406A/pJScLNrdfoI9RvlKblwWWxcr2QBS
|
|
||||||
gFvEcnAYByVQb7S9gEOZev5CHGPw9Bav4jYZ+nTc+ERDuMC6HaqrjbLk1UbkuvAV
|
|
||||||
cWipYygtVFeeWx1TdHmez7n+kXcKNVojp1BbNJj5162zYXD7CnWrepA0r8b3ETEs
|
|
||||||
jTFRmJd6UgjZ/u+apf+DlIQ5UZOWPUs1okzmCjHAL0hp55Mj6lRW7F+ZEX8uC/pG
|
|
||||||
jOz/Qi2AIztZp+tYSQmyXlsEODft88D6StWKLwIDAQABAoIBAG+d3BRmIrDUnp1t
|
|
||||||
VndYxWYYhDOYkoIcmZsoPPBwGhO3ORak1RuuRZYhaCCsRSjEV7+ZStswof1U8qCa
|
|
||||||
haN+pG386PjYDnMw0ZTsv8VOjaeysx7uJzonoAu+Q2IroT49gOAK0ca3zC085+/Y
|
|
||||||
Zxh+gRnAHadhxED1oLiKzQz8CB9JpNIWWIhMEAPUgnnVMRzED62OyMTsX6ztPSx0
|
|
||||||
EiM1sNU7Jnf9TVMYS1LjJ9SNqbT9tmPaRj4DM2X17Iolg6ntx3rl8xeKQfcrOl/1
|
|
||||||
EWjiXBSmmqsGpQZPyD8uCE4d1/V+5sNpRkPRBJVoqPKRdmSHCgOPkeWDv1zoJZv5
|
|
||||||
RnS6MKECgYEA0nRtQt6j3USq/PDdnzRjskks7qsfOtsMR7ebQFwD+bbpAiY+walu
|
|
||||||
zTFwr1KggAtfjlp1pegnLg2aIvCoVr3wDAf7itAFIY34OKXsgV6AAu8k/Kr2KYgI
|
|
||||||
ZbPKmhn7bCH3vCzC+SsN0kBHhOmWLiErx50mpVPFgjkOHG/RQZa24NECgYEAyxVH
|
|
||||||
cGfSMWRe/e25R6F8b5V+oUThCZ6JyL0n03Vp9OFt1FN9OleBjezA47AysnKFnqIa
|
|
||||||
jsUwjXEZOFHmNSO9tPoNxqPH5vaE/BShSTVdP/zeOXF3BQLajrqwC6+2tzDMmpmT
|
|
||||||
erc1lPWHIMrvNaVkF/9mVbaDyZcGa4eNwm0Iev8CgYAtcTRSdw587aHaIgxInyBT
|
|
||||||
09ce5dZFeBzrs2qTeArntaYUb7unR3WEWwOQ589+NnZ4n3G91CX5nLhGiR5gNH0L
|
|
||||||
rAGVlJs3Bpeta65otMYBXC/pWuTyTMw7YZoCsk+GpsL+X8/ty20dlAGdYm6qIUF5
|
|
||||||
xaYdlrwUBUvVuhM+DVQJsQKBgALJ9AUzJ8vN2RAbp6O4MAFISEjmrUB4kOPU1Ssu
|
|
||||||
PZpDTkLQMrQOZ5UPX0bBMLEKqZMYHs0/H/+RQgtn9IVeTEij9nR341Lkp8becaiT
|
|
||||||
twgd7N9VE5FaDK5RGgHPE+9IGEc3PLM+uNmm1Yg5wTc3YjyCIWGj9ANcs5Xecq/s
|
|
||||||
12T5AoGAAlLIzXB5KStzhEibmwgmXLDL16hgTXmMHZ59Uy3Wz5g5r66rUqQL1Fg0
|
|
||||||
RjtRYeCjylVzDGw5ffzQYPUg2DqAncD/K2Pgw1EirwdZfzdWU7oXIiA+FYEEi0Z3
|
|
||||||
q3VVFmHAJaTQpU2A5UpL5+a8s0oPxxmU8p+FVhVuTLSuX8GcJr0=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user