mirror of
https://github.com/gofiber/storage.git
synced 2025-09-27 21:02:20 +08:00
Compare commits
379 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7e7d4f371b | ||
![]() |
bf28559433 | ||
![]() |
8915ac5932 | ||
![]() |
fd4fac3adf | ||
![]() |
8aa8fbeefc | ||
![]() |
bf983c20f9 | ||
![]() |
13e08cef5a | ||
![]() |
c1af83c69d | ||
![]() |
b68751d060 | ||
![]() |
6c4deabb76 | ||
![]() |
77503ea5d8 | ||
![]() |
d89901cc12 | ||
![]() |
335fab6bdf | ||
![]() |
0f10913b8b | ||
![]() |
26a210373f | ||
![]() |
213f994147 | ||
![]() |
588a599ecb | ||
![]() |
c08a1ff422 | ||
![]() |
a21499405c | ||
![]() |
43150c5fea | ||
![]() |
41bbe83912 | ||
![]() |
4b6d204e22 | ||
![]() |
1190344d37 | ||
![]() |
0ab3d410b2 | ||
![]() |
4a7266f166 | ||
![]() |
866bd8730b | ||
![]() |
4f5088e8da | ||
![]() |
50cf5a78b1 | ||
![]() |
aee8189852 | ||
![]() |
c906c8ae1c | ||
![]() |
3c69d1c1da | ||
![]() |
cc691bdbd6 | ||
![]() |
f8ddd21b97 | ||
![]() |
1a3961f00d | ||
![]() |
6c0e70cefb | ||
![]() |
accf8d2c15 | ||
![]() |
9677f3549e | ||
![]() |
2f911653ec | ||
![]() |
bc8bb06e3c | ||
![]() |
d19802b57a | ||
![]() |
cbfbd984d3 | ||
![]() |
a3b1139001 | ||
![]() |
5a40e781c1 | ||
![]() |
e819b50e03 | ||
![]() |
57394e68cd | ||
![]() |
959e491679 | ||
![]() |
84a36d2015 | ||
![]() |
d004699f2d | ||
![]() |
5622ef89d5 | ||
![]() |
9a88efd8df | ||
![]() |
7793d2a375 | ||
![]() |
d6f24b53b6 | ||
![]() |
fb038e2f23 | ||
![]() |
ff49c86eea | ||
![]() |
20885d936c | ||
![]() |
0380c686df | ||
![]() |
f0840fb5c8 | ||
![]() |
2bb1e01c17 | ||
![]() |
396549add5 | ||
![]() |
164dbec004 | ||
![]() |
63f3884abb | ||
![]() |
55fb9917ff | ||
![]() |
2bba6b2afd | ||
![]() |
df568c139f | ||
![]() |
a4c75f4d23 | ||
![]() |
ab96148ba7 | ||
![]() |
3a2dcee0b3 | ||
![]() |
42a0064a70 | ||
![]() |
668c9cc6ad | ||
![]() |
aa1d482357 | ||
![]() |
f450f56bf3 | ||
![]() |
9222956861 | ||
![]() |
d8ee898ba0 | ||
![]() |
9d6194668c | ||
![]() |
2a795ed473 | ||
![]() |
117838fd0e | ||
![]() |
318b2fc04c | ||
![]() |
0aa08303bc | ||
![]() |
a1556f322a | ||
![]() |
6c27f7f186 | ||
![]() |
ee54c946b0 | ||
![]() |
0b9349c8bd | ||
![]() |
24611ce162 | ||
![]() |
1469483e15 | ||
![]() |
5eba92a47b | ||
![]() |
999159cfb7 | ||
![]() |
da27e01fe6 | ||
![]() |
b9f4a4fada | ||
![]() |
533803d845 | ||
![]() |
c790bf75df | ||
![]() |
c15a219ee8 | ||
![]() |
155e4d36f7 | ||
![]() |
b4dea997f0 | ||
![]() |
bc92dbd3c3 | ||
![]() |
dcc812364e | ||
![]() |
ae0c3cfe6f | ||
![]() |
d5342ec28a | ||
![]() |
f7239431b3 | ||
![]() |
800e2db645 | ||
![]() |
420291805e | ||
![]() |
cdaf9129ee | ||
![]() |
125ee5f155 | ||
![]() |
c752b57508 | ||
![]() |
a63192c702 | ||
![]() |
c790785827 | ||
![]() |
25bf058c15 | ||
![]() |
debea836ad | ||
![]() |
4ba1e265d9 | ||
![]() |
82a7c7c87e | ||
![]() |
4791605f49 | ||
![]() |
fb2da5d153 | ||
![]() |
9f74d3e4a8 | ||
![]() |
e2196eb28a | ||
![]() |
f23189e030 | ||
![]() |
a37e0cc3b0 | ||
![]() |
8cd43b2951 | ||
![]() |
fd6f711788 | ||
![]() |
b48047ea41 | ||
![]() |
939d9b0eeb | ||
![]() |
4da7a8a588 | ||
![]() |
6d96c2fe32 | ||
![]() |
a04596a8b5 | ||
![]() |
23d0362d9b | ||
![]() |
35acbea01c | ||
![]() |
f201d3a103 | ||
![]() |
43ac34f7f3 | ||
![]() |
9006b23eef | ||
![]() |
d8daf4eb86 | ||
![]() |
42106d8ab4 | ||
![]() |
934395fb24 | ||
![]() |
caca820b8c | ||
![]() |
98413e412a | ||
![]() |
c8041d6397 | ||
![]() |
dca8f183e4 | ||
![]() |
659ab6b298 | ||
![]() |
08e41d81a0 | ||
![]() |
4b651548b3 | ||
![]() |
d43a56df50 | ||
![]() |
c3e230d024 | ||
![]() |
987a93083e | ||
![]() |
368027dc04 | ||
![]() |
4711dd9713 | ||
![]() |
b886afa98f | ||
![]() |
b10af3a02c | ||
![]() |
1f2c29fd9a | ||
![]() |
66d62ec7cb | ||
![]() |
e3e1f7a5ed | ||
![]() |
98c27d105b | ||
![]() |
84e6895b43 | ||
![]() |
5e419ced93 | ||
![]() |
fa82c71195 | ||
![]() |
47b223f56a | ||
![]() |
fe408d135e | ||
![]() |
501fd5d574 | ||
![]() |
954b019951 | ||
![]() |
4b0b7156c8 | ||
![]() |
0ca08d620b | ||
![]() |
4b33392dfb | ||
![]() |
d6a1b45f1f | ||
![]() |
6f502bb885 | ||
![]() |
c920e92115 | ||
![]() |
2998ca898b | ||
![]() |
01c4e9fa39 | ||
![]() |
9a830af2d8 | ||
![]() |
4cdb9c09a1 | ||
![]() |
922fbd8dd1 | ||
![]() |
d58b2097ce | ||
![]() |
d8f916f077 | ||
![]() |
d379039ef4 | ||
![]() |
a53bde5913 | ||
![]() |
21b2e44742 | ||
![]() |
6ef891d8a0 | ||
![]() |
23be295830 | ||
![]() |
6ded9c0f75 | ||
![]() |
dd752c6046 | ||
![]() |
20ba96f664 | ||
![]() |
e8a33f952c | ||
![]() |
c850eaff51 | ||
![]() |
2bd20cfa5a | ||
![]() |
2ee234e829 | ||
![]() |
1137fb9036 | ||
![]() |
a9dc413939 | ||
![]() |
825eb938c2 | ||
![]() |
e5eb169055 | ||
![]() |
4e6f1c95ff | ||
![]() |
c010712741 | ||
![]() |
161724ceae | ||
![]() |
6627d9d1ee | ||
![]() |
d533947dca | ||
![]() |
595b1917f3 | ||
![]() |
f112c6ddff | ||
![]() |
070dec8c74 | ||
![]() |
8125d5ae39 | ||
![]() |
45e450a3d8 | ||
![]() |
737624d914 | ||
![]() |
1401f6b804 | ||
![]() |
8c679bf3a2 | ||
![]() |
fc7eb4fd27 | ||
![]() |
7486445385 | ||
![]() |
dfdfd7fbf3 | ||
![]() |
87862b1ac6 | ||
![]() |
bbfc356c01 | ||
![]() |
d8d446b1a5 | ||
![]() |
6ba900f18c | ||
![]() |
dc7bef5d10 | ||
![]() |
dff3b2aa26 | ||
![]() |
560664ab5a | ||
![]() |
68c1b99eac | ||
![]() |
998df25440 | ||
![]() |
b59617e2a6 | ||
![]() |
c6162ed666 | ||
![]() |
31f94813cf | ||
![]() |
1f256f5391 | ||
![]() |
a299404c1b | ||
![]() |
72b47afe1e | ||
![]() |
ce744287b7 | ||
![]() |
9f14918a5a | ||
![]() |
11aacc8bd1 | ||
![]() |
01da118ae2 | ||
![]() |
94d968b7f7 | ||
![]() |
57c24a378b | ||
![]() |
fdea0f9267 | ||
![]() |
58364534e9 | ||
![]() |
bc10416921 | ||
![]() |
c30115270c | ||
![]() |
2c315e1ce7 | ||
![]() |
ff64bffed1 | ||
![]() |
34200e124b | ||
![]() |
20a6c8a79b | ||
![]() |
d2569fbe93 | ||
![]() |
bf76d31f6c | ||
![]() |
551c37101c | ||
![]() |
23f59994f8 | ||
![]() |
109c6b6f4f | ||
![]() |
fc6b3c841b | ||
![]() |
0b3e720b84 | ||
![]() |
7bcf46ac24 | ||
![]() |
0b31353707 | ||
![]() |
872f038e0b | ||
![]() |
b08cc03b22 | ||
![]() |
328c5ce28f | ||
![]() |
3e54ad6cac | ||
![]() |
7990d6d708 | ||
![]() |
95f32bf522 | ||
![]() |
95f98b0c41 | ||
![]() |
b0af7b2d2e | ||
![]() |
51f7507c86 | ||
![]() |
0965ae08a9 | ||
![]() |
2e6aade129 | ||
![]() |
7d29b5bbf0 | ||
![]() |
6666191087 | ||
![]() |
43b37e9b7e | ||
![]() |
6c53e5e46e | ||
![]() |
d178fca7df | ||
![]() |
230c3a6c5b | ||
![]() |
9b85e40cc6 | ||
![]() |
e38e2dcbba | ||
![]() |
a5d0a37b49 | ||
![]() |
808d103448 | ||
![]() |
30e0b8afa8 | ||
![]() |
da887624a4 | ||
![]() |
5eb8d57c09 | ||
![]() |
89493b1be0 | ||
![]() |
7ad1f0f105 | ||
![]() |
ffa78322a4 | ||
![]() |
ad9cf6da5d | ||
![]() |
a5a18bb80b | ||
![]() |
81764f4072 | ||
![]() |
327c871825 | ||
![]() |
4126450357 | ||
![]() |
8e81d7cded | ||
![]() |
94977c4028 | ||
![]() |
278f9d748a | ||
![]() |
d5f9d825aa | ||
![]() |
3a4eb3934d | ||
![]() |
d0b6aa2131 | ||
![]() |
310758fc7a | ||
![]() |
c1ab36765b | ||
![]() |
f24af60e42 | ||
![]() |
7d0bbde770 | ||
![]() |
efffcc135b | ||
![]() |
1b233673bb | ||
![]() |
07bde5f757 | ||
![]() |
ce174aed64 | ||
![]() |
cff33471cf | ||
![]() |
e211b33874 | ||
![]() |
05c149e84f | ||
![]() |
bf50899345 | ||
![]() |
b2f8339751 | ||
![]() |
e0435cd1a0 | ||
![]() |
d03bf4584c | ||
![]() |
e40f7b86df | ||
![]() |
3a8b8d4f71 | ||
![]() |
c38c925975 | ||
![]() |
d27ddd4739 | ||
![]() |
0aec65bb77 | ||
![]() |
671a3e4a04 | ||
![]() |
cbc4d3d251 | ||
![]() |
fe8cc5f97c | ||
![]() |
af3630ee22 | ||
![]() |
602260698d | ||
![]() |
ad27e8bcbb | ||
![]() |
d4ddc46c29 | ||
![]() |
ac29a7e86c | ||
![]() |
daa2dc7ee4 | ||
![]() |
1e822400d5 | ||
![]() |
57f7bb86d5 | ||
![]() |
ba65508bc9 | ||
![]() |
30e23d86d0 | ||
![]() |
7c79c78623 | ||
![]() |
caf28d82f7 | ||
![]() |
28ae1f71fb | ||
![]() |
bdea86b669 | ||
![]() |
2ec5a2cf70 | ||
![]() |
841d5eaedd | ||
![]() |
9ee4838edf | ||
![]() |
12203cbbe8 | ||
![]() |
e2ce496727 | ||
![]() |
4c11a63573 | ||
![]() |
725abe0123 | ||
![]() |
81c40a28df | ||
![]() |
2465b14c41 | ||
![]() |
d002c1076e | ||
![]() |
c3e5299489 | ||
![]() |
2d113619b3 | ||
![]() |
2fdd8600ad | ||
![]() |
dbc7a0636d | ||
![]() |
382fd19d57 | ||
![]() |
364ffb1dda | ||
![]() |
b787cedd82 | ||
![]() |
2dd7251e59 | ||
![]() |
b6574fdbfa | ||
![]() |
adcd9c09c3 | ||
![]() |
e8a6d1b229 | ||
![]() |
6d96fb56af | ||
![]() |
6fd94ebd5a | ||
![]() |
0c0027d11d | ||
![]() |
07d3c6b7c1 | ||
![]() |
8be14c8950 | ||
![]() |
2f13554ac3 | ||
![]() |
3d96c04300 | ||
![]() |
debcd26997 | ||
![]() |
96284ee8b7 | ||
![]() |
a1f5f8b1b0 | ||
![]() |
6ea9ef03b5 | ||
![]() |
663d7da0e7 | ||
![]() |
3432c9df7b | ||
![]() |
46d63d36ec | ||
![]() |
035b445a98 | ||
![]() |
ef2bde0f4a | ||
![]() |
b2e9530bc7 | ||
![]() |
bd65618ff5 | ||
![]() |
6420cf2823 | ||
![]() |
2f656df41c | ||
![]() |
83339bc156 | ||
![]() |
e464f894c6 | ||
![]() |
a5b31b013b | ||
![]() |
0dd7781663 | ||
![]() |
771b96b211 | ||
![]() |
aeda350995 | ||
![]() |
551f99d5d2 | ||
![]() |
2aa051f366 | ||
![]() |
7d95149519 | ||
![]() |
1c100fe50a | ||
![]() |
395ea51b28 | ||
![]() |
d327e9b0dd | ||
![]() |
5cbf98de49 | ||
![]() |
22444f8aa9 | ||
![]() |
cc5ccf062b | ||
![]() |
315f14ce58 | ||
![]() |
f9eaa6ae4d | ||
![]() |
2be6e0cc10 | ||
![]() |
5b444c36df | ||
![]() |
61fa9709f2 | ||
![]() |
45cc6b9dcd | ||
![]() |
e7293b3841 | ||
![]() |
69b0b5a26f | ||
![]() |
edb920dc05 | ||
![]() |
df9fdcbaf9 |
91
.github/dependabot.yml
vendored
91
.github/dependabot.yml
vendored
@@ -2,111 +2,104 @@
|
|||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/" # Location of package manifests
|
directory: "/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/arangodb/" # Location of package manifests
|
directory: "/arangodb/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/badger/" # Location of package manifests
|
directory: "/badger/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/dynamodb/" # Location of package manifests
|
directory: "/dynamodb/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "weekly"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/memcache/" # Location of package manifests
|
directory: "/memcache/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/memory/" # Location of package manifests
|
directory: "/memory/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/mongodb/" # Location of package manifests
|
directory: "/mongodb/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/mysql/" # Location of package manifests
|
directory: "/mysql/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/postgres/" # Location of package manifests
|
directory: "/postgres/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/redis/" # Location of package manifests
|
directory: "/redis/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/sqlite3/" # Location of package manifests
|
directory: "/sqlite3/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/ristretto/" # Location of package manifests
|
directory: "/ristretto/" # Location of package manifests
|
||||||
default_labels:
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/s3/" # Location of package manifests
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/bbolt/" # Location of package manifests
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/azureblob/" # Location of package manifests
|
||||||
|
labels:
|
||||||
|
- "🤖 Dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
directory: "/mssql/" # Location of package manifests
|
||||||
|
labels:
|
||||||
- "🤖 Dependencies"
|
- "🤖 Dependencies"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
automerged_updates:
|
|
||||||
- match:
|
|
||||||
dependency_name: "gofiber/fiber/*"
|
|
||||||
|
3
.github/release-drafter.yml
vendored
3
.github/release-drafter.yml
vendored
@@ -16,6 +16,7 @@ categories:
|
|||||||
- '📒 Documentation'
|
- '📒 Documentation'
|
||||||
change-template: '- $TITLE (#$NUMBER)'
|
change-template: '- $TITLE (#$NUMBER)'
|
||||||
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||||
|
sort-by: 'title'
|
||||||
version-resolver:
|
version-resolver:
|
||||||
major:
|
major:
|
||||||
labels:
|
labels:
|
||||||
@@ -90,4 +91,6 @@ autolabeler:
|
|||||||
template: |
|
template: |
|
||||||
$CHANGES
|
$CHANGES
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
||||||
|
|
||||||
Thank you $CONTRIBUTORS for making this update possible.
|
Thank you $CONTRIBUTORS for making this update possible.
|
||||||
|
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
# We must fetch at least the immediate parents so that if this is
|
# We must fetch at least the immediate parents so that if this is
|
||||||
# a pull request then we can checkout the head.
|
# a pull request then we can checkout the head.
|
||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v2
|
||||||
# Override language selection by uncommenting this and choosing your languages
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
with:
|
with:
|
||||||
languages: go
|
languages: go
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -51,4 +51,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
||||||
|
41
.github/workflows/dependabot_automerge.yml
vendored
Normal file
41
.github/workflows/dependabot_automerge.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Dependabot auto-merge
|
||||||
|
on:
|
||||||
|
pull_request
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
wait_for_checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||||
|
steps:
|
||||||
|
- name: Wait for check is finished
|
||||||
|
uses: lewagon/wait-on-check-action@v1.2.0
|
||||||
|
id: wait_for_checks
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||||
|
running-workflow-name: wait_for_checks
|
||||||
|
check-regexp: Tests
|
||||||
|
repo-token: ${{ secrets.PR_TOKEN }}
|
||||||
|
wait-interval: 10
|
||||||
|
dependabot:
|
||||||
|
needs: [wait_for_checks]
|
||||||
|
name: Dependabot auto-merge
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||||
|
steps:
|
||||||
|
- name: Dependabot metadata
|
||||||
|
id: metadata
|
||||||
|
uses: dependabot/fetch-metadata@v1.3.5
|
||||||
|
with:
|
||||||
|
github-token: "${{ secrets.PR_TOKEN }}"
|
||||||
|
- name: Enable auto-merge for Dependabot PRs
|
||||||
|
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
|
||||||
|
run: |
|
||||||
|
gh pr review --approve "$PR_URL"
|
||||||
|
gh pr merge --auto --merge "$PR_URL"
|
||||||
|
env:
|
||||||
|
PR_URL: ${{github.event.pull_request.html_url}}
|
||||||
|
GITHUB_TOKEN: ${{secrets.PR_TOKEN}}
|
11
.github/workflows/linter.yml
vendored
11
.github/workflows/linter.yml
vendored
@@ -1,12 +1,17 @@
|
|||||||
on: [push, pull_request]
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
name: Linter
|
name: Linter
|
||||||
jobs:
|
jobs:
|
||||||
Golint:
|
Golint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Golint
|
- name: Run Golint
|
||||||
uses: reviewdog/action-golangci-lint@v1
|
uses: reviewdog/action-golangci-lint@v2
|
||||||
with:
|
with:
|
||||||
golangci_lint_flags: "--tests=false"
|
golangci_lint_flags: "--tests=false"
|
||||||
|
31
.github/workflows/security.yml
vendored
31
.github/workflows/security.yml
vendored
@@ -1,22 +1,27 @@
|
|||||||
on: [ push, pull_request ]
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
name: Security
|
name: Security
|
||||||
jobs:
|
jobs:
|
||||||
Gosec:
|
Gosec:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '^1.17.6'
|
go-version: '^1.17.6'
|
||||||
- name: Install Gosec
|
- name: Install Gosec
|
||||||
run: |
|
run: |
|
||||||
export PATH=${PATH}:`go env GOPATH`/bin
|
export PATH=${PATH}:`go env GOPATH`/bin
|
||||||
go get -u github.com/securego/gosec/v2/cmd/gosec
|
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||||
- name: Run Gosec (root)
|
- name: Run Gosec (root)
|
||||||
working-directory: .
|
working-directory: .
|
||||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal -exclude-dir=arangodb -exclude-dir=badger -exclude-dir=dynamodb -exclude-dir=memcache -exclude-dir=memory -exclude-dir=mongodb -exclude-dir=mysql -exclude-dir=postgres -exclude-dir=redis -exclude-dir=ristretto -exclude-dir=sqlite3 ./..."
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal -exclude-dir=arangodb -exclude-dir=badger -exclude-dir=dynamodb -exclude-dir=memcache -exclude-dir=memory -exclude-dir=mongodb -exclude-dir=mysql -exclude-dir=postgres -exclude-dir=redis -exclude-dir=ristretto -exclude-dir=sqlite3 -exclude-dir=s3 -exclude-dir=bbolt -exclude-dir=azureblob -exclude-dir=mssql ./..."
|
||||||
# -----
|
# -----
|
||||||
- name: Run Gosec (arangodb)
|
- name: Run Gosec (arangodb)
|
||||||
working-directory: ./arangodb
|
working-directory: ./arangodb
|
||||||
@@ -58,7 +63,23 @@ jobs:
|
|||||||
working-directory: ./sqlite3
|
working-directory: ./sqlite3
|
||||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||||
# -----
|
# -----
|
||||||
|
- name: Run Gosec (s3)
|
||||||
|
working-directory: ./s3
|
||||||
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||||
|
# -----
|
||||||
- name: Run Gosec (ristretto)
|
- name: Run Gosec (ristretto)
|
||||||
working-directory: ./ristretto
|
working-directory: ./ristretto
|
||||||
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||||
# -----
|
# -----
|
||||||
|
- name: Run Gosec (bbolt)
|
||||||
|
working-directory: ./bbolt
|
||||||
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||||
|
# -----
|
||||||
|
- name: Run Gosec (azureblob)
|
||||||
|
working-directory: ./azureblob
|
||||||
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||||
|
# -----
|
||||||
|
- name: Run Gosec (mssql)
|
||||||
|
working-directory: ./mssql
|
||||||
|
run: "`go env GOPATH`/bin/gosec -exclude-dir=internal ./..."
|
||||||
|
# -----
|
||||||
|
36
.github/workflows/test-arangodb.yml
vendored
36
.github/workflows/test-arangodb.yml
vendored
@@ -1,7 +1,10 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: ArangoDB
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests ArangoDB"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -15,19 +18,34 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./arangodb && go test ./... -v -race
|
run: cd ./arangodb && go test ./... -v -race
|
||||||
|
46
.github/workflows/test-azureblob.yml
vendored
Normal file
46
.github/workflows/test-azureblob.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Azure Blob"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
- 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 Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./azureblob && go test ./... -v -race
|
44
.github/workflows/test-badger.yml
vendored
Normal file
44
.github/workflows/test-badger.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Badger"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
runs-on: '${{ matrix.platform }}'
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Test Badger
|
||||||
|
run: cd ./badger && go test ./... -v -race
|
43
.github/workflows/test-bbolt.yml
vendored
Normal file
43
.github/workflows/test-bbolt.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Bbolt"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./bbolt && go mod tidy && go test ./... -v -race
|
49
.github/workflows/test-dynamodb.yml
vendored
Normal file
49
.github/workflows/test-dynamodb.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests DynamoDB"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mongo:
|
||||||
|
image: 'amazon/dynamodb-local:latest'
|
||||||
|
ports:
|
||||||
|
- '8000:8000'
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.16.x
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./dynamodb && go test ./... -v -race
|
36
.github/workflows/test-memcache.yml
vendored
36
.github/workflows/test-memcache.yml
vendored
@@ -1,7 +1,10 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Memcache
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Memcache"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -13,19 +16,34 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./memcache && go test ./... -v -race
|
run: cd ./memcache && go test ./... -v -race
|
||||||
|
36
.github/workflows/test-mongodb.yml
vendored
36
.github/workflows/test-mongodb.yml
vendored
@@ -1,7 +1,10 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: MongoDB
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Mongodb"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -13,19 +16,34 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./mongodb && go test ./... -v -race
|
run: cd ./mongodb && go test ./... -v -race
|
||||||
|
65
.github/workflows/test-mssql.yml
vendored
Normal file
65
.github/workflows/test-mssql.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests MSSQL"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mssql:
|
||||||
|
image: 'mcmoe/mssqldocker:v2019.CU4.0'
|
||||||
|
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
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.16.x
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./mssql && go test ./... -v -race
|
||||||
|
env:
|
||||||
|
MSSQL_DATABASE: master
|
||||||
|
MSSQL_USERNAME: sa
|
||||||
|
MSSQL_PASSWORD: MsSql!1234
|
36
.github/workflows/test-mysql.yml
vendored
36
.github/workflows/test-mysql.yml
vendored
@@ -1,7 +1,10 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: MySQL
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests MySQL"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -21,20 +24,35 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./mysql && go test ./... -v -race
|
run: cd ./mysql && go test ./... -v -race
|
||||||
env:
|
env:
|
||||||
|
36
.github/workflows/test-postgres.yml
vendored
36
.github/workflows/test-postgres.yml
vendored
@@ -1,7 +1,10 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Postgres
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Postgres"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -20,20 +23,35 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./postgres && go test ./... -v -race
|
run: cd ./postgres && go test ./... -v -race
|
||||||
env:
|
env:
|
||||||
|
39
.github/workflows/test-redis.yml
vendored
39
.github/workflows/test-redis.yml
vendored
@@ -1,28 +1,30 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Redis
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Redis"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Redis
|
- name: Setup Redis
|
||||||
uses: shogo82148/actions-setup-redis@v1
|
uses: shogo82148/actions-setup-redis@v1
|
||||||
with:
|
with:
|
||||||
redis-version: 'latest'
|
redis-version: '6.x'
|
||||||
auto-start: 'false'
|
auto-start: 'false'
|
||||||
redis-port: '6379'
|
redis-port: '6379'
|
||||||
redis-tls-port: '6380'
|
redis-tls-port: '6380'
|
||||||
@@ -35,9 +37,26 @@ jobs:
|
|||||||
--tls-ca-cert-file ./redis/tests/tls/ca.crt&
|
--tls-ca-cert-file ./redis/tests/tls/ca.crt&
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./redis && go test ./... -v -race
|
run: cd ./redis && go test ./... -v -race
|
||||||
|
35
.github/workflows/test-ristretto.yml
vendored
35
.github/workflows/test-ristretto.yml
vendored
@@ -1,24 +1,43 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Ristretto
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Ristretto"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.16.x
|
- 1.18.x
|
||||||
- 1.17.x
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Run Test
|
- name: Run Test
|
||||||
run: cd ./ristretto && go mod tidy && go test ./... -v -race
|
run: cd ./ristretto && go mod tidy && go test ./... -v -race
|
||||||
|
53
.github/workflows/test-s3.yml
vendored
Normal file
53
.github/workflows/test-s3.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests S3"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.16.x
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Install MinIO
|
||||||
|
run: |
|
||||||
|
docker run -d -p 9000:9000 --name minio minio/minio server /data
|
||||||
|
|
||||||
|
export AWS_ACCESS_KEY_ID=minioadmin
|
||||||
|
export AWS_SECRET_ACCESS_KEY=minioadmin
|
||||||
|
export AWS_EC2_METADATA_DISABLED=true
|
||||||
|
|
||||||
|
aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://testbucket
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run Test
|
||||||
|
run: cd ./s3 && go test ./... -v -race
|
49
.github/workflows/test-sqlite3.yml
vendored
Normal file
49
.github/workflows/test-sqlite3.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Sqlite3"
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version:
|
||||||
|
- 1.16.x
|
||||||
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
|
platform:
|
||||||
|
- ubuntu-latest
|
||||||
|
- windows-latest
|
||||||
|
runs-on: '${{ matrix.platform }}'
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Test SQLite3 - with -race check
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
run: cd ./sqlite3 && go test ./... -v -race
|
||||||
|
- name: Test SQLite3 - without -race check
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
run: cd ./sqlite3 && go test ./... -v
|
41
.github/workflows/test.yml
vendored
41
.github/workflows/test.yml
vendored
@@ -1,30 +1,45 @@
|
|||||||
'on':
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
name: Local Storage
|
- master
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
name: "Tests Local Storage"
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
Tests:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.14.x
|
|
||||||
- 1.15.x
|
|
||||||
- 1.16.x
|
- 1.16.x
|
||||||
- 1.17.x
|
- 1.18.x
|
||||||
|
- 1.19.x
|
||||||
platform:
|
platform:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
runs-on: '${{ matrix.platform }}'
|
runs-on: '${{ matrix.platform }}'
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '${{ matrix.go-version }}'
|
go-version: '${{ matrix.go-version }}'
|
||||||
|
- name: Setup Golang caches
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
# In order:
|
||||||
|
# * Module download cache
|
||||||
|
# * Build cache (Linux)
|
||||||
|
# * Build cache (Mac)
|
||||||
|
# * Build cache (Windows)
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
~\AppData\Local\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||||
|
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Test Badger
|
|
||||||
run: cd ./badger && go test ./... -v -race
|
|
||||||
- name: Test Memory
|
- name: Test Memory
|
||||||
run: cd ./memory && go test ./... -v -race
|
run: cd ./memory && go test ./... -v -race
|
||||||
- name: Test SQLite3
|
|
||||||
run: cd ./sqlite3 && go test ./... -v -race
|
|
||||||
|
19
.github/workflows/vulncheck.yml
vendored
Normal file
19
.github/workflows/vulncheck.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
on: [push, pull_request_target]
|
||||||
|
name: Vulnerability Check
|
||||||
|
jobs:
|
||||||
|
Security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19.x
|
||||||
|
- name: Fetch Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Install Govulncheck
|
||||||
|
run: |
|
||||||
|
export GO111MODULE=on
|
||||||
|
export PATH=${PATH}:`go env GOPATH`/bin
|
||||||
|
go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
|
- name: Run Govulncheck
|
||||||
|
run: "`go env GOPATH`/bin/govulncheck ./..."
|
53
README.md
53
README.md
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<!-- <a href="https://gofiber.io">
|
<!-- <a href="https://gofiber.io">
|
||||||
<img alt="Fiber" height="125" src="https://raw.githubusercontent.com/gofiber/docs/master/static/fiber_v2_logo.svg">
|
<img alt="Fiber" height="125" src="https://raw.githubusercontent.com/gofiber/docs/master/static/fiber_v2_logo.svg">
|
||||||
@@ -51,33 +50,45 @@ type Storage interface {
|
|||||||
|
|
||||||
## 📑 Storage Implementations
|
## 📑 Storage Implementations
|
||||||
|
|
||||||
* [ArangoDB](/arangodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22ArangoDB%22">
|
* [ArangoDB](/arangodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+ArangoDB%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/ArangoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20ArangoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [Badger](/badger) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
* [AzureBlob](/azureblob) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Azure+Blob%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Azure%20Blob?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [DynamoDB](/dynamodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22DynamoDB%22">
|
* [Badger](/badger) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Badger%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/DynamoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Badger?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [Memcache](/memcache) <a href="https://github.com/gofiber/storage/actions?query=workflow%3AMemcache">
|
* [Bbolt](/bbolt) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Bbolt%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Memcache?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Bbolt?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [Memory](/memory) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
* [DynamoDB](/dynamodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+DynamoDB%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20DynamoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [MongoDB](/mongodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3AMongoDB">
|
* [Memcache](/memcache) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Memcache%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/MongoDB?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Memcache?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [MySQL](/mysql) <a href="https://github.com/gofiber/storage/actions?query=workflow%3AMySQL">
|
* [Memory](/memory) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Local+Storage%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/MySQL?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [Postgres](/postgres) <a href="https://github.com/gofiber/storage/actions?query=workflow%3APostgres">
|
* [MongoDB](/mongodb) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Mongodb%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Postgres?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Mongodb?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [Redis](/redis) <a href="https://github.com/gofiber/storage/actions?query=workflow%3ARedis">
|
* [MSSQL](/mssql) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MSSQL%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Redis?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20MSSQL?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
* [SQLite3](/sqlite3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Local+Storage%22">
|
* [MySQL](/mysql) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MySQL%22">
|
||||||
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Local%20Storage?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20MySQL?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
|
</a>
|
||||||
|
* [Postgres](/postgres) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Postgres%22">
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Postgres?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
|
</a>
|
||||||
|
* [Redis](/redis) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Redis%22">
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Redis?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
|
</a>
|
||||||
|
* [SQLite3](/sqlite3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Sqlite3%22">
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20Sqlite3?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
|
</a>
|
||||||
|
* [S3](/s3) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+S3%22">
|
||||||
|
<img src="https://img.shields.io/github/workflow/status/gofiber/storage/Tests%20S3?label=%F0%9F%A7%AA%20&style=flat&color=75C46B">
|
||||||
</a>
|
</a>
|
||||||
|
@@ -16,6 +16,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() driver.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
ArangoDB is tested on the 2 last (1.14/1.15) [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
ArangoDB is tested on the 2 last (1.14/1.15) [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
|
@@ -246,3 +246,8 @@ func (s *Storage) gc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() driver.Client {
|
||||||
|
return s.client
|
||||||
|
}
|
||||||
|
@@ -132,3 +132,7 @@ func Test_ARANGODB_Non_UTF8(t *testing.T) {
|
|||||||
func Test_ARANGODB_Close(t *testing.T) {
|
func Test_ARANGODB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ARANGODB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
module github.com/gofiber/storage/arangodb
|
module github.com/gofiber/storage/arangodb
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/arangodb/go-driver v1.2.1
|
github.com/arangodb/go-driver v1.4.0
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v1.0.1
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
github.com/arangodb/go-driver v1.2.1 h1:HREDHhDmzdIWxHmfkfTESbYUnRjESjPh4WUuXq7FZa8=
|
github.com/arangodb/go-driver v1.4.0 h1:uNCbVYkr5ZP3hIVUP6wqjOVyhMYOL9NDmR762tIeYP0=
|
||||||
github.com/arangodb/go-driver v1.2.1/go.mod h1:zdDkJJnCj8DAkfbtIjIXnsTrWIiy6VhP3Vy14p+uQeY=
|
github.com/arangodb/go-driver v1.4.0/go.mod h1:5GAx3XvK72DJPhJgyjZOtYAGc4SpY7rZDb3LyhCvLcQ=
|
||||||
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g=
|
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g=
|
||||||
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
|
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho=
|
||||||
github.com/coreos/go-iptables v0.4.3/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
|
github.com/coreos/go-iptables v0.4.3/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
|
||||||
@@ -7,8 +7,8 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
|
|||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4=
|
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4=
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
@@ -33,7 +33,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
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/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
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/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.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
103
azureblob/README.md
Normal file
103
azureblob/README.md
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
# Azure blob
|
||||||
|
|
||||||
|
[Azure Blob storage](https://azure.microsoft.com/en-us/products/storage/blobs/#overview) is Microsoft's object storage solution for the cloud.
|
||||||
|
|
||||||
|
> NOTE: Go **1.18** or later is required. Source: [link](https://github.com/Azure/azure-sdk-for-go/blob/main/README.md)
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
|
||||||
|
- [Signatures](#signatures)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Config](#config)
|
||||||
|
- [Default Config](#default-config)
|
||||||
|
|
||||||
|
### Signatures
|
||||||
|
|
||||||
|
```go
|
||||||
|
func New(config ...Config) Storage
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error)
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||||
|
func (s *Storage) Delete(key string) error
|
||||||
|
func (s *Storage) Reset() error
|
||||||
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *azblob.Client
|
||||||
|
```
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
Azure blob storage driver is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go mod init github.com/<user>/<repo>
|
||||||
|
```
|
||||||
|
|
||||||
|
And then install the azure blob implementation:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go get github.com/gofiber/storage/azureblob
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
Import the storage package.
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "github.com/gofiber/storage/azureblob"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use the following possibilities to create a storage:
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Initialize default config
|
||||||
|
store := azureblob.New()
|
||||||
|
|
||||||
|
// Initialize custom config
|
||||||
|
store := azureblob.New(azureblob.Config{
|
||||||
|
Account: "test",
|
||||||
|
Container: "test",
|
||||||
|
Credentials: Credentials{
|
||||||
|
Account: "test",
|
||||||
|
Key: "YXp1cml0ZWtleQo=",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Config struct {
|
||||||
|
// Storage account name.
|
||||||
|
Account string
|
||||||
|
// Container name.
|
||||||
|
Container string
|
||||||
|
// Storage endpoint.
|
||||||
|
// Optional. Default: "https://STORAGEACCOUNTNAME.blob.core.windows.net"
|
||||||
|
Endpoint string
|
||||||
|
// Request timeout.
|
||||||
|
// Optional. Default is 0 (no timeout)
|
||||||
|
RequestTimeout time.Duration
|
||||||
|
// Reset clears any existing keys in existing container.
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||||
|
// Optional. Default is Credentials{}
|
||||||
|
Credentials Credentials
|
||||||
|
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||||
|
// Optional. Default is 3
|
||||||
|
MaxAttempts int
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default Config
|
||||||
|
|
||||||
|
```go
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
Account: "",
|
||||||
|
Container: "",
|
||||||
|
Endpoint: "",
|
||||||
|
RequestTimeout: 0,
|
||||||
|
Reset: false,
|
||||||
|
MaxAttempts: 3,
|
||||||
|
}
|
||||||
|
```
|
138
azureblob/azureblob.go
Normal file
138
azureblob/azureblob.go
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
package azureblob
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror"
|
||||||
|
"io"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Storage interface that is implemented by storage providers
|
||||||
|
type Storage struct {
|
||||||
|
client *azblob.Client
|
||||||
|
container string
|
||||||
|
requestTimeout time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new storage
|
||||||
|
func New(config ...Config) *Storage {
|
||||||
|
// Set default config
|
||||||
|
cfg := configure(config...)
|
||||||
|
// Set the azure credentials
|
||||||
|
cred, err := azblob.NewSharedKeyCredential(cfg.Credentials.Account, cfg.Credentials.Key)
|
||||||
|
handleError(err)
|
||||||
|
client, err := azblob.NewClientWithSharedKeyCredential(cfg.Endpoint, cred, nil)
|
||||||
|
handleError(err)
|
||||||
|
_, err = client.CreateContainer(context.TODO(), cfg.Container, nil)
|
||||||
|
if err != nil {
|
||||||
|
if !bloberror.HasCode(err, bloberror.ContainerAlreadyExists) {
|
||||||
|
panic(fmt.Sprintf("invalid config:, %v", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
storage := &Storage{
|
||||||
|
client: client,
|
||||||
|
container: cfg.Container,
|
||||||
|
requestTimeout: cfg.RequestTimeout,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset all entries if set to true
|
||||||
|
if cfg.Reset {
|
||||||
|
if err := storage.Reset(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get value by key
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
resp, err := s.client.DownloadStream(ctx, s.container, key, nil)
|
||||||
|
if err != nil {
|
||||||
|
return []byte{}, err
|
||||||
|
}
|
||||||
|
data, err := io.ReadAll(resp.Body)
|
||||||
|
return data, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set key with value
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
_, err := s.client.UploadBuffer(ctx, s.container, key, val, nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete entry by key
|
||||||
|
func (s *Storage) Delete(key string) error {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
_, err := s.client.DeleteBlob(ctx, s.container, key, nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset all entries
|
||||||
|
func (s *Storage) Reset() error {
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
//_, err := s.client.DeleteContainer(ctx, s.container, nil)
|
||||||
|
//return err
|
||||||
|
pager := s.client.NewListBlobsFlatPager(s.container, nil)
|
||||||
|
errCounter := 0
|
||||||
|
for pager.More() {
|
||||||
|
resp, err := pager.NextPage(ctx)
|
||||||
|
if err != nil {
|
||||||
|
errCounter = errCounter + 1
|
||||||
|
}
|
||||||
|
for _, v := range resp.Segment.BlobItems {
|
||||||
|
_, err = s.client.DeleteBlob(ctx, s.container, *v.Name, nil)
|
||||||
|
if err != nil {
|
||||||
|
errCounter = errCounter + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errCounter > 0 {
|
||||||
|
return errors.New(fmt.Sprintf("%d errors occured while resetting", errCounter))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conn returns storage client
|
||||||
|
func (s *Storage) Conn() *azblob.Client {
|
||||||
|
return s.client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the storage connextion
|
||||||
|
func (s *Storage) Close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Context for making requests will timeout if a non-zero timeout is configured
|
||||||
|
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
||||||
|
if s.requestTimeout > 0 {
|
||||||
|
return context.WithTimeout(context.Background(), s.requestTimeout)
|
||||||
|
}
|
||||||
|
return context.Background(), func() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleError is a helper to panic on error
|
||||||
|
func handleError(err error) {
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("invalid config:, %v", err))
|
||||||
|
}
|
||||||
|
}
|
137
azureblob/azureblob_test.go
Normal file
137
azureblob/azureblob_test.go
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
package azureblob
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror"
|
||||||
|
"github.com/gofiber/fiber/v2/utils"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newStore() *Storage {
|
||||||
|
return New(Config{
|
||||||
|
Account: "devstoreaccount1",
|
||||||
|
Container: "test",
|
||||||
|
Endpoint: "http://127.0.0.1:10000/devstoreaccount1",
|
||||||
|
Credentials: Credentials{
|
||||||
|
Account: "devstoreaccount1",
|
||||||
|
Key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func Test_AzureBlob_Get(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
testStore := newStore()
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, val, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_AzureBlob_Set(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
testStore := newStore()
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_AzureBlob_Delete(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
testStore := newStore()
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Delete(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
if err != nil {
|
||||||
|
if bloberror.HasCode(err, bloberror.BlobNotFound) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_AzureBlob_Override(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
testStore := newStore()
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_AzureBlob_Get_NotExist(t *testing.T) {
|
||||||
|
testStore := newStore()
|
||||||
|
result, err := testStore.Get("notexist")
|
||||||
|
if err != nil {
|
||||||
|
if bloberror.HasCode(err, bloberror.BlobNotFound) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_AzureBlob_Reset(t *testing.T) {
|
||||||
|
var (
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
testStore := newStore()
|
||||||
|
|
||||||
|
err := testStore.Set("john1", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set("john2", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Reset()
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get("john1")
|
||||||
|
if err != nil {
|
||||||
|
if bloberror.HasCode(err, bloberror.BlobNotFound) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
|
||||||
|
result, err = testStore.Get("john2")
|
||||||
|
if err != nil {
|
||||||
|
if bloberror.HasCode(err, bloberror.BlobNotFound) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_S3_Conn(t *testing.T) {
|
||||||
|
testStore := newStore()
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_AzureBlob_Close(t *testing.T) {
|
||||||
|
testStore := newStore()
|
||||||
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
|
}
|
80
azureblob/config.go
Normal file
80
azureblob/config.go
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package azureblob
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Storage account name.
|
||||||
|
Account string
|
||||||
|
// Container name.
|
||||||
|
Container string
|
||||||
|
// Storage endpoint.
|
||||||
|
// Optional. Default: "https://STORAGEACCOUNTNAME.blob.core.windows.net"
|
||||||
|
Endpoint string
|
||||||
|
// Request timeout.
|
||||||
|
// Optional. Default is 0 (no timeout)
|
||||||
|
RequestTimeout time.Duration
|
||||||
|
// Reset clears any existing keys in existing container.
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||||
|
// Optional. Default is Credentials{}
|
||||||
|
Credentials Credentials
|
||||||
|
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||||
|
// Optional. Default is 3
|
||||||
|
MaxAttempts int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Credentials are the azure storage account access keys
|
||||||
|
type Credentials struct {
|
||||||
|
Account string
|
||||||
|
Key string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigDefault is the default config
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
Account: "",
|
||||||
|
Container: "",
|
||||||
|
Endpoint: "",
|
||||||
|
RequestTimeout: 0,
|
||||||
|
Reset: false,
|
||||||
|
MaxAttempts: 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to set default values
|
||||||
|
func configure(config ...Config) Config {
|
||||||
|
// Return default config if nothing provided
|
||||||
|
if len(config) < 1 {
|
||||||
|
return ConfigDefault
|
||||||
|
}
|
||||||
|
// Override default config
|
||||||
|
cfg := config[0]
|
||||||
|
valid, err := validateConfig(cfg)
|
||||||
|
if err != nil || !valid {
|
||||||
|
panic(fmt.Sprintf("invalid config:, %v", err))
|
||||||
|
}
|
||||||
|
if cfg.Endpoint == "" {
|
||||||
|
cfg.Endpoint = "https://" + cfg.Account + ".blob.core.windows.net"
|
||||||
|
}
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateConfig(config Config) (bool, error) {
|
||||||
|
if config.Credentials.Account == "" || config.Credentials.Key == "" {
|
||||||
|
err := errors.New("credentials must not be empty")
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if config.Account == "" || config.Container == "" {
|
||||||
|
err := errors.New("invalid account information provided")
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if config.Account != config.Credentials.Account {
|
||||||
|
err := errors.New("account configuration mismatch")
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
16
azureblob/go.mod
Normal file
16
azureblob/go.mod
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
module github.com/gofiber/storage/azureblob
|
||||||
|
|
||||||
|
go 1.18
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1
|
||||||
|
github.com/gofiber/fiber/v2 v2.40.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 // indirect
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 // indirect
|
||||||
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
|
golang.org/x/net v0.2.0 // indirect
|
||||||
|
golang.org/x/text v0.4.0 // indirect
|
||||||
|
)
|
27
azureblob/go.sum
Normal file
27
azureblob/go.sum
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 h1:sVW/AFBTGyJxDaMYlq0ct3jUXTtj12tQ6zE2GZUgVQw=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 h1:Oj853U9kG+RLTCQXpjvOnrv0WaZHxgmZz1TlLywgOPY=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1 h1:BMTdr+ib5ljLa9MxTJK8x/Ds0MbBb4MfuW5BL0zMJnI=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1/go.mod h1:c6WvOhtmjNUWbLfOG1qxM/q0SPvQNSVJvolm+C52dIU=
|
||||||
|
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c=
|
||||||
|
github.com/gofiber/fiber/v2 v2.40.0 h1:fdU7w5hT6PLL7jiWIhtQ+S/k5WEFYoUZidptlPu8GBo=
|
||||||
|
github.com/gofiber/fiber/v2 v2.40.0/go.mod h1:Gko04sLksnHbzLSRBFWPFdzM9Ws9pRxvvIaohJK1dsk=
|
||||||
|
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
|
||||||
|
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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
|
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||||
|
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw=
|
||||||
|
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
|
||||||
|
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
|
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||||
|
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||||
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
@@ -19,6 +19,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *badger.DB
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -123,3 +123,8 @@ func (s *Storage) gc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *badger.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -119,3 +119,7 @@ func Test_Badger_Reset(t *testing.T) {
|
|||||||
func Test_Badger_Close(t *testing.T) {
|
func Test_Badger_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Badger_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
@@ -1,20 +1,27 @@
|
|||||||
module github.com/gofiber/storage/badger
|
module github.com/gofiber/storage/badger
|
||||||
|
|
||||||
go 1.14
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/dgraph-io/badger/v3 v3.2103.4
|
||||||
|
github.com/gofiber/utils v1.0.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/cespare/xxhash v1.1.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
github.com/dgraph-io/badger/v3 v3.2103.2
|
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/glog v1.0.0 // indirect
|
github.com/golang/glog v1.0.0 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/flatbuffers v2.0.5+incompatible // indirect
|
github.com/google/flatbuffers v22.10.26+incompatible // indirect
|
||||||
github.com/klauspost/compress v1.13.6 // indirect
|
github.com/klauspost/compress v1.15.12 // indirect
|
||||||
github.com/kr/pretty v0.2.0 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
go.opencensus.io v0.23.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d // indirect
|
golang.org/x/net v0.2.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
golang.org/x/sys v0.2.0 // indirect
|
||||||
google.golang.org/protobuf v1.27.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
)
|
)
|
||||||
|
@@ -18,10 +18,10 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.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/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8=
|
github.com/dgraph-io/badger/v3 v3.2103.4 h1:WE1B07YNTTJTtG9xjBcSW2wn0RJLyiV99h959RKZqM4=
|
||||||
github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M=
|
github.com/dgraph-io/badger/v3 v3.2103.4/go.mod h1:4MPiseMeDQ3FNCYwRbbcBOGJLf5jsE0PPFzRiKjtcdw=
|
||||||
github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI=
|
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
|
||||||
github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=
|
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
|
||||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||||
@@ -31,8 +31,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
|
|||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
@@ -60,8 +60,8 @@ github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
|
|||||||
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/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||||
github.com/google/flatbuffers v2.0.5+incompatible h1:ANsW0idDAXIY+mNHzIHxWRfabV2x5LUEEIIWcwsYgB8=
|
github.com/google/flatbuffers v22.10.26+incompatible h1:z1QiaMyPu1x3Z6xf2u1dsLj1ZxicdGSeaLpCuIsQNZM=
|
||||||
github.com/google/flatbuffers v2.0.5+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
github.com/google/flatbuffers v22.10.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
@@ -77,13 +77,10 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
|
|||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM=
|
||||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
|
||||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
@@ -105,17 +102,21 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
|
|||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/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.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.6.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 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.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.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||||
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
|
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
@@ -135,8 +136,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.0.0-20220107192237-5cfca573fb4d h1:62NvYBuaanGXR2ZOfwDFkhhl6X1DUgf8qg3GuQvxZsE=
|
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
|
||||||
golang.org/x/net v0.0.0-20220107192237-5cfca573fb4d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
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=
|
||||||
@@ -150,15 +151,11 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
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-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-20201119102817-f84b799fce68/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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.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.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
@@ -195,13 +192,13 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
|
|||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-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.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.28.1/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 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
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=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
93
bbolt/README.md
Normal file
93
bbolt/README.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Bbolt
|
||||||
|
A Bbolt storage driver using [etcd-io/bbolt](https://github.com/etcd-io/bbolt). Bolt is a pure Go key/value store inspired by [Howard Chu's](https://twitter.com/hyc_symas) [LMDB project](https://www.symas.com/symas-embedded-database-lmdb). The goal of the project is to provide a simple, fast, and reliable database for projects that don't require a full database server such as Postgres or MySQL.
|
||||||
|
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
- [Signatures](#signatures)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Config](#config)
|
||||||
|
- [Default Config](#default-config)
|
||||||
|
|
||||||
|
### Signatures
|
||||||
|
```go
|
||||||
|
func New(config ...Config) Storage
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error)
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||||
|
func (s *Storage) Delete(key string) error
|
||||||
|
func (s *Storage) Reset() error
|
||||||
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *bbolt.DB
|
||||||
|
```
|
||||||
|
### Installation
|
||||||
|
Bbolt is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
|
```bash
|
||||||
|
go mod init github.com/<user>/<repo>
|
||||||
|
```
|
||||||
|
And then install the s3 implementation:
|
||||||
|
```bash
|
||||||
|
go get github.com/gofiber/storage/bbolt
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
Import the storage package.
|
||||||
|
```go
|
||||||
|
import "github.com/gofiber/storage/bbolt"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use the following possibilities to create a storage:
|
||||||
|
```go
|
||||||
|
// Initialize default config
|
||||||
|
store := bbolt.New()
|
||||||
|
|
||||||
|
// Initialize custom config
|
||||||
|
store := bbolt.New(bbolt.Config{
|
||||||
|
Database: "my_database.db",
|
||||||
|
Bucket: "my-bucket",
|
||||||
|
Reset: false,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Config
|
||||||
|
```go
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Database path
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber.db"
|
||||||
|
Database string
|
||||||
|
|
||||||
|
// Bbolt bucket name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber_storage"
|
||||||
|
Bucket string
|
||||||
|
|
||||||
|
// Timeout is the amount of time to wait to obtain a file lock.
|
||||||
|
// Only available on Darwin and Linux.
|
||||||
|
//
|
||||||
|
// Optional. Default is 60 * time.Second.
|
||||||
|
Timeout time.Duration
|
||||||
|
|
||||||
|
// Open database in read-only mode.
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
ReadOnly bool
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Bucket
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default Config
|
||||||
|
```go
|
||||||
|
// ConfigDefault is the default config
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
Database: "fiber.db",
|
||||||
|
Bucket: "fiber_storage",
|
||||||
|
Timeout: 60 * time.Second,
|
||||||
|
ReadOnly: false,
|
||||||
|
Reset: false,
|
||||||
|
}
|
||||||
|
```
|
111
bbolt/bbolt.go
Normal file
111
bbolt/bbolt.go
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
package bbolt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
"go.etcd.io/bbolt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Storage interface that is implemented by storage providers
|
||||||
|
type Storage struct {
|
||||||
|
conn *bbolt.DB
|
||||||
|
bucket string
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new storage
|
||||||
|
func New(config ...Config) *Storage {
|
||||||
|
// Set default config
|
||||||
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
|
conn, err := bbolt.Open(cfg.Database, 0666, &bbolt.Options{
|
||||||
|
Timeout: cfg.Timeout,
|
||||||
|
ReadOnly: cfg.ReadOnly,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset bucket if field selected
|
||||||
|
if cfg.Reset {
|
||||||
|
if err := removeBucket(cfg, conn); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create bucket if not exists
|
||||||
|
if err := createBucket(cfg, conn); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Storage{
|
||||||
|
conn: conn,
|
||||||
|
bucket: cfg.Bucket,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get value by key
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var value []byte
|
||||||
|
|
||||||
|
err := s.conn.View(func(tx *bbolt.Tx) error {
|
||||||
|
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||||
|
value = b.Get(utils.UnsafeBytes(key))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set key with value
|
||||||
|
func (s *Storage) Set(key string, value []byte, exp time.Duration) error {
|
||||||
|
if len(key) <= 0 || len(value) <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.conn.Update(func(tx *bbolt.Tx) error {
|
||||||
|
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||||
|
|
||||||
|
return b.Put(utils.UnsafeBytes(key), value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete entry by key
|
||||||
|
func (s *Storage) Delete(key string) error {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.conn.Update(func(tx *bbolt.Tx) error {
|
||||||
|
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||||
|
|
||||||
|
return b.Delete(utils.UnsafeBytes(key))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset all entries
|
||||||
|
func (s *Storage) Reset() error {
|
||||||
|
return s.conn.Update(func(tx *bbolt.Tx) error {
|
||||||
|
b := tx.Bucket(utils.UnsafeBytes(s.bucket))
|
||||||
|
|
||||||
|
return b.ForEach(func(k, _ []byte) error {
|
||||||
|
return b.Delete(k)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database
|
||||||
|
func (s *Storage) Close() error {
|
||||||
|
return s.conn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *bbolt.DB {
|
||||||
|
return s.conn
|
||||||
|
}
|
101
bbolt/bbolt_test.go
Normal file
101
bbolt/bbolt_test.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package bbolt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var testStore = New()
|
||||||
|
|
||||||
|
func Test_Bbolt_Set(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Set_Override(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Get(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, val, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Get_NotExist(t *testing.T) {
|
||||||
|
|
||||||
|
result, err := testStore.Get("notexist")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Delete(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Delete(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Reset(t *testing.T) {
|
||||||
|
var (
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set("john1", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set("john2", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Reset()
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get("john1")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
|
||||||
|
result, err = testStore.Get("john2")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Close(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Bbolt_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
63
bbolt/config.go
Normal file
63
bbolt/config.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package bbolt
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Database path
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber.db"
|
||||||
|
Database string
|
||||||
|
|
||||||
|
// Bbolt bucket name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber_storage"
|
||||||
|
Bucket string
|
||||||
|
|
||||||
|
// Timeout is the amount of time to wait to obtain a file lock.
|
||||||
|
// Only available on Darwin and Linux.
|
||||||
|
//
|
||||||
|
// Optional. Default is set to 60 * time.Second.
|
||||||
|
Timeout time.Duration
|
||||||
|
|
||||||
|
// Open database in read-only mode.
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
ReadOnly bool
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Bucket
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigDefault is the default config
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
Database: "fiber.db",
|
||||||
|
Bucket: "fiber_storage",
|
||||||
|
Timeout: 60 * time.Second,
|
||||||
|
ReadOnly: false,
|
||||||
|
Reset: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to set default values
|
||||||
|
func configDefault(config ...Config) Config {
|
||||||
|
// Return default config if nothing provided
|
||||||
|
if len(config) < 1 {
|
||||||
|
return ConfigDefault
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override default config
|
||||||
|
cfg := config[0]
|
||||||
|
|
||||||
|
// Set default values
|
||||||
|
if cfg.Database == "" {
|
||||||
|
cfg.Database = ConfigDefault.Database
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Bucket == "" {
|
||||||
|
cfg.Bucket = ConfigDefault.Bucket
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg
|
||||||
|
}
|
10
bbolt/go.mod
Normal file
10
bbolt/go.mod
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
module github.com/gofiber/storage/bbolt
|
||||||
|
|
||||||
|
go 1.18
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gofiber/utils v1.0.1
|
||||||
|
go.etcd.io/bbolt v1.3.6
|
||||||
|
)
|
||||||
|
|
||||||
|
require golang.org/x/sys v0.2.0 // indirect
|
7
bbolt/go.sum
Normal file
7
bbolt/go.sum
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
|
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
|
||||||
|
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
|
||||||
|
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||||
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
20
bbolt/utils.go
Normal file
20
bbolt/utils.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package bbolt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
"go.etcd.io/bbolt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createBucket(cfg Config, conn *bbolt.DB) error {
|
||||||
|
return conn.Update(func(tx *bbolt.Tx) error {
|
||||||
|
_, err := tx.CreateBucketIfNotExists(utils.UnsafeBytes(cfg.Bucket))
|
||||||
|
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeBucket(cfg Config, conn *bbolt.DB) error {
|
||||||
|
return conn.Update(func(tx *bbolt.Tx) error {
|
||||||
|
return tx.DeleteBucket(utils.UnsafeBytes(cfg.Bucket))
|
||||||
|
})
|
||||||
|
}
|
@@ -1,4 +1,7 @@
|
|||||||
# ⚠ DynamoDB is still in development, do not use in production!
|
# DynamoDB
|
||||||
|
A DynamoDB storage driver using [aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2).
|
||||||
|
|
||||||
|
**Note:** If config fields of credentials not given, credentials are using from the environment variables, ~/.aws/credentials, or EC2 instance role. If config fields of credentials given, credentials are using from config. Look at: [specifying credentials](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials)
|
||||||
|
|
||||||
....
|
....
|
||||||
|
|
||||||
@@ -20,6 +23,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *awsdynamodb.Client
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
@@ -60,28 +64,70 @@ type Config struct {
|
|||||||
// Optional ("fiber_storage" by default).
|
// Optional ("fiber_storage" by default).
|
||||||
Table string
|
Table string
|
||||||
|
|
||||||
// AWS access key ID (part of the credentials).
|
|
||||||
// Optional (read from shared credentials file or environment variable if not set).
|
|
||||||
// Environment variable: "AWS_ACCESS_KEY_ID".
|
|
||||||
AWSaccessKeyID string
|
|
||||||
|
|
||||||
// AWS secret access key (part of the credentials).
|
|
||||||
// Optional (read from shared credentials file or environment variable if not set).
|
|
||||||
// Environment variable: "AWS_SECRET_ACCESS_KEY".
|
|
||||||
AWSsecretAccessKey string
|
|
||||||
|
|
||||||
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
|
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
|
||||||
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
|
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
|
||||||
// Typical value for the Docker container: "http://localhost:8000".
|
// Typical value for the Docker container: "http://localhost:8000".
|
||||||
// See https://hub.docker.com/r/amazon/dynamodb-local/.
|
// See https://hub.docker.com/r/amazon/dynamodb-local/.
|
||||||
// Optional ("" by default)
|
// Optional ("" by default)
|
||||||
CustomEndpoint string
|
Endpoint string
|
||||||
|
|
||||||
|
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||||
|
//
|
||||||
|
// Optional. Default is Credentials{}
|
||||||
|
Credentials Credentials
|
||||||
|
|
||||||
|
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||||
|
//
|
||||||
|
// Optional. Default is 3
|
||||||
|
MaxAttempts int
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Bucket
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
|
||||||
|
// ReadCapacityUnits of the table.
|
||||||
|
// Only required when the table doesn't exist yet and is created by gokv.
|
||||||
|
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
||||||
|
// 25 RCUs are included in the free tier (across all tables).
|
||||||
|
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||||
|
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||||
|
ReadCapacityUnits int64
|
||||||
|
|
||||||
|
// ReadCapacityUnits of the table.
|
||||||
|
// Only required when the table doesn't exist yet and is created by gokv.
|
||||||
|
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
||||||
|
// 25 RCUs are included in the free tier (across all tables).
|
||||||
|
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||||
|
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||||
|
WriteCapacityUnits int64
|
||||||
|
|
||||||
|
// If the table doesn't exist yet, gokv creates it.
|
||||||
|
// If WaitForTableCreation is true, gokv will block until the table is created, with a timeout of 15 seconds.
|
||||||
|
// If the table still doesn't exist after 15 seconds, an error is returned.
|
||||||
|
// If WaitForTableCreation is false, gokv returns the client immediately.
|
||||||
|
// In the latter case you need to make sure that you don't read from or write to the table before it's created,
|
||||||
|
// because otherwise you will get ResourceNotFoundException errors.
|
||||||
|
// Optional (true by default).
|
||||||
|
WaitForTableCreation *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Credentials struct {
|
||||||
|
AccessKey string
|
||||||
|
SecretAccessKey string
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Table: "fiber_storage",
|
Table: "fiber_storage",
|
||||||
|
Credentials: Credentials{},
|
||||||
|
MaxAttempts: 3,
|
||||||
|
Reset: false,
|
||||||
|
ReadCapacityUnits: 5,
|
||||||
|
WriteCapacityUnits: 5,
|
||||||
|
WaitForTableCreation: aws.Bool(true),
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package dynamodb
|
package dynamodb
|
||||||
|
|
||||||
import "github.com/aws/aws-sdk-go/aws"
|
import "github.com/aws/aws-sdk-go-v2/aws"
|
||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -15,22 +15,27 @@ type Config struct {
|
|||||||
// Optional ("fiber_storage" by default).
|
// Optional ("fiber_storage" by default).
|
||||||
Table string
|
Table string
|
||||||
|
|
||||||
// AWS access key ID (part of the credentials).
|
|
||||||
// Optional (read from shared credentials file or environment variable if not set).
|
|
||||||
// Environment variable: "AWS_ACCESS_KEY_ID".
|
|
||||||
AWSaccessKeyID string
|
|
||||||
|
|
||||||
// AWS secret access key (part of the credentials).
|
|
||||||
// Optional (read from shared credentials file or environment variable if not set).
|
|
||||||
// Environment variable: "AWS_SECRET_ACCESS_KEY".
|
|
||||||
AWSsecretAccessKey string
|
|
||||||
|
|
||||||
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
|
// CustomEndpoint allows you to set a custom DynamoDB service endpoint.
|
||||||
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
|
// This is especially useful if you're running a "DynamoDB local" Docker container for local testing.
|
||||||
// Typical value for the Docker container: "http://localhost:8000".
|
// Typical value for the Docker container: "http://localhost:8000".
|
||||||
// See https://hub.docker.com/r/amazon/dynamodb-local/.
|
// See https://hub.docker.com/r/amazon/dynamodb-local/.
|
||||||
// Optional ("" by default)
|
// Optional ("" by default)
|
||||||
CustomEndpoint string
|
Endpoint string
|
||||||
|
|
||||||
|
// Credentials overrides AWS access key and AWS secret access key. Not recommended.
|
||||||
|
//
|
||||||
|
// Optional. Default is Credentials{}
|
||||||
|
Credentials Credentials
|
||||||
|
|
||||||
|
// The maximum number of times requests that encounter retryable failures should be attempted.
|
||||||
|
//
|
||||||
|
// Optional. Default is 3
|
||||||
|
MaxAttempts int
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Bucket
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
|
||||||
// ReadCapacityUnits of the table.
|
// ReadCapacityUnits of the table.
|
||||||
// Only required when the table doesn't exist yet and is created by gokv.
|
// Only required when the table doesn't exist yet and is created by gokv.
|
||||||
@@ -38,14 +43,16 @@ type Config struct {
|
|||||||
// 25 RCUs are included in the free tier (across all tables).
|
// 25 RCUs are included in the free tier (across all tables).
|
||||||
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||||
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||||
readCapacityUnits int64
|
ReadCapacityUnits int64
|
||||||
|
|
||||||
// ReadCapacityUnits of the table.
|
// ReadCapacityUnits of the table.
|
||||||
// Only required when the table doesn't exist yet and is created by gokv.
|
// Only required when the table doesn't exist yet and is created by gokv.
|
||||||
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
// Optional (5 by default, which is the same default value as when creating a table in the web console)
|
||||||
// 25 RCUs are included in the free tier (across all tables).
|
// 25 RCUs are included in the free tier (across all tables).
|
||||||
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
// For example calculations, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/HowItWorks.ProvisionedThroughput.
|
||||||
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
// For limits, see https://github.com/awsdocs/amazon-dynamodb-developer-guide/blob/c420420a59040c5b3dd44a6e59f7c9e55fc922ef/doc_source/Limits.md#capacity-units-and-provisioned-throughput.md#provisioned-throughput.
|
||||||
writeCapacityUnits int64
|
WriteCapacityUnits int64
|
||||||
|
|
||||||
// If the table doesn't exist yet, gokv creates it.
|
// If the table doesn't exist yet, gokv creates it.
|
||||||
// If WaitForTableCreation is true, gokv will block until the table is created, with a timeout of 15 seconds.
|
// If WaitForTableCreation is true, gokv will block until the table is created, with a timeout of 15 seconds.
|
||||||
// If the table still doesn't exist after 15 seconds, an error is returned.
|
// If the table still doesn't exist after 15 seconds, an error is returned.
|
||||||
@@ -53,15 +60,23 @@ type Config struct {
|
|||||||
// In the latter case you need to make sure that you don't read from or write to the table before it's created,
|
// In the latter case you need to make sure that you don't read from or write to the table before it's created,
|
||||||
// because otherwise you will get ResourceNotFoundException errors.
|
// because otherwise you will get ResourceNotFoundException errors.
|
||||||
// Optional (true by default).
|
// Optional (true by default).
|
||||||
waitForTableCreation *bool
|
WaitForTableCreation *bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Credentials struct {
|
||||||
|
AccessKey string
|
||||||
|
SecretAccessKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigDefault is the default config
|
// ConfigDefault is the default config
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
Table: "fiber_storage",
|
Table: "fiber_storage",
|
||||||
readCapacityUnits: 5,
|
Credentials: Credentials{},
|
||||||
writeCapacityUnits: 5,
|
MaxAttempts: 3,
|
||||||
waitForTableCreation: aws.Bool(true),
|
Reset: false,
|
||||||
|
ReadCapacityUnits: 5,
|
||||||
|
WriteCapacityUnits: 5,
|
||||||
|
WaitForTableCreation: aws.Bool(true),
|
||||||
}
|
}
|
||||||
|
|
||||||
// configDefault is a helper function to set default values
|
// configDefault is a helper function to set default values
|
||||||
@@ -78,5 +93,18 @@ func configDefault(config ...Config) Config {
|
|||||||
if cfg.Table == "" {
|
if cfg.Table == "" {
|
||||||
cfg.Table = ConfigDefault.Table
|
cfg.Table = ConfigDefault.Table
|
||||||
}
|
}
|
||||||
|
if cfg.MaxAttempts == 0 {
|
||||||
|
cfg.MaxAttempts = ConfigDefault.MaxAttempts
|
||||||
|
}
|
||||||
|
if cfg.ReadCapacityUnits == 0 {
|
||||||
|
cfg.ReadCapacityUnits = ConfigDefault.ReadCapacityUnits
|
||||||
|
}
|
||||||
|
if cfg.WriteCapacityUnits == 0 {
|
||||||
|
cfg.WriteCapacityUnits = ConfigDefault.WriteCapacityUnits
|
||||||
|
}
|
||||||
|
if cfg.WaitForTableCreation == nil {
|
||||||
|
cfg.WaitForTableCreation = ConfigDefault.WaitForTableCreation
|
||||||
|
}
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@@ -3,90 +3,23 @@ package dynamodb
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go-v2/aws/retry"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
awsdynamodb "github.com/aws/aws-sdk-go/service/dynamodb"
|
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
|
||||||
|
awsdynamodb "github.com/aws/aws-sdk-go-v2/service/dynamodb"
|
||||||
|
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage interface that is implemented by storage providers
|
// Storage interface that is implemented by storage providers
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
db *awsdynamodb.DynamoDB
|
db *awsdynamodb.Client
|
||||||
table string
|
table string
|
||||||
}
|
requestTimeout time.Duration
|
||||||
|
|
||||||
// New creates a new storage
|
|
||||||
func New(config Config) *Storage {
|
|
||||||
// Set default config
|
|
||||||
cfg := configDefault(config)
|
|
||||||
|
|
||||||
// Create db
|
|
||||||
var creds *credentials.Credentials
|
|
||||||
if (cfg.AWSaccessKeyID != "" && cfg.AWSsecretAccessKey == "") || (cfg.AWSaccessKeyID == "" && cfg.AWSsecretAccessKey != "") {
|
|
||||||
panic("[DynamoDB] You need to set BOTH AWSaccessKeyID AND AWSsecretAccessKey")
|
|
||||||
} else if cfg.AWSaccessKeyID != "" {
|
|
||||||
// Due to the previous check we can be sure that in this case AWSsecretAccessKey is not empty as well.
|
|
||||||
creds = credentials.NewStaticCredentials(cfg.AWSaccessKeyID, cfg.AWSsecretAccessKey, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set database options
|
|
||||||
opt := aws.NewConfig()
|
|
||||||
if cfg.Region != "" {
|
|
||||||
opt = opt.WithRegion(cfg.Region)
|
|
||||||
}
|
|
||||||
if creds != nil {
|
|
||||||
opt = opt.WithCredentials(creds)
|
|
||||||
}
|
|
||||||
if cfg.CustomEndpoint != "" {
|
|
||||||
opt = opt.WithEndpoint(cfg.CustomEndpoint)
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionOpt := session.Options{
|
|
||||||
SharedConfigState: session.SharedConfigEnable,
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...but allow overwrite of region and credentials if they are set in the options.
|
|
||||||
sessionOpt.Config.MergeIn(opt)
|
|
||||||
session, err := session.NewSessionWithOptions(sessionOpt)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
svc := awsdynamodb.New(session)
|
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
describeTableInput := awsdynamodb.DescribeTableInput{
|
|
||||||
TableName: &cfg.Table,
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DescribeTableWithContext(timeoutCtx, &describeTableInput)
|
|
||||||
if err != nil {
|
|
||||||
awsErr, ok := err.(awserr.Error)
|
|
||||||
if !ok {
|
|
||||||
panic(err)
|
|
||||||
} else if awsErr.Code() == awsdynamodb.ErrCodeResourceNotFoundException {
|
|
||||||
err = createTable(cfg.Table, cfg.readCapacityUnits, cfg.writeCapacityUnits, *cfg.waitForTableCreation, describeTableInput, svc)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create storage
|
|
||||||
store := &Storage{
|
|
||||||
db: svc,
|
|
||||||
table: cfg.Table,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start garbage collector
|
|
||||||
//go store.gc()
|
|
||||||
|
|
||||||
return store
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// "k" is used as table column name for the key.
|
// "k" is used as table column name for the key.
|
||||||
@@ -95,126 +28,182 @@ var keyAttrName = "k"
|
|||||||
// "v" is used as table column name for the value.
|
// "v" is used as table column name for the value.
|
||||||
var valAttrName = "v"
|
var valAttrName = "v"
|
||||||
|
|
||||||
|
type table struct {
|
||||||
|
K string
|
||||||
|
V []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new storage
|
||||||
|
func New(config Config) *Storage {
|
||||||
|
// Set default config
|
||||||
|
cfg := configDefault(config)
|
||||||
|
|
||||||
|
awscfg, err := returnAWSConfig(cfg)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("unable to load SDK config, %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create db
|
||||||
|
sess := awsdynamodb.NewFromConfig(awscfg)
|
||||||
|
|
||||||
|
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
describeTableInput := awsdynamodb.DescribeTableInput{
|
||||||
|
TableName: &cfg.Table,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create storage
|
||||||
|
store := &Storage{
|
||||||
|
db: sess,
|
||||||
|
table: cfg.Table,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create table
|
||||||
|
_, err = sess.DescribeTable(timeoutCtx, &describeTableInput)
|
||||||
|
if err != nil {
|
||||||
|
var rnfe *types.ResourceNotFoundException
|
||||||
|
if errors.As(err, &rnfe) {
|
||||||
|
err := store.createTable(cfg, describeTableInput)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return store
|
||||||
|
}
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (s *Storage) Get(key string) ([]byte, error) {
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
k := make(map[string]*awsdynamodb.AttributeValue)
|
ctx, cancel := s.requestContext()
|
||||||
k[keyAttrName] = &awsdynamodb.AttributeValue{
|
defer cancel()
|
||||||
S: &key,
|
|
||||||
|
k := make(map[string]types.AttributeValue)
|
||||||
|
k[keyAttrName] = &types.AttributeValueMemberS{
|
||||||
|
Value: key,
|
||||||
}
|
}
|
||||||
getItemInput := awsdynamodb.GetItemInput{
|
getItemInput := awsdynamodb.GetItemInput{
|
||||||
TableName: &s.table,
|
TableName: &s.table,
|
||||||
Key: k,
|
Key: k,
|
||||||
}
|
}
|
||||||
getItemOutput, err := s.db.GetItem(&getItemInput)
|
getItemOutput, err := s.db.GetItem(ctx, &getItemInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var rnfe *types.ResourceNotFoundException
|
||||||
|
if errors.As(err, &rnfe) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if getItemOutput.Item == nil {
|
} else if getItemOutput.Item == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
attributeVal := getItemOutput.Item[valAttrName]
|
|
||||||
if attributeVal == nil {
|
item := &table{}
|
||||||
return nil, nil
|
err = attributevalue.UnmarshalMap(getItemOutput.Item, &item)
|
||||||
}
|
|
||||||
return attributeVal.B, nil
|
return item.V, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set key with value
|
|
||||||
// Set key with value
|
// Set key with value
|
||||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// Ain't Nobody Got Time For That
|
// Ain't Nobody Got Time For That
|
||||||
if len(key) <= 0 || len(val) <= 0 {
|
if len(key) <= 0 || len(val) <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
item := make(map[string]*awsdynamodb.AttributeValue)
|
|
||||||
item[keyAttrName] = &awsdynamodb.AttributeValue{
|
item := make(map[string]types.AttributeValue)
|
||||||
S: &key,
|
item[keyAttrName] = &types.AttributeValueMemberS{
|
||||||
|
Value: key,
|
||||||
}
|
}
|
||||||
item[valAttrName] = &awsdynamodb.AttributeValue{
|
item[valAttrName] = &types.AttributeValueMemberB{
|
||||||
B: val,
|
Value: val,
|
||||||
}
|
}
|
||||||
putItemInput := awsdynamodb.PutItemInput{
|
putItemInput := awsdynamodb.PutItemInput{
|
||||||
TableName: &s.table,
|
TableName: &s.table,
|
||||||
Item: item,
|
Item: item,
|
||||||
}
|
}
|
||||||
_, err := s.db.PutItem(&putItemInput)
|
|
||||||
|
_, err := s.db.PutItem(ctx, &putItemInput)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete entry by key
|
// Delete entry by key
|
||||||
func (s *Storage) Delete(key string) error {
|
func (s *Storage) Delete(key string) error {
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// Ain't Nobody Got Time For That
|
// Ain't Nobody Got Time For That
|
||||||
if len(key) <= 0 {
|
if len(key) <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
k := make(map[string]*awsdynamodb.AttributeValue)
|
|
||||||
k[keyAttrName] = &awsdynamodb.AttributeValue{
|
k := make(map[string]types.AttributeValue)
|
||||||
S: &key,
|
k[keyAttrName] = &types.AttributeValueMemberS{
|
||||||
|
Value: key,
|
||||||
}
|
}
|
||||||
deleteItemInput := awsdynamodb.DeleteItemInput{
|
deleteItemInput := awsdynamodb.DeleteItemInput{
|
||||||
TableName: &s.table,
|
TableName: &s.table,
|
||||||
Key: k,
|
Key: k,
|
||||||
}
|
}
|
||||||
_, err := s.db.DeleteItem(&deleteItemInput)
|
|
||||||
|
_, err := s.db.DeleteItem(ctx, &deleteItemInput)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset all entries, including unexpired
|
// Reset all entries, including unexpired
|
||||||
func (s *Storage) Reset() error {
|
func (s *Storage) Reset() error {
|
||||||
|
ctx, cancel := s.requestContext()
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
deleteTableInput := awsdynamodb.DeleteTableInput{
|
deleteTableInput := awsdynamodb.DeleteTableInput{
|
||||||
TableName: &s.table,
|
TableName: &s.table,
|
||||||
}
|
}
|
||||||
_, err := s.db.DeleteTable(&deleteTableInput)
|
_, err := s.db.DeleteTable(ctx, &deleteTableInput)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the database
|
// Close the database
|
||||||
func (s *Storage) Close() error {
|
func (s *Storage) Close() error {
|
||||||
// In the DynamoDB implementation this doesn't have any effect.
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GC deletes all expired entries
|
func (s *Storage) createTable(cfg Config, describeTableInput awsdynamodb.DescribeTableInput) error {
|
||||||
// func (s *Storage) gc() {
|
ctx, cancel := s.requestContext()
|
||||||
// ticker := time.NewTicker(s.gcInterval)
|
defer cancel()
|
||||||
// defer ticker.Stop()
|
|
||||||
// for {
|
|
||||||
// select {
|
|
||||||
// case <-s.done:
|
|
||||||
// return
|
|
||||||
// case t := <-ticker.C:
|
|
||||||
// _, _ = s.db.Exec(s.sqlGC, t.Unix())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
func createTable(tableName string, readCapacityUnits, writeCapacityUnits int64, waitForTableCreation bool, describeTableInput awsdynamodb.DescribeTableInput, svc *awsdynamodb.DynamoDB) error {
|
|
||||||
keyAttrType := "S" // For "string"
|
keyAttrType := "S" // For "string"
|
||||||
keyType := "HASH" // As opposed to "RANGE"
|
keyType := "HASH" // As opposed to "RANGE"
|
||||||
|
|
||||||
createTableInput := awsdynamodb.CreateTableInput{
|
createTableInput := awsdynamodb.CreateTableInput{
|
||||||
TableName: &tableName,
|
TableName: &s.table,
|
||||||
AttributeDefinitions: []*awsdynamodb.AttributeDefinition{{
|
AttributeDefinitions: []types.AttributeDefinition{{
|
||||||
AttributeName: &keyAttrName,
|
AttributeName: &keyAttrName,
|
||||||
AttributeType: &keyAttrType,
|
AttributeType: types.ScalarAttributeType(keyAttrType),
|
||||||
}},
|
}},
|
||||||
KeySchema: []*awsdynamodb.KeySchemaElement{{
|
KeySchema: []types.KeySchemaElement{{
|
||||||
AttributeName: &keyAttrName,
|
AttributeName: &keyAttrName,
|
||||||
KeyType: &keyType,
|
KeyType: types.KeyType(keyType),
|
||||||
}},
|
}},
|
||||||
ProvisionedThroughput: &awsdynamodb.ProvisionedThroughput{
|
ProvisionedThroughput: &types.ProvisionedThroughput{
|
||||||
ReadCapacityUnits: &readCapacityUnits,
|
ReadCapacityUnits: &cfg.ReadCapacityUnits,
|
||||||
WriteCapacityUnits: &writeCapacityUnits,
|
WriteCapacityUnits: &cfg.WriteCapacityUnits,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err := svc.CreateTable(&createTableInput)
|
_, err := s.db.CreateTable(ctx, &createTableInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// If configured (true by default), block until the table is created.
|
// If configured (true by default), block until the table is created.
|
||||||
// Typical table creation duration is 10 seconds.
|
// Typical table creation duration is 10 seconds.
|
||||||
if waitForTableCreation {
|
if *cfg.WaitForTableCreation {
|
||||||
for try := 1; try < 16; try++ {
|
for try := 1; try < 16; try++ {
|
||||||
describeTableOutput, err := svc.DescribeTable(&describeTableInput)
|
describeTableOutput, err := s.db.DescribeTable(ctx, &describeTableInput)
|
||||||
if err != nil || *describeTableOutput.Table.TableStatus == "CREATING" {
|
if err != nil || describeTableOutput.Table.TableStatus == "CREATING" {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
@@ -222,14 +211,61 @@ func createTable(tableName string, readCapacityUnits, writeCapacityUnits int64,
|
|||||||
}
|
}
|
||||||
// Last try (16th) after 15 seconds of waiting.
|
// Last try (16th) after 15 seconds of waiting.
|
||||||
// Now handle error as such.
|
// Now handle error as such.
|
||||||
describeTableOutput, err := svc.DescribeTable(&describeTableInput)
|
describeTableOutput, err := s.db.DescribeTable(ctx, &describeTableInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("The DynamoDB table couldn't be created")
|
return errors.New("dynamodb: the table couldn't be created")
|
||||||
}
|
}
|
||||||
if *describeTableOutput.Table.TableStatus == "CREATING" {
|
if describeTableOutput.Table.TableStatus == "CREATING" {
|
||||||
return errors.New("The DynamoDB table took too long to be created")
|
return errors.New("dynamodb: the table took too long to be created")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Context for making requests will timeout if a non-zero timeout is configured
|
||||||
|
func (s *Storage) requestContext() (context.Context, context.CancelFunc) {
|
||||||
|
if s.requestTimeout > 0 {
|
||||||
|
return context.WithTimeout(context.Background(), s.requestTimeout)
|
||||||
|
}
|
||||||
|
return context.Background(), func() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnAWSConfig(cfg Config) (aws.Config, error) {
|
||||||
|
endpoint := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
||||||
|
if cfg.Endpoint != "" {
|
||||||
|
return aws.Endpoint{
|
||||||
|
PartitionID: "aws",
|
||||||
|
URL: cfg.Endpoint,
|
||||||
|
SigningRegion: cfg.Region,
|
||||||
|
HostnameImmutable: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
return aws.Endpoint{}, &aws.EndpointNotFoundError{}
|
||||||
|
})
|
||||||
|
|
||||||
|
if cfg.Credentials != (Credentials{}) {
|
||||||
|
credentials := credentials.NewStaticCredentialsProvider(cfg.Credentials.AccessKey, cfg.Credentials.SecretAccessKey, "")
|
||||||
|
return awsconfig.LoadDefaultConfig(context.TODO(),
|
||||||
|
awsconfig.WithRegion(cfg.Region),
|
||||||
|
awsconfig.WithEndpointResolverWithOptions(endpoint),
|
||||||
|
awsconfig.WithCredentialsProvider(credentials),
|
||||||
|
awsconfig.WithRetryer(func() aws.Retryer {
|
||||||
|
return retry.AddWithMaxAttempts(retry.NewStandard(), cfg.MaxAttempts)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return awsconfig.LoadDefaultConfig(context.TODO(),
|
||||||
|
awsconfig.WithRegion(cfg.Region),
|
||||||
|
awsconfig.WithEndpointResolverWithOptions(endpoint),
|
||||||
|
awsconfig.WithRetryer(func() aws.Retryer {
|
||||||
|
return retry.AddWithMaxAttempts(retry.NewStandard(), cfg.MaxAttempts)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *awsdynamodb.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -1 +1,111 @@
|
|||||||
package dynamodb
|
package dynamodb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var testStore = New(
|
||||||
|
Config{
|
||||||
|
Table: "fiber_storage",
|
||||||
|
Endpoint: "http://localhost:8000/",
|
||||||
|
Region: "us-east-1",
|
||||||
|
Credentials: Credentials{
|
||||||
|
AccessKey: "dummy",
|
||||||
|
SecretAccessKey: "dummy",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_DynamoDB_Set(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Set_Override(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Get(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, val, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Get_NotExist(t *testing.T) {
|
||||||
|
|
||||||
|
result, err := testStore.Get("notexist")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Delete(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Delete(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Reset(t *testing.T) {
|
||||||
|
var (
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set("john1", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set("john2", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Reset()
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get("john1")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
|
||||||
|
result, err = testStore.Get("john2")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Close(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_DynamoDB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,12 @@
|
|||||||
module github.com/gofiber/storage/dynamodb
|
module github.com/gofiber/storage/dynamodb
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require github.com/aws/aws-sdk-go v1.42.38
|
require (
|
||||||
|
github.com/aws/aws-sdk-go-v2 v1.17.2
|
||||||
|
github.com/aws/aws-sdk-go-v2/config v1.18.4
|
||||||
|
github.com/aws/aws-sdk-go-v2/credentials v1.13.4
|
||||||
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.7
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.8
|
||||||
|
github.com/gofiber/utils v1.0.1
|
||||||
|
)
|
||||||
|
@@ -1,24 +1,50 @@
|
|||||||
github.com/aws/aws-sdk-go v1.42.38 h1:/fNQTB4ZUQOa8+cfX7C7F0zyXRdiN1jGKKXt3+5nmzM=
|
github.com/aws/aws-sdk-go-v2 v1.17.2 h1:r0yRZInwiPBNpQ4aDy/Ssh3ROWsGtKDwar2JS8Lm+N8=
|
||||||
github.com/aws/aws-sdk-go v1.42.38/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc=
|
github.com/aws/aws-sdk-go-v2 v1.17.2/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
|
||||||
|
github.com/aws/aws-sdk-go-v2/config v1.18.4 h1:VZKhr3uAADXHStS/Gf9xSYVmmaluTUfkc0dcbPiDsKE=
|
||||||
|
github.com/aws/aws-sdk-go-v2/config v1.18.4/go.mod h1:EZxMPLSdGAZ3eAmkqXfYbRppZJTzFTkv8VyEzJhKko4=
|
||||||
|
github.com/aws/aws-sdk-go-v2/credentials v1.13.4 h1:nEbHIyJy7mCvQ/kzGG7VWHSBpRB4H6sJy3bWierWUtg=
|
||||||
|
github.com/aws/aws-sdk-go-v2/credentials v1.13.4/go.mod h1:/Cj5w9LRsNTLSwexsohwDME32OzJ6U81Zs33zr2ZWOM=
|
||||||
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.7 h1:CyuByiiCA4lPfU8RaHJh2wIYYn0hkFlOkMfWkVY67Mc=
|
||||||
|
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.7/go.mod h1:pAMtgCPVxcKohC/HNI6nLwLeW007eYl3T+pq7yTMV3o=
|
||||||
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.20 h1:tpNOglTZ8kg9T38NpcGBxudqfUAwUzyUnLQ4XSd0CHE=
|
||||||
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.20/go.mod h1:d9xFpWd3qYwdIXM0fvu7deD08vvdRXyc/ueV+0SqaWE=
|
||||||
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.26 h1:5WU31cY7m0tG+AiaXuXGoMzo2GBQ1IixtWa8Yywsgco=
|
||||||
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.26/go.mod h1:2E0LdbJW6lbeU4uxjum99GZzI0ZjDpAb0CoSCM0oeEY=
|
||||||
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.20 h1:WW0qSzDWoiWU2FS5DbKpxGilFVlCEJPwx4YtjdfI0Jw=
|
||||||
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.20/go.mod h1:/+6lSiby8TBFpTVXZgKiN/rCfkYXEGvhlM4zCgPpt7w=
|
||||||
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.27 h1:N2eKFw2S+JWRCtTt0IhIX7uoGGQciD4p6ba+SJv4WEU=
|
||||||
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.27/go.mod h1:RdwFVc7PBYWY33fa2+8T1mSqQ7ZEK4ILpM0wfioDC3w=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.8 h1:VgdGaSIoH4JhUZIspT8UgK0aBF85TiLve7VHEx3NfqE=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.17.8/go.mod h1:jvXzk+hVrlkiQOvnq6jH+F6qBK0CEceXkEWugT+4Kdc=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.27 h1:7MhqbR+k+b0gbOxp+W8yXgsl/Z5/dtMh85K0WI8X2EA=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.27/go.mod h1:wX9QEZJ8Dw1fdAKCOAUmSvAe3wNJFxnE/4AeYc8blGA=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.20 h1:kSZR22oLBDMtP8ZPGXhz649NU77xsJDG7g3xfT6nHVk=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.20/go.mod h1:lxM5qubwGNX29Qy+xTFG8G0r2Mj/TmyC+h3hS/7E4V8=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.20 h1:jlgyHbkZQAgAc7VIxJDmtouH8eNjOk2REVAQfVhdaiQ=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.20/go.mod h1:Xs52xaLBqDEKRcAfX/hgjmD3YQ7c/W+BEyfamlO/W2E=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/sso v1.11.26 h1:ActQgdTNQej/RuUJjB9uxYVLDOvRGtUreXF8L3c8wyg=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/sso v1.11.26/go.mod h1:uB9tV79ULEZUXc6Ob18A46KSQ0JDlrplPni9XW6Ot60=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.9 h1:wihKuqYUlA2T/Rx+yu2s6NDAns8B9DgnRooB1PVhY+Q=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.9/go.mod h1:2E/3D/mB8/r2J7nK42daoKP/ooCwbf0q1PznNc+DZTU=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/sts v1.17.6 h1:VQFOLQVL3BrKM/NLO/7FiS4vcp5bqK0mGMyk09xLoAY=
|
||||||
|
github.com/aws/aws-sdk-go-v2/service/sts v1.17.6/go.mod h1:Az3OXXYGyfNwQNsK/31L4R75qFYnO641RZGAoV3uH1c=
|
||||||
|
github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8=
|
||||||
|
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||||
|
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
github.com/jmespath/go-jmespath v0.4.0 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=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
|
|
||||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
2
go.mod
2
go.mod
@@ -1,3 +1,3 @@
|
|||||||
module github.com/gofiber/storage
|
module github.com/gofiber/storage
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *mc.Client
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
module github.com/gofiber/storage/memcache
|
module github.com/gofiber/storage/memcache
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d
|
github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v1.0.1
|
||||||
)
|
)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
|
github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822 h1:hjXJeBcAMS1WGENGqDpzvmgS43oECTx8UXq31UBu0Jw=
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
|
@@ -122,3 +122,8 @@ func (s *Storage) releaseItem(item *mc.Item) {
|
|||||||
s.items.Put(item)
|
s.items.Put(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *mc.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -119,3 +119,7 @@ func Test_Memcache_Reset(t *testing.T) {
|
|||||||
func Test_Memcache_Close(t *testing.T) {
|
func Test_Memcache_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Memcache_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -18,6 +18,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() map[string]entry
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
module github.com/gofiber/storage/memory
|
module github.com/gofiber/storage/memory
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require github.com/gofiber/utils v0.1.2
|
require github.com/gofiber/utils v1.0.1
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
|
32
memory/internal/time.go
Normal file
32
memory/internal/time.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
timestampTimer sync.Once
|
||||||
|
// Timestamp please start the timer function before you use this value
|
||||||
|
// please load the value with atomic `atomic.LoadUint32(&utils.Timestamp)`
|
||||||
|
Timestamp uint32
|
||||||
|
)
|
||||||
|
|
||||||
|
// StartTimeStampUpdater starts a concurrent function which stores the timestamp to an atomic value per second,
|
||||||
|
// which is much better for performance than determining it at runtime each time
|
||||||
|
func StartTimeStampUpdater() {
|
||||||
|
timestampTimer.Do(func() {
|
||||||
|
// set initial value
|
||||||
|
atomic.StoreUint32(&Timestamp, uint32(time.Now().Unix()))
|
||||||
|
go func(sleep time.Duration) {
|
||||||
|
ticker := time.NewTicker(sleep)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for t := range ticker.C {
|
||||||
|
// update timestamp
|
||||||
|
atomic.StoreUint32(&Timestamp, uint32(t.Unix()))
|
||||||
|
}
|
||||||
|
}(1 * time.Second) // duration
|
||||||
|
})
|
||||||
|
}
|
47
memory/internal/time_test.go
Normal file
47
memory/internal/time_test.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync/atomic"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func checkTimeStamp(t testing.TB, expectedCurrent, actualCurrent uint32) {
|
||||||
|
// test with some buffer in front and back of the expectedCurrent time -> because of the timing on the work machine
|
||||||
|
utils.AssertEqual(t, true, actualCurrent >= expectedCurrent-1 || actualCurrent <= expectedCurrent+1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_TimeStampUpdater(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
StartTimeStampUpdater()
|
||||||
|
|
||||||
|
now := uint32(time.Now().Unix())
|
||||||
|
checkTimeStamp(t, now, atomic.LoadUint32(&Timestamp))
|
||||||
|
// one second later
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
checkTimeStamp(t, now+1, atomic.LoadUint32(&Timestamp))
|
||||||
|
// two seconds later
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
checkTimeStamp(t, now+2, atomic.LoadUint32(&Timestamp))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Benchmark_CalculateTimestamp(b *testing.B) {
|
||||||
|
StartTimeStampUpdater()
|
||||||
|
|
||||||
|
var res uint32
|
||||||
|
b.Run("fiber", func(b *testing.B) {
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
res = atomic.LoadUint32(&Timestamp)
|
||||||
|
}
|
||||||
|
checkTimeStamp(b, uint32(time.Now().Unix()), res)
|
||||||
|
})
|
||||||
|
b.Run("default", func(b *testing.B) {
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
res = uint32(time.Now().Unix())
|
||||||
|
}
|
||||||
|
checkTimeStamp(b, uint32(time.Now().Unix()), res)
|
||||||
|
})
|
||||||
|
}
|
@@ -2,7 +2,10 @@ package memory
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/storage/memory/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage interface that is implemented by storage providers
|
// Storage interface that is implemented by storage providers
|
||||||
@@ -15,7 +18,8 @@ type Storage struct {
|
|||||||
|
|
||||||
type entry struct {
|
type entry struct {
|
||||||
data []byte
|
data []byte
|
||||||
expiry int64
|
// max value is 4294967295 -> Sun Feb 07 2106 06:28:15 GMT+0000
|
||||||
|
expiry uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new memory storage
|
// New creates a new memory storage
|
||||||
@@ -31,6 +35,7 @@ func New(config ...Config) *Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start garbage collector
|
// Start garbage collector
|
||||||
|
internal.StartTimeStampUpdater()
|
||||||
go store.gc()
|
go store.gc()
|
||||||
|
|
||||||
return store
|
return store
|
||||||
@@ -44,14 +49,13 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
|||||||
s.mux.RLock()
|
s.mux.RLock()
|
||||||
v, ok := s.db[key]
|
v, ok := s.db[key]
|
||||||
s.mux.RUnlock()
|
s.mux.RUnlock()
|
||||||
if !ok || v.expiry != 0 && v.expiry <= time.Now().Unix() {
|
if !ok || v.expiry != 0 && v.expiry <= atomic.LoadUint32(&internal.Timestamp) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.data, nil
|
return v.data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set key with value
|
|
||||||
// Set key with value
|
// Set key with value
|
||||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
// Ain't Nobody Got Time For That
|
// Ain't Nobody Got Time For That
|
||||||
@@ -59,13 +63,14 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var expire int64
|
var expire uint32
|
||||||
if exp != 0 {
|
if exp != 0 {
|
||||||
expire = time.Now().Add(exp).Unix()
|
expire = uint32(exp.Seconds()) + atomic.LoadUint32(&internal.Timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e := entry{val, expire}
|
||||||
s.mux.Lock()
|
s.mux.Lock()
|
||||||
s.db[key] = entry{val, expire}
|
s.db[key] = e
|
||||||
s.mux.Unlock()
|
s.mux.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -84,8 +89,9 @@ func (s *Storage) Delete(key string) error {
|
|||||||
|
|
||||||
// Reset all keys
|
// Reset all keys
|
||||||
func (s *Storage) Reset() error {
|
func (s *Storage) Reset() error {
|
||||||
|
ndb := make(map[string]entry)
|
||||||
s.mux.Lock()
|
s.mux.Lock()
|
||||||
s.db = make(map[string]entry)
|
s.db = ndb
|
||||||
s.mux.Unlock()
|
s.mux.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -99,20 +105,37 @@ func (s *Storage) Close() error {
|
|||||||
func (s *Storage) gc() {
|
func (s *Storage) gc() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
var expired []string
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.done:
|
case <-s.done:
|
||||||
return
|
return
|
||||||
case t := <-ticker.C:
|
case <-ticker.C:
|
||||||
now := t.Unix()
|
ts := atomic.LoadUint32(&internal.Timestamp)
|
||||||
s.mux.Lock()
|
expired = expired[:0]
|
||||||
|
s.mux.RLock()
|
||||||
for id, v := range s.db {
|
for id, v := range s.db {
|
||||||
if v.expiry != 0 && v.expiry < now {
|
if v.expiry != 0 && v.expiry < ts {
|
||||||
delete(s.db, id)
|
expired = append(expired, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.mux.RUnlock()
|
||||||
|
s.mux.Lock()
|
||||||
|
// Double-checked locking.
|
||||||
|
// We might have replaced the item in the meantime.
|
||||||
|
for i := range expired {
|
||||||
|
v := s.db[expired[i]]
|
||||||
|
if v.expiry != 0 && v.expiry <= ts {
|
||||||
|
delete(s.db, expired[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.mux.Unlock()
|
s.mux.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() map[string]entry {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
var testStore = New()
|
var testStore = New()
|
||||||
|
|
||||||
func Test_Memory_Set(t *testing.T) {
|
func Test_Storage_Memory_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -19,7 +19,7 @@ func Test_Memory_Set(t *testing.T) {
|
|||||||
utils.AssertEqual(t, nil, err)
|
utils.AssertEqual(t, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Set_Override(t *testing.T) {
|
func Test_Storage_Memory_Set_Override(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -32,7 +32,7 @@ func Test_Memory_Set_Override(t *testing.T) {
|
|||||||
utils.AssertEqual(t, nil, err)
|
utils.AssertEqual(t, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Get(t *testing.T) {
|
func Test_Storage_Memory_Get(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -46,7 +46,7 @@ func Test_Memory_Get(t *testing.T) {
|
|||||||
utils.AssertEqual(t, val, result)
|
utils.AssertEqual(t, val, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Set_Expiration(t *testing.T) {
|
func Test_Storage_Memory_Set_Expiration(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -59,7 +59,7 @@ func Test_Memory_Set_Expiration(t *testing.T) {
|
|||||||
time.Sleep(1100 * time.Millisecond)
|
time.Sleep(1100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Get_Expired(t *testing.T) {
|
func Test_Storage_Memory_Get_Expired(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
)
|
)
|
||||||
@@ -69,14 +69,14 @@ func Test_Memory_Get_Expired(t *testing.T) {
|
|||||||
utils.AssertEqual(t, true, len(result) == 0)
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Get_NotExist(t *testing.T) {
|
func Test_Storage_Memory_Get_NotExist(t *testing.T) {
|
||||||
|
|
||||||
result, err := testStore.Get("notexist")
|
result, err := testStore.Get("notexist")
|
||||||
utils.AssertEqual(t, nil, err)
|
utils.AssertEqual(t, nil, err)
|
||||||
utils.AssertEqual(t, true, len(result) == 0)
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Delete(t *testing.T) {
|
func Test_Storage_Memory_Delete(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
@@ -93,7 +93,7 @@ func Test_Memory_Delete(t *testing.T) {
|
|||||||
utils.AssertEqual(t, true, len(result) == 0)
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Reset(t *testing.T) {
|
func Test_Storage_Memory_Reset(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
val = []byte("doe")
|
val = []byte("doe")
|
||||||
)
|
)
|
||||||
@@ -116,6 +116,39 @@ func Test_Memory_Reset(t *testing.T) {
|
|||||||
utils.AssertEqual(t, true, len(result) == 0)
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Memory_Close(t *testing.T) {
|
func Test_Storage_Memory_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Storage_Memory_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// go test -v -run=^$ -bench=Benchmark_Storage_Memory -benchmem -count=4
|
||||||
|
func Benchmark_Storage_Memory(b *testing.B) {
|
||||||
|
keyLength := 1000
|
||||||
|
keys := make([]string, keyLength)
|
||||||
|
for i := 0; i < keyLength; i++ {
|
||||||
|
keys[i] = utils.UUID()
|
||||||
|
}
|
||||||
|
value := []byte("joe")
|
||||||
|
|
||||||
|
ttl := 2 * time.Second
|
||||||
|
b.Run("fiber_memory", func(b *testing.B) {
|
||||||
|
d := New()
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
for _, key := range keys {
|
||||||
|
d.Set(key, value, ttl)
|
||||||
|
}
|
||||||
|
for _, key := range keys {
|
||||||
|
_, _ = d.Get(key)
|
||||||
|
}
|
||||||
|
for _, key := range keys {
|
||||||
|
d.Delete(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *mongo.Database
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
MongoDB is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
MongoDB is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
|
@@ -1,14 +1,10 @@
|
|||||||
module github.com/gofiber/storage/mongodb
|
module github.com/gofiber/storage/mongodb
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-stack/stack v1.8.1 // indirect
|
github.com/gofiber/utils v1.0.1
|
||||||
github.com/gofiber/utils v0.1.2
|
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||||
go.mongodb.org/mongo-driver v1.8.2
|
go.mongodb.org/mongo-driver v1.11.0
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
|
||||||
golang.org/x/text v0.3.7 // indirect
|
|
||||||
)
|
)
|
||||||
|
@@ -1,11 +1,8 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
|
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
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=
|
||||||
@@ -18,6 +15,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
||||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
@@ -30,46 +28,38 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
|||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||||
github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w=
|
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
|
||||||
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
|
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||||
github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc=
|
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
|
||||||
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
|
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
||||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
||||||
go.mongodb.org/mongo-driver v1.8.2 h1:8ssUXufb90ujcIvR6MyE1SchaNj0SFxsakiZgxIyrMk=
|
go.mongodb.org/mongo-driver v1.11.0 h1:FZKhBSTydeuffHj9CBjXlR8vQLee1cQyTWYPA6/tqiE=
|
||||||
go.mongodb.org/mongo-driver v1.8.2/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
|
go.mongodb.org/mongo-driver v1.11.0/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@@ -199,3 +199,8 @@ func (s *Storage) releaseItem(item *item) {
|
|||||||
s.items.Put(item)
|
s.items.Put(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *mongo.Database {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -121,3 +121,7 @@ func Test_MongoDB_Reset(t *testing.T) {
|
|||||||
func Test_MongoDB_Close(t *testing.T) {
|
func Test_MongoDB_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_MongoDB_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
135
mssql/README.md
Normal file
135
mssql/README.md
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
# MSSQL
|
||||||
|
|
||||||
|
A MSSQL storage driver using [microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb).
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
- [Signatures](#signatures)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Config](#config)
|
||||||
|
- [Default Config](#default-config)
|
||||||
|
|
||||||
|
### Signatures
|
||||||
|
```go
|
||||||
|
func New(config ...Config) Storage
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error)
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
||||||
|
func (s *Storage) Delete(key string) error
|
||||||
|
func (s *Storage) Reset() error
|
||||||
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
|
```
|
||||||
|
### Installation
|
||||||
|
MSSQL is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
|
```bash
|
||||||
|
go mod init github.com/<user>/<repo>
|
||||||
|
```
|
||||||
|
And then install the mssql implementation:
|
||||||
|
```bash
|
||||||
|
go get github.com/gofiber/storage/mssql
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
Import the storage package.
|
||||||
|
```go
|
||||||
|
import "github.com/gofiber/storage/mssql"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use the following possibilities to create a storage:
|
||||||
|
```go
|
||||||
|
// Initialize default config
|
||||||
|
store := mssql.New()
|
||||||
|
|
||||||
|
// Initialize custom config
|
||||||
|
store := mssql.New(mssql.Config{
|
||||||
|
Host: "127.0.0.1",
|
||||||
|
Port: 1433,
|
||||||
|
Database: "fiber",
|
||||||
|
Table: "fiber_storage",
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
SslMode: "disable",
|
||||||
|
})
|
||||||
|
|
||||||
|
// Initialize custom config using connection string
|
||||||
|
store := mssql.New(mssql.Config{
|
||||||
|
ConnectionURI: "sqlserver://user:password@localhost:1433?database=fiber"
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Config
|
||||||
|
```go
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Connection string to use for DB. Will override all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
ConnectionURI string
|
||||||
|
|
||||||
|
// Host name where the DB is hosted
|
||||||
|
//
|
||||||
|
// Optional. Default is "127.0.0.1"
|
||||||
|
Host string
|
||||||
|
|
||||||
|
// Port where the DB is listening on
|
||||||
|
//
|
||||||
|
// Optional. Default is 1433
|
||||||
|
Port int
|
||||||
|
|
||||||
|
// Server username
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Username string
|
||||||
|
|
||||||
|
// Server password
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Password string
|
||||||
|
|
||||||
|
// Instance name
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Instance string
|
||||||
|
|
||||||
|
// Database name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber"
|
||||||
|
Database string
|
||||||
|
|
||||||
|
// Table name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber_storage"
|
||||||
|
Table string
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Table
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
|
||||||
|
// Time before deleting expired keys
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 * time.Second
|
||||||
|
GCInterval time.Duration
|
||||||
|
|
||||||
|
// The SSL mode for the connection
|
||||||
|
//
|
||||||
|
// Optional. Default is "disable"
|
||||||
|
SslMode string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default Config
|
||||||
|
```go
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
|
Host: "127.0.0.1",
|
||||||
|
Port: 1433,
|
||||||
|
Database: "fiber",
|
||||||
|
Table: "fiber_storage",
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
SslMode: "disable",
|
||||||
|
}
|
||||||
|
```
|
146
mssql/config.go
Normal file
146
mssql/config.go
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
package mssql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config defines the config for storage.
|
||||||
|
type Config struct {
|
||||||
|
// Connection string to use for DB. Will override all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
ConnectionURI string
|
||||||
|
|
||||||
|
// Host name where the DB is hosted
|
||||||
|
//
|
||||||
|
// Optional. Default is "127.0.0.1"
|
||||||
|
Host string
|
||||||
|
|
||||||
|
// Port where the DB is listening on
|
||||||
|
//
|
||||||
|
// Optional. Default is 1433
|
||||||
|
Port int
|
||||||
|
|
||||||
|
// Server username
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Username string
|
||||||
|
|
||||||
|
// Server password
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Password string
|
||||||
|
|
||||||
|
// Instance name
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
Instance string
|
||||||
|
|
||||||
|
// Database name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber"
|
||||||
|
Database string
|
||||||
|
|
||||||
|
// Table name
|
||||||
|
//
|
||||||
|
// Optional. Default is "fiber_storage"
|
||||||
|
Table string
|
||||||
|
|
||||||
|
// The SSL mode for the connection
|
||||||
|
//
|
||||||
|
// Optional. Default is "disable"
|
||||||
|
SslMode string
|
||||||
|
|
||||||
|
// Reset clears any existing keys in existing Table
|
||||||
|
//
|
||||||
|
// Optional. Default is false
|
||||||
|
Reset bool
|
||||||
|
|
||||||
|
// Time before deleting expired keys
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 * time.Second
|
||||||
|
GCInterval time.Duration
|
||||||
|
|
||||||
|
////////////////////////////////////
|
||||||
|
// Adaptor related config options //
|
||||||
|
////////////////////////////////////
|
||||||
|
|
||||||
|
// Maximum wait for connection, in seconds. Zero or
|
||||||
|
// n < 0 means wait indefinitely.
|
||||||
|
timeout time.Duration
|
||||||
|
|
||||||
|
// The maximum number of connections in the idle connection pool.
|
||||||
|
//
|
||||||
|
// If MaxOpenConns is greater than 0 but less than the new MaxIdleConns,
|
||||||
|
// then the new MaxIdleConns will be reduced to match the MaxOpenConns limit.
|
||||||
|
//
|
||||||
|
// If n <= 0, no idle connections are retained.
|
||||||
|
//
|
||||||
|
// The default max idle connections is currently 2. This may change in
|
||||||
|
// a future release.
|
||||||
|
maxIdleConns int
|
||||||
|
|
||||||
|
// The maximum number of open connections to the database.
|
||||||
|
//
|
||||||
|
// If MaxIdleConns is greater than 0 and the new MaxOpenConns is less than
|
||||||
|
// MaxIdleConns, then MaxIdleConns will be reduced to match the new
|
||||||
|
// MaxOpenConns limit.
|
||||||
|
//
|
||||||
|
// If n <= 0, then there is no limit on the number of open connections.
|
||||||
|
// The default is 0 (unlimited).
|
||||||
|
maxOpenConns int
|
||||||
|
|
||||||
|
// The maximum amount of time a connection may be reused.
|
||||||
|
//
|
||||||
|
// Expired connections may be closed lazily before reuse.
|
||||||
|
//
|
||||||
|
// If d <= 0, connections are reused forever.
|
||||||
|
connMaxLifetime time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigDefault is the default config
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
|
Host: "127.0.0.1",
|
||||||
|
Port: 1433,
|
||||||
|
Database: "fiber",
|
||||||
|
Table: "fiber_storage",
|
||||||
|
SslMode: "disable",
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
maxOpenConns: 100,
|
||||||
|
maxIdleConns: 100,
|
||||||
|
connMaxLifetime: 1 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.Host == "" {
|
||||||
|
cfg.Host = ConfigDefault.Host
|
||||||
|
}
|
||||||
|
if cfg.Port <= 0 {
|
||||||
|
cfg.Port = ConfigDefault.Port
|
||||||
|
}
|
||||||
|
if cfg.Database == "" {
|
||||||
|
cfg.Database = ConfigDefault.Database
|
||||||
|
}
|
||||||
|
if cfg.Table == "" {
|
||||||
|
cfg.Table = ConfigDefault.Table
|
||||||
|
}
|
||||||
|
if cfg.SslMode == "" {
|
||||||
|
cfg.SslMode = ConfigDefault.SslMode
|
||||||
|
}
|
||||||
|
if int(cfg.GCInterval.Seconds()) <= 0 {
|
||||||
|
cfg.GCInterval = ConfigDefault.GCInterval
|
||||||
|
}
|
||||||
|
return cfg
|
||||||
|
}
|
13
mssql/go.mod
Normal file
13
mssql/go.mod
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module github.com/gofiber/storage/mssql
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gofiber/utils v1.0.1
|
||||||
|
github.com/microsoft/go-mssqldb v0.18.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
|
||||||
|
golang.org/x/crypto v0.3.0 // indirect
|
||||||
|
)
|
97
mssql/go.sum
Normal file
97
mssql/go.sum
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.2/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
|
||||||
|
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
|
||||||
|
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||||
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
|
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
|
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||||
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
|
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/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
|
||||||
|
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
|
||||||
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||||
|
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||||
|
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
|
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.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
|
||||||
|
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
|
||||||
|
github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc=
|
||||||
|
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 v0.18.0 h1:6Pf95ZIt8mjg3Bm374SlH7RFiez1nGy4xKKOiCw/zFE=
|
||||||
|
github.com/microsoft/go-mssqldb v0.18.0/go.mod h1:ukJCBnnzLzpVF0qYRT+eg1e+eSwjeQ7IvenUv8QPook=
|
||||||
|
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
|
||||||
|
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||||
|
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
|
||||||
|
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
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-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
|
||||||
|
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||||
|
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/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7/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.2.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.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
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/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
|
||||||
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
|
||||||
|
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.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
236
mssql/mssql.go
Normal file
236
mssql/mssql.go
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
package mssql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
_ "github.com/microsoft/go-mssqldb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Storage interface that is implemented by storage providers
|
||||||
|
type Storage struct {
|
||||||
|
db *sql.DB
|
||||||
|
gcInterval time.Duration
|
||||||
|
done chan struct{}
|
||||||
|
|
||||||
|
sqlSelect string
|
||||||
|
sqlInsert string
|
||||||
|
sqlDelete string
|
||||||
|
sqlReset string
|
||||||
|
sqlGC string
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
checkSchemaMsg = "The `v` row has an incorrect data type. " +
|
||||||
|
"It should be VARBINARY(MAX) but is instead %s. This will cause encoding-related panics if the DB is not migrated (see https://github.com/gofiber/storage/blob/main/MIGRATE.md)."
|
||||||
|
dropQuery = `IF EXISTS(SELECT * FROM sys.tables WHERE name = '%s')
|
||||||
|
DROP TABLE %s;`
|
||||||
|
initQuery = []string{
|
||||||
|
`IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = '%s')
|
||||||
|
CREATE TABLE %s (
|
||||||
|
k VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT '',
|
||||||
|
v VARBINARY(MAX) NOT NULL,
|
||||||
|
e BIGINT NOT NULL DEFAULT '0'
|
||||||
|
);`,
|
||||||
|
`IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name = 'e')
|
||||||
|
CREATE INDEX e ON %s (e);`,
|
||||||
|
}
|
||||||
|
checkSchemaQuery = `SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE table_name = '%s' AND COLUMN_NAME = 'v';`
|
||||||
|
)
|
||||||
|
|
||||||
|
// New creates a new storage
|
||||||
|
func New(config ...Config) *Storage {
|
||||||
|
// Set default config
|
||||||
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
|
// Create data source name
|
||||||
|
var dsn string
|
||||||
|
if cfg.ConnectionURI != "" {
|
||||||
|
dsn = cfg.ConnectionURI
|
||||||
|
} else {
|
||||||
|
dsn = "sqlserver://"
|
||||||
|
if cfg.Username != "" {
|
||||||
|
dsn += url.QueryEscape(cfg.Username)
|
||||||
|
}
|
||||||
|
if cfg.Password != "" {
|
||||||
|
dsn += ":" + cfg.Password
|
||||||
|
}
|
||||||
|
if cfg.Username != "" || cfg.Password != "" {
|
||||||
|
dsn += "@"
|
||||||
|
}
|
||||||
|
// unix socket host path
|
||||||
|
if strings.HasPrefix(cfg.Host, "/") {
|
||||||
|
dsn += fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)
|
||||||
|
} else {
|
||||||
|
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||||
|
}
|
||||||
|
if cfg.Instance != "" {
|
||||||
|
dsn += "/" + cfg.Instance
|
||||||
|
}
|
||||||
|
dsn += fmt.Sprintf("?database=%s&connection+timeout=%d&encrypt=%s",
|
||||||
|
url.QueryEscape(cfg.Database),
|
||||||
|
int64(cfg.timeout.Seconds()),
|
||||||
|
cfg.SslMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create db
|
||||||
|
db, err := sql.Open("sqlserver", dsn)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set database options
|
||||||
|
db.SetMaxOpenConns(cfg.maxOpenConns)
|
||||||
|
db.SetMaxIdleConns(cfg.maxIdleConns)
|
||||||
|
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
||||||
|
|
||||||
|
// Ping database to ensure a connection has been made
|
||||||
|
if err := db.Ping(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop table if set to true
|
||||||
|
if cfg.Reset {
|
||||||
|
if _, err = db.Exec(strings.Replace(dropQuery, "%s", cfg.Table, -1)); err != nil {
|
||||||
|
_ = db.Close()
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init database queries
|
||||||
|
for _, query := range initQuery {
|
||||||
|
if _, err := db.Exec(strings.Replace(query, "%s", cfg.Table, -1)); err != nil {
|
||||||
|
_ = db.Close()
|
||||||
|
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create storage
|
||||||
|
store := &Storage{
|
||||||
|
db: db,
|
||||||
|
gcInterval: cfg.GCInterval,
|
||||||
|
done: make(chan struct{}),
|
||||||
|
sqlSelect: fmt.Sprintf(`SELECT v, e FROM %s WHERE k=@p1;`, cfg.Table),
|
||||||
|
sqlInsert: fmt.Sprintf(`MERGE INTO %s WITH (HOLDLOCK) AS T USING (VALUES(@p1)) AS S (k) ON (T.k = S.k)
|
||||||
|
WHEN MATCHED THEN UPDATE SET v = @p2, e = @p3
|
||||||
|
WHEN NOT MATCHED THEN INSERT (k, v, e) VALUES(@p1, @p2, @p3);`, cfg.Table),
|
||||||
|
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=@p1", cfg.Table),
|
||||||
|
sqlReset: fmt.Sprintf("TRUNCATE TABLE %s;", cfg.Table),
|
||||||
|
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= @p1 AND e != 0", cfg.Table),
|
||||||
|
}
|
||||||
|
|
||||||
|
store.checkSchema(cfg.Table)
|
||||||
|
|
||||||
|
// Start garbage collector
|
||||||
|
go store.gcTicker()
|
||||||
|
|
||||||
|
return store
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get value by key
|
||||||
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
row := s.db.QueryRow(s.sqlSelect, key)
|
||||||
|
|
||||||
|
var (
|
||||||
|
data = []byte{}
|
||||||
|
exp int64 = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := row.Scan(&data, &exp); err != nil {
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the expiration time has already passed, then return nil
|
||||||
|
if exp != 0 && exp <= time.Now().Unix() {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set key with value
|
||||||
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
|
if len(key) <= 0 || len(val) <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var expSeconds int64
|
||||||
|
if exp != 0 {
|
||||||
|
expSeconds = time.Now().Add(exp).Unix()
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := s.db.Exec(s.sqlInsert, key, val, expSeconds)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete entry by key
|
||||||
|
func (s *Storage) Delete(key string) error {
|
||||||
|
if len(key) <= 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := s.db.Exec(s.sqlDelete, key)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset all entries, including unexpired
|
||||||
|
func (s *Storage) Reset() error {
|
||||||
|
_, err := s.db.Exec(s.sqlReset)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database
|
||||||
|
func (s *Storage) Close() error {
|
||||||
|
s.done <- struct{}{}
|
||||||
|
return s.db.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
|
// gcTicker starts the gc ticker
|
||||||
|
func (s *Storage) gcTicker() {
|
||||||
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-s.done:
|
||||||
|
return
|
||||||
|
case t := <-ticker.C:
|
||||||
|
s.gc(t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// gc deletes all expired entries
|
||||||
|
func (s *Storage) gc(t time.Time) {
|
||||||
|
_, _ = s.db.Exec(s.sqlGC, t.Unix())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Storage) checkSchema(tableName string) {
|
||||||
|
var data []byte
|
||||||
|
|
||||||
|
row := s.db.QueryRow(fmt.Sprintf(checkSchemaQuery, tableName))
|
||||||
|
if err := row.Scan(&data); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.ToLower(string(data)) != "varbinary" {
|
||||||
|
fmt.Printf(checkSchemaMsg, string(data))
|
||||||
|
}
|
||||||
|
}
|
183
mssql/mssql_test.go
Normal file
183
mssql/mssql_test.go
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
package mssql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var testStore = New(Config{
|
||||||
|
Database: os.Getenv("MSSQL_DATABASE"),
|
||||||
|
Username: os.Getenv("MSSQL_USERNAME"),
|
||||||
|
Password: os.Getenv("MSSQL_PASSWORD"),
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
func Test_MSSQL_Set(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Set_Override(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Get(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, val, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Set_Expiration(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
exp = 1 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, exp)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
time.Sleep(1100 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Get_Expired(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Get_NotExist(t *testing.T) {
|
||||||
|
|
||||||
|
result, err := testStore.Get("notexist")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Delete(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key = "john"
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set(key, val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Delete(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get(key)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Reset(t *testing.T) {
|
||||||
|
var (
|
||||||
|
val = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
err := testStore.Set("john1", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Set("john2", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
err = testStore.Reset()
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get("john1")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
|
||||||
|
result, err = testStore.Get("john2")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, true, len(result) == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_GC(t *testing.T) {
|
||||||
|
var (
|
||||||
|
testVal = []byte("doe")
|
||||||
|
)
|
||||||
|
|
||||||
|
// This key should expire
|
||||||
|
err := testStore.Set("john", testVal, time.Nanosecond)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
testStore.gc(time.Now())
|
||||||
|
row := testStore.db.QueryRow(testStore.sqlSelect, "john")
|
||||||
|
err = row.Scan(nil, nil)
|
||||||
|
utils.AssertEqual(t, sql.ErrNoRows, err)
|
||||||
|
|
||||||
|
// This key should not expire
|
||||||
|
err = testStore.Set("john", testVal, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
testStore.gc(time.Now())
|
||||||
|
val, err := testStore.Get("john")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, testVal, val)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Non_UTF8(t *testing.T) {
|
||||||
|
val := []byte("0xF5")
|
||||||
|
|
||||||
|
err := testStore.Set("0xF6", val, 0)
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
|
||||||
|
result, err := testStore.Get("0xF6")
|
||||||
|
utils.AssertEqual(t, nil, err)
|
||||||
|
utils.AssertEqual(t, val, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_SslRequiredMode(t *testing.T) {
|
||||||
|
defer func() {
|
||||||
|
if recover() == nil {
|
||||||
|
utils.AssertEqual(t, true, nil, "Connection was established with a `require`")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
_ = New(Config{
|
||||||
|
Database: "fiber",
|
||||||
|
Username: "username",
|
||||||
|
Password: "password",
|
||||||
|
Reset: true,
|
||||||
|
SslMode: "require",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Close(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_MSSQL_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
MySQL is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
MySQL is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
@@ -48,11 +49,36 @@ store := mysql.New(mysql.Config{
|
|||||||
Reset: false,
|
Reset: false,
|
||||||
GCInterval: 10 * time.Second,
|
GCInterval: 10 * time.Second,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Initialize custom config using connection string
|
||||||
|
store := mysql.New(mysql.Config{
|
||||||
|
ConnectionURI: "<username>:<pw>@tcp(<HOST>:<port>)/<dbname>"
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Initialize custom config using sql db connection
|
||||||
|
db, _ := sql.Open("mysql", "<username>:<pw>@tcp(<HOST>:<port>)/<dbname>")
|
||||||
|
store := mysql.New(mysql.Config{
|
||||||
|
Db: db,
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// DB Will override ConnectionURI and all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is nil
|
||||||
|
Db *sql.DB
|
||||||
|
|
||||||
|
// Connection string to use for DB. Will override all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
ConnectionURI string
|
||||||
|
|
||||||
// Host name where the DB is hosted
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -98,6 +124,7 @@ type Config struct {
|
|||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 3306,
|
Port: 3306,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
|
@@ -1,12 +1,23 @@
|
|||||||
package mysql
|
package mysql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// DB Will override ConnectionURI and all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is nil
|
||||||
|
Db *sql.DB
|
||||||
|
|
||||||
|
// Connection string to use for DB. Will override all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
ConnectionURI string
|
||||||
|
|
||||||
// Host name where the DB is hosted
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -58,6 +69,8 @@ type Config struct {
|
|||||||
|
|
||||||
// ConfigDefault is the default config
|
// ConfigDefault is the default config
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
Db: nil,
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 3306,
|
Port: 3306,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
@@ -70,6 +83,9 @@ var ConfigDefault = Config{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) dsn() string {
|
func (c Config) dsn() string {
|
||||||
|
if c.ConnectionURI != "" {
|
||||||
|
return c.ConnectionURI
|
||||||
|
}
|
||||||
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", c.Username, c.Password, c.Host, c.Port, c.Database)
|
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", c.Username, c.Password, c.Host, c.Port, c.Database)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
module github.com/gofiber/storage/mysql
|
module github.com/gofiber/storage/mysql
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-sql-driver/mysql v1.6.0
|
github.com/go-sql-driver/mysql v1.7.0
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v1.0.1
|
||||||
)
|
)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
|
@@ -40,11 +40,18 @@ var (
|
|||||||
|
|
||||||
// New creates a new storage
|
// New creates a new storage
|
||||||
func New(config ...Config) *Storage {
|
func New(config ...Config) *Storage {
|
||||||
|
var err error
|
||||||
|
var db *sql.DB
|
||||||
|
|
||||||
// Set default config
|
// Set default config
|
||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
|
if cfg.Db != nil {
|
||||||
|
// Use passed db
|
||||||
|
db = cfg.Db
|
||||||
|
} else {
|
||||||
// Create db
|
// Create db
|
||||||
db, err := sql.Open("mysql", cfg.dsn())
|
db, err = sql.Open("mysql", cfg.dsn())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -53,6 +60,7 @@ func New(config ...Config) *Storage {
|
|||||||
db.SetMaxOpenConns(cfg.maxOpenConns)
|
db.SetMaxOpenConns(cfg.maxOpenConns)
|
||||||
db.SetMaxIdleConns(cfg.maxIdleConns)
|
db.SetMaxIdleConns(cfg.maxIdleConns)
|
||||||
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
db.SetConnMaxLifetime(cfg.connMaxLifetime)
|
||||||
|
}
|
||||||
|
|
||||||
// Ping database to ensure a connection has been made
|
// Ping database to ensure a connection has been made
|
||||||
if err := db.Ping(); err != nil {
|
if err := db.Ping(); err != nil {
|
||||||
@@ -165,6 +173,11 @@ func (s *Storage) Close() error {
|
|||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
// gcTicker starts the gc ticker
|
// gcTicker starts the gc ticker
|
||||||
func (s *Storage) gcTicker() {
|
func (s *Storage) gcTicker() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
@@ -2,11 +2,12 @@ package mysql
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gofiber/utils"
|
"github.com/gofiber/utils"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testStore = New(Config{
|
var testStore = New(Config{
|
||||||
@@ -16,6 +17,36 @@ var testStore = New(Config{
|
|||||||
Reset: true,
|
Reset: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
func Test_MYSQL_New(t *testing.T) {
|
||||||
|
newConfigStore := New(Config{
|
||||||
|
Database: os.Getenv("MYSQL_DATABASE"),
|
||||||
|
Username: os.Getenv("MYSQL_USERNAME"),
|
||||||
|
Password: os.Getenv("MYSQL_PASSWORD"),
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
utils.AssertEqual(t, true, newConfigStore.db != nil)
|
||||||
|
newConfigStore.Close()
|
||||||
|
|
||||||
|
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", os.Getenv("MYSQL_USERNAME"), os.Getenv("MYSQL_PASSWORD"), "127.0.0.1", 3306, os.Getenv("MYSQL_DATABASE"))
|
||||||
|
newConfigStore = New(Config{
|
||||||
|
ConnectionURI: dsn,
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
utils.AssertEqual(t, true, newConfigStore.db != nil)
|
||||||
|
newConfigStore.Close()
|
||||||
|
|
||||||
|
db, _ := sql.Open("mysql", dsn)
|
||||||
|
newConfigStore = New(Config{
|
||||||
|
Db: db,
|
||||||
|
Reset: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
utils.AssertEqual(t, true, newConfigStore.db != nil)
|
||||||
|
newConfigStore.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func Test_MYSQL_Set(t *testing.T) {
|
func Test_MYSQL_Set(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
key = "john"
|
key = "john"
|
||||||
@@ -162,3 +193,7 @@ func Test_MYSQL_Non_UTF8(t *testing.T) {
|
|||||||
func Test_MYSQL_Close(t *testing.T) {
|
func Test_MYSQL_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_MYSQL_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *sql.DB
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
Postgres is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
Postgres is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
@@ -49,12 +50,24 @@ store := postgres.New(postgres.Config{
|
|||||||
GCInterval: 10 * time.Second,
|
GCInterval: 10 * time.Second,
|
||||||
SslMode: "disable",
|
SslMode: "disable",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Initialize custom config using connection string
|
||||||
|
store := postgres.New(postgres.Config{
|
||||||
|
ConnectionURI: "postgresql://user:password@localhost:5432/fiber"
|
||||||
|
Reset: false,
|
||||||
|
GCInterval: 10 * time.Second,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
```go
|
```go
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// Connection string to use for DB. Will override all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
ConnectionURI string
|
||||||
|
|
||||||
// Host name where the DB is hosted
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -105,6 +118,7 @@ type Config struct {
|
|||||||
### Default Config
|
### Default Config
|
||||||
```go
|
```go
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
|
@@ -6,6 +6,11 @@ import (
|
|||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
// Connection string to use for DB. Will override all other authentication values if used
|
||||||
|
//
|
||||||
|
// Optional. Default is ""
|
||||||
|
ConnectionURI string
|
||||||
|
|
||||||
// Host name where the DB is hosted
|
// Host name where the DB is hosted
|
||||||
//
|
//
|
||||||
// Optional. Default is "127.0.0.1"
|
// Optional. Default is "127.0.0.1"
|
||||||
@@ -90,6 +95,7 @@ type Config struct {
|
|||||||
|
|
||||||
// ConfigDefault is the default config
|
// ConfigDefault is the default config
|
||||||
var ConfigDefault = Config{
|
var ConfigDefault = Config{
|
||||||
|
ConnectionURI: "",
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 5432,
|
Port: 5432,
|
||||||
Database: "fiber",
|
Database: "fiber",
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
module github.com/gofiber/storage/postgres
|
module github.com/gofiber/storage/postgres
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v1.0.1
|
||||||
github.com/lib/pq v1.10.4
|
github.com/lib/pq v1.10.7
|
||||||
)
|
)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
|
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||||
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
@@ -46,7 +46,11 @@ func New(config ...Config) *Storage {
|
|||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
// Create data source name
|
// Create data source name
|
||||||
var dsn string = "postgresql://"
|
var dsn string
|
||||||
|
if cfg.ConnectionURI != "" {
|
||||||
|
dsn = cfg.ConnectionURI
|
||||||
|
} else {
|
||||||
|
dsn = "postgresql://"
|
||||||
if cfg.Username != "" {
|
if cfg.Username != "" {
|
||||||
dsn += url.QueryEscape(cfg.Username)
|
dsn += url.QueryEscape(cfg.Username)
|
||||||
}
|
}
|
||||||
@@ -56,12 +60,17 @@ func New(config ...Config) *Storage {
|
|||||||
if cfg.Username != "" || cfg.Password != "" {
|
if cfg.Username != "" || cfg.Password != "" {
|
||||||
dsn += "@"
|
dsn += "@"
|
||||||
}
|
}
|
||||||
|
// unix socket host path
|
||||||
|
if strings.HasPrefix(cfg.Host, "/") {
|
||||||
|
dsn += fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)
|
||||||
|
} else {
|
||||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||||
|
}
|
||||||
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=%s",
|
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=%s",
|
||||||
url.QueryEscape(cfg.Database),
|
url.QueryEscape(cfg.Database),
|
||||||
int64(cfg.timeout.Seconds()),
|
int64(cfg.timeout.Seconds()),
|
||||||
cfg.SslMode,
|
cfg.SslMode)
|
||||||
)
|
}
|
||||||
|
|
||||||
// Create db
|
// Create db
|
||||||
db, err := sql.Open("postgres", dsn)
|
db, err := sql.Open("postgres", dsn)
|
||||||
@@ -180,6 +189,11 @@ func (s *Storage) Close() error {
|
|||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *sql.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
// gcTicker starts the gc ticker
|
// gcTicker starts the gc ticker
|
||||||
func (s *Storage) gcTicker() {
|
func (s *Storage) gcTicker() {
|
||||||
ticker := time.NewTicker(s.gcInterval)
|
ticker := time.NewTicker(s.gcInterval)
|
||||||
|
@@ -177,3 +177,7 @@ func Test_SslRequiredMode(t *testing.T) {
|
|||||||
func Test_Postgres_Close(t *testing.T) {
|
func Test_Postgres_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Postgres_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
@@ -17,6 +17,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *redis.Client
|
||||||
```
|
```
|
||||||
### Installation
|
### Installation
|
||||||
Redis is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
Redis is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet:
|
||||||
@@ -49,7 +50,8 @@ store := redis.New(redis.Config{
|
|||||||
Database: 0,
|
Database: 0,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
TLSConfig: nil,
|
TLSConfig: nil,
|
||||||
}
|
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||||
|
})
|
||||||
|
|
||||||
// or just the url with all information
|
// or just the url with all information
|
||||||
store = redis.New(redis.Config{
|
store = redis.New(redis.Config{
|
||||||
@@ -68,7 +70,7 @@ type Config struct {
|
|||||||
|
|
||||||
// Port where the DB is listening on
|
// Port where the DB is listening on
|
||||||
//
|
//
|
||||||
// Optional. Default is 3306
|
// Optional. Default is 6379
|
||||||
Port int
|
Port int
|
||||||
|
|
||||||
// Server username
|
// Server username
|
||||||
@@ -101,6 +103,11 @@ type Config struct {
|
|||||||
//
|
//
|
||||||
// Optional. Default is nil
|
// Optional. Default is nil
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
|
||||||
|
// Maximum number of socket connections.
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||||
|
PoolSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -116,5 +123,6 @@ var ConfigDefault = Config{
|
|||||||
Database: 0,
|
Database: 0,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
TLSConfig: nil,
|
TLSConfig: nil,
|
||||||
|
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
package redis
|
package redis
|
||||||
|
|
||||||
import "crypto/tls"
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
// Config defines the config for storage.
|
// Config defines the config for storage.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -11,7 +14,7 @@ type Config struct {
|
|||||||
|
|
||||||
// Port where the DB is listening on
|
// Port where the DB is listening on
|
||||||
//
|
//
|
||||||
// Optional. Default is 3306
|
// Optional. Default is 6379
|
||||||
Port int
|
Port int
|
||||||
|
|
||||||
// Server username
|
// Server username
|
||||||
@@ -43,6 +46,11 @@ type Config struct {
|
|||||||
// TLS Config to use. When set TLS will be negotiated.
|
// TLS Config to use. When set TLS will be negotiated.
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
|
||||||
|
// Maximum number of socket connections.
|
||||||
|
//
|
||||||
|
// Optional. Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||||
|
PoolSize int
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
// Adaptor related config options //
|
// Adaptor related config options //
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
@@ -60,6 +68,7 @@ var ConfigDefault = Config{
|
|||||||
Database: 0,
|
Database: 0,
|
||||||
Reset: false,
|
Reset: false,
|
||||||
TLSConfig: nil,
|
TLSConfig: nil,
|
||||||
|
PoolSize: 10 * runtime.GOMAXPROCS(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to set default values
|
// Helper function to set default values
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
module github.com/gofiber/storage/redis
|
module github.com/gofiber/storage/redis
|
||||||
|
|
||||||
go 1.14
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-redis/redis/v8 v8.11.4
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
github.com/gofiber/utils v0.1.2
|
github.com/gofiber/utils v1.0.1
|
||||||
)
|
)
|
||||||
|
32
redis/go.sum
32
redis/go.sum
@@ -1,5 +1,8 @@
|
|||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
@@ -7,11 +10,11 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu
|
|||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg=
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||||
github.com/gofiber/utils v0.1.2 h1:1SH2YEz4RlNS0tJlMJ0bGwO0JkqPqvq6TbHK9tXZKtk=
|
github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio=
|
||||||
github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
@@ -20,26 +23,28 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
|||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
|
||||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||||
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
|
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||||
|
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
|
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||||
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
|
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/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=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
@@ -64,12 +69,14 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
@@ -81,7 +88,6 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
|
|||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
@@ -90,9 +96,7 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE
|
|||||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
@@ -19,16 +19,18 @@ func New(config ...Config) *Storage {
|
|||||||
cfg := configDefault(config...)
|
cfg := configDefault(config...)
|
||||||
|
|
||||||
// Create new redis client
|
// Create new redis client
|
||||||
|
|
||||||
var options *redis.Options
|
var options *redis.Options
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if cfg.URL != "" {
|
if cfg.URL != "" {
|
||||||
options, err = redis.ParseURL(cfg.URL)
|
options, err = redis.ParseURL(cfg.URL)
|
||||||
options.TLSConfig = cfg.TLSConfig
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.TLSConfig = cfg.TLSConfig
|
||||||
|
options.PoolSize = cfg.PoolSize
|
||||||
} else {
|
} else {
|
||||||
options = &redis.Options{
|
options = &redis.Options{
|
||||||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
|
||||||
@@ -36,6 +38,7 @@ func New(config ...Config) *Storage {
|
|||||||
Username: cfg.Username,
|
Username: cfg.Username,
|
||||||
Password: cfg.Password,
|
Password: cfg.Password,
|
||||||
TLSConfig: cfg.TLSConfig,
|
TLSConfig: cfg.TLSConfig,
|
||||||
|
PoolSize: cfg.PoolSize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +74,6 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
|||||||
return val, err
|
return val, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set key with value
|
|
||||||
// Set key with value
|
// Set key with value
|
||||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||||
// Ain't Nobody Got Time For That
|
// Ain't Nobody Got Time For That
|
||||||
@@ -99,3 +101,8 @@ func (s *Storage) Reset() error {
|
|||||||
func (s *Storage) Close() error {
|
func (s *Storage) Close() error {
|
||||||
return s.db.Close()
|
return s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return database client
|
||||||
|
func (s *Storage) Conn() *redis.Client {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
@@ -123,6 +123,10 @@ func Test_Redis_Close(t *testing.T) {
|
|||||||
utils.AssertEqual(t, nil, testStore.Close())
|
utils.AssertEqual(t, nil, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_Redis_Conn(t *testing.T) {
|
||||||
|
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Redis_Initalize_WithURL(t *testing.T) {
|
func Test_Redis_Initalize_WithURL(t *testing.T) {
|
||||||
testStoreUrl := New(Config{
|
testStoreUrl := New(Config{
|
||||||
URL: "redis://localhost:6379",
|
URL: "redis://localhost:6379",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIE5jCCAs4CCQCX6TN/mZGB/zANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
MIIE5jCCAs4CCQCw1ymcsil7MTANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
||||||
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjEx
|
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjIx
|
||||||
MTExMTYzNjE2WhcNMzExMTA5MTYzNjE2WjA1MRMwEQYDVQQKDApSZWRpcyBUZXN0
|
MTE0MDgyNTE0WhcNMzIxMTExMDgyNTE0WjA1MRMwEQYDVQQKDApSZWRpcyBUZXN0
|
||||||
MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEB
|
MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEB
|
||||||
AQUAA4ICDwAwggIKAoICAQDnZXRXrYURmTc/559vMe7CZnwtKul2ZMOtS7UDPCcw
|
AQUAA4ICDwAwggIKAoICAQDnZXRXrYURmTc/559vMe7CZnwtKul2ZMOtS7UDPCcw
|
||||||
G3I1KHCxFkAxLNDhLtIENWId90Lc1mAIKtULy+RX2ORfOhYZ+JDK3sY25+53dgFq
|
G3I1KHCxFkAxLNDhLtIENWId90Lc1mAIKtULy+RX2ORfOhYZ+JDK3sY25+53dgFq
|
||||||
@@ -14,16 +14,16 @@ q0UUyb3aKjkluBn5rZuHxZLP14FueojFTLIXW6sNKYGqHqh4TicogmqCQAGhd9wo
|
|||||||
Wis21+xeOI9FgojASxugN+tY/64nwYQfCWsv8AuZegjyQ+AodGrtIHEbrAdgeYOj
|
Wis21+xeOI9FgojASxugN+tY/64nwYQfCWsv8AuZegjyQ+AodGrtIHEbrAdgeYOj
|
||||||
heEYDePaKMau/0vc14vlOs5EssXf49QYhciRqESc+0O85rHemgqhb4Qz31V3AGf1
|
heEYDePaKMau/0vc14vlOs5EssXf49QYhciRqESc+0O85rHemgqhb4Qz31V3AGf1
|
||||||
NP0wvqA97AmBYRLZSNc4ExvmQponOIVJY+idWiqJuRZSOeScEx0sx22MF1Nhwaw+
|
NP0wvqA97AmBYRLZSNc4ExvmQponOIVJY+idWiqJuRZSOeScEx0sx22MF1Nhwaw+
|
||||||
3QIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQCN1SnYfobIM0bY1bI/n5njNV8HEFAT
|
3QIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQDGSfsv4PsVkApOy0IYgO/ejJMqcbRF
|
||||||
X9EoXEKEg8lTJNNHSAEBDGgJMH4tc2+gQ/AQxdjCTJXlYP7ET5eHHPiUxXRqwjZr
|
Qv+PWcNG43qRuF0Fyg+6Gc+Ph8W3qNoh3lGm16WOdhMrMnnV3GKpIbl1z1Dr6Jtl
|
||||||
MDSVbipaqJ3AVkJs+XeqrxyjsJ0S4uPd82gYzcPYCP6Zq2hFGTnzlnNE8oZq+Ys9
|
BRAOW+rPN8QueB7Fb2hT7QIkTDNAhoj+ks26KvzBOkQa9IrXUQZRigystOl3k1OB
|
||||||
mdVEwWmOnD+sl8pcRuccxUfPAJoZK3A5G+X2xctJLwMM6Y82ppu5XVMbmuoMTQaK
|
BIL7c6pF9gMaskBlM5g70i+R7bb+MF1ivhB/G1QGYx97QJFdmDIr1NkcMFo/PsSN
|
||||||
pkhw6wZwah6Fa0QSgL1Lro63aDG1xDvUi8HXD7baZw/nNT/rI81ZFwT735sRkRm5
|
pcm/f8i0Vh+DfM9jnywLESptyKJCO5RnMW67ep7t/IzfnNfHLZ0avf91nEP6PRtd
|
||||||
7WXnfic8/SsQGk0zw8grUy+Q/7YSonr6LxUPd6vSJk3ZBEWo/FbDpXRSLaZQiR2S
|
3ZDXcHX1rT+T9RQNcxws92x8gOvIxrJN4asLZj8A5T6tTGlhbaR77j98NH/e8m+1
|
||||||
87gWa1Mt/a98OHR736q1jBvIeiGhC0dB1mj2Cclvtc3rO0uJzsHBzviE4008t8mn
|
MIET49DsIpIWWMW7M0CATUejHtddpFV/fXfhMXjU2/nWfzhCAXpi6BN2iE7Qihvc
|
||||||
mCVTp03nvMMO9BOpwECDOnBok4aMfqiIMJlPrl2ieiZX1lM5xiwZkzS/x9mTp6dx
|
RmjFrrSdqkPEuTDVFN/rdlWwz6m1/cqYBGlPEFEHkN+gEyhBf5Qa1dc1QUYDBYzW
|
||||||
9dhppRo/y9ViuB8PVxkDQCPjnZ+WefRXTW6Vtacc4D6LNQgJytFL4nVBAzgABfpv
|
rSR/NdH4wo21MWvJDLMb8tzp4LJJ3deW1o84UeiymjHStzJARVEX8w1/qjTohVbm
|
||||||
cUOk41qGpY/n9VscZRGadyHjz2f0l4LY6GeIDg/iF9/qzOFTTRx6eyJ4ueeq2+/T
|
PWKPe98137BQWYQ4QUhRDeZc1h6OcWdVsNg0wwNtZ9hqNGo7n7+YzyoKFLSYm6So
|
||||||
V5Ro8kzYg8aXkDY2dFLdSz8KBkaZ++8A6Q7h2SPVNfAepKGLHyB76ktMaqjonhbn
|
D+93y5AoOZlCgtUfzUPlumMXCYcvWP0yifvnNksK7eknlen9tRuhP5vUYC+DTfrP
|
||||||
rq7Y+FUj+SMshw==
|
YpIOMlHgRIe0YA==
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
@@ -1 +1 @@
|
|||||||
F93DEACFF8ACD904
|
F93DEACFF8ACD907
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkDMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkGMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
||||||
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
||||||
Fw0yMTExMTExNjM2MTZaFw0yMjExMTExNjM2MTZaMCsxEzARBgNVBAoMClJlZGlz
|
Fw0yMjExMTQwODI1MTRaFw0yMzExMTQwODI1MTRaMCsxEzARBgNVBAoMClJlZGlz
|
||||||
IFRlc3QxFDASBgNVBAMMC0NsaWVudC1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
IFRlc3QxFDASBgNVBAMMC0NsaWVudC1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||||
AQ8AMIIBCgKCAQEAtKcK6sWYkbgmWKV03WzmLbicEr9gMZVsoyxgNV52ciFnPQ72
|
AQ8AMIIBCgKCAQEAtKcK6sWYkbgmWKV03WzmLbicEr9gMZVsoyxgNV52ciFnPQ72
|
||||||
2B0PEafTO4CFdzTj3titqqOtcQVVqo6uCZroBfwCYzEgozBEPvECcY/ldw1uiN9c
|
2B0PEafTO4CFdzTj3titqqOtcQVVqo6uCZroBfwCYzEgozBEPvECcY/ldw1uiN9c
|
||||||
@@ -9,16 +9,16 @@ EyCKTAEGFqnSZwJ4UfC/JDnsNRjflLrAZ5xsQV56+yreYurY8WzCmdjpxkHQ0i0s
|
|||||||
BBG0wdd/d4G8EYSHjOhtoqckUCeHU3Z8+WOn3LeIjK2XaAZTJHC+a9Pjj376degV
|
BBG0wdd/d4G8EYSHjOhtoqckUCeHU3Z8+WOn3LeIjK2XaAZTJHC+a9Pjj376degV
|
||||||
bgEQufwrTiyOimwoMVvu2biMEyPo6KXJeofaPjAMeS2uD89czV2qjPPoLrb+x1mZ
|
bgEQufwrTiyOimwoMVvu2biMEyPo6KXJeofaPjAMeS2uD89czV2qjPPoLrb+x1mZ
|
||||||
wVWK+PIiQE5cgBGhjNTEToj0xI8ZhGiqvoLTdQIDAQABoyIwIDALBgNVHQ8EBAMC
|
wVWK+PIiQE5cgBGhjNTEToj0xI8ZhGiqvoLTdQIDAQABoyIwIDALBgNVHQ8EBAMC
|
||||||
BaAwEQYJYIZIAYb4QgEBBAQDAgeAMA0GCSqGSIb3DQEBCwUAA4ICAQAkDELpveEq
|
BaAwEQYJYIZIAYb4QgEBBAQDAgeAMA0GCSqGSIb3DQEBCwUAA4ICAQCSTgkiaEou
|
||||||
jdQ2S3meMJlBjSI5raNkZ3eduV8TMQd7w7Wti6/DYhpquYyt1SqKnDm5Req5BC0D
|
OS9K4Cq7sIPvZHmZlniti4TeMq1lgVzTjRRjSA2mP0183LrWCRouKor5ce/Zozbp
|
||||||
Q6EgJuTOJ8ElkZ0PC3mZXDsAsHrjgJ9PAgMpGv9HB4XkAjvD9YdKH610IkmOUHMu
|
0/GNaA+Iru5Ig22dtC8M2UiQGvIRCth6oJxmM/T9VeK54pIQ3XDpyl2t3xVqh74u
|
||||||
pToFdck+woe5lbQsILJl2AE72zzqCgDM1K7FxMoP6ZN8fmX+7/TSwiEfVgkwLDgp
|
1g5BvZ51X17WnuVR0Ipax1EPARkXKijvhZ1R71yd8fClXeXE4SsepUXdl80mkCKk
|
||||||
FkGPCGGnHcWYW3H+4UF1UbjP1uZwiSAq2GbzfHuUrCQhVUCnFOEygMowgK8CtZgb
|
wFqdhArQYrNcG4lI/y4VxGbPFQ28a9L8Ru44pP8+7lHCENN4T8P7CquRpHaEIyKH
|
||||||
ONJV3ePGSE8ESh/hQPnihlJBASXT7AXO/8Z4pW1J54VgamTrDKbiz/35fNAcsCId
|
v10TLZM3V5e1cZmDmmvWmdyntQR1FIHLUNWbinLkUwhYvFQPlGqXyywUDF0Jn8x8
|
||||||
tfiPXGTAG1QSWHMB+Lio9okNleb0RNHsXWQH3j6oNjPfMOGqYIpmkefv+2nivin+
|
KyUfvUXyoi+vbKQPVHY90QPyTc6hpHfSLU+jkXFmrWn1f1h7pHRBIcCFX77CTZyY
|
||||||
LAfzbcSGNXnus19HtsS+AjUNeSeoR1IIBg/aRmYeDCX1sBTugyIo8njdWtyT3Pj4
|
8Qpse0xsyDb1d07DB+RhTkw9nZeNBjj9/YPWgM/Opl5C6g0w5vMQYvIkgrGZ4Xsy
|
||||||
LgOuMi/vyNL6hocdwkTfMqceMo3cCF+G0R6V1yrZ5xKFTmkqT8E2SqHC1sHHqI9o
|
8D16nIZtoP9omGzK7La7Yov69gq+/5j4IkMda4FukDs9y71/t55mlYtR/J2rQiEo
|
||||||
G1AvHtivIlNuACilB/s7ptnDdgcGPu5aNSWPm3S1GctR6JHOxbGzSaa1UiIAHzoT
|
YIFdXng0CgqMZg3i+qPU9c9ptsm1y8R6RCZHyrrV4P4Z79TbUv0bHU0pc56lXFZw
|
||||||
B1HLud63T/6YDWTWn01zLfE1X+tdSkekTEk9qCyQZRokbvrP/oIwSpnuuzPlUlYn
|
M4HwFYGvc5cvSbTeqmpOKftlE743+8ZZuL1Ll/tscVehNiduHpogkPfN4Z2UNM8h
|
||||||
OvQBR7Rly6F3JkME8rk9sCYv995CiUr+4A==
|
3cRF3zsnD1QdBbJuvIgaO7HsOuLiZprlSw==
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIID3TCCAcUCCQD5PerP+KzZBDANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
MIID3TCCAcUCCQD5PerP+KzZBzANBgkqhkiG9w0BAQsFADA1MRMwEQYDVQQKDApS
|
||||||
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjEx
|
ZWRpcyBUZXN0MR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjIx
|
||||||
MTExMTYzNjE3WhcNMjIxMTExMTYzNjE3WjAsMRMwEQYDVQQKDApSZWRpcyBUZXN0
|
MTE0MDgyNTE0WhcNMjMxMTE0MDgyNTE0WjAsMRMwEQYDVQQKDApSZWRpcyBUZXN0
|
||||||
MRUwEwYDVQQDDAxHZW5lcmljLWNlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
MRUwEwYDVQQDDAxHZW5lcmljLWNlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
||||||
ggEKAoIBAQC/lqyvZ+JecRTRWFEoyfIYnxz+1HiZwFGL7BhSrPf7Y6CSDwV+A7tB
|
ggEKAoIBAQC/lqyvZ+JecRTRWFEoyfIYnxz+1HiZwFGL7BhSrPf7Y6CSDwV+A7tB
|
||||||
Pvu7gSQx69cfMIeS78n/pNV4P0dCgiEiOYZlqa8z1H3MVG6ZuM9uIfeubAeOvG5M
|
Pvu7gSQx69cfMIeS78n/pNV4P0dCgiEiOYZlqa8z1H3MVG6ZuM9uIfeubAeOvG5M
|
||||||
@@ -9,15 +9,15 @@ Emk9UJ3KU01XFFLCaQ9u+WPJNUQyB+hUDE92k3PQ+sh3getcgYDQm6ktt1lZOgUK
|
|||||||
JwXPNg6E1HlLDMrf4kqsCLMHCAuI7pT0RjMrK6mNEvs7hFf487zj857Jd1XJ069l
|
JwXPNg6E1HlLDMrf4kqsCLMHCAuI7pT0RjMrK6mNEvs7hFf487zj857Jd1XJ069l
|
||||||
Fhqt/LOW7jOOCEXiGtfWEJ8pApsIsc1Pdgzxh+WS1HH0qRELMv0RUJXnhw/uiE1A
|
Fhqt/LOW7jOOCEXiGtfWEJ8pApsIsc1Pdgzxh+WS1HH0qRELMv0RUJXnhw/uiE1A
|
||||||
TwLVUD91YwboSLIYf/E3m7zREaXwf14RAgMBAAEwDQYJKoZIhvcNAQELBQADggIB
|
TwLVUD91YwboSLIYf/E3m7zREaXwf14RAgMBAAEwDQYJKoZIhvcNAQELBQADggIB
|
||||||
ADWC4NSOil1EAqtrZbNAMm2beofNCcgkcO1FzYjgLXlEmq7ntvJF6LNhVBFtQCJw
|
ADZgwvnwZf+4FuUrMs7sN1CcMyZ9IIXH16Z4/nn9LjzheqvtzoEEP7fAkYjL2z48
|
||||||
dRFfYqAH2TPI9nU3NadaJFCNTC3MQaSaIOXe4ntV2H8swbNlHEonjJ+PutK+GQYL
|
S1iHMYfCGNHI+wijtbt4BrbvR1g0nqmGBfiJ0xHyFpU03goh4l/JiqSK9kf1SPAF
|
||||||
6+ZF4heW7ZgOREr1cldVFo7GWQIGKR0jlckscn6OwHcBiqxYdrW8xXfUEcRH0EJk
|
763h564PGaA7sFFKf+VR1GpvEGD6vfjm5vIs2Hn0SRF5/6dwUNZOWaCkfdBB5ddb
|
||||||
pFn8QjZlCBvMM1oVSPE4xdi04DRJJxHeE++KNH17KyoTSuvIrHvf24bKr2RlPvN8
|
1mSI8g5cEEv9+7mlIEXkdRiUJHFnuIUbH9W3ivB+XWGp9/o3y1+eK68+BkcRWBSr
|
||||||
HC6cvLGSWVZYu4MKx2tWtQUNwnA+oQ+Ri7Id+KdpEBn+UJrSoZ0hu5xz9LBakbXo
|
PkCL7V3DVj0ENV2QqovUcyu1Z1kakNubyBxs/0t84DZ2NfYSyAOr2rBn8LW8Fbfc
|
||||||
CoJJ9vzhHn4VP0Q1/UT+GQzdC39P+s2TErHKNQFql+qZYNJltJcbq3uWQHL0K0v7
|
X2E79C0RiuT6NDjMMFPchYVXeT7Fuh/ExwkE8DYCJWNZCY+pDdas1fqSt8loPZDG
|
||||||
ai7AXsGSIJHWTMT3LihKBeWFLDZBugWxpFF6SjHmcONpv1KSfxHvRw+OrNARPIof
|
M0LNCrVdI0uR5sJnau8ihKkn4UIkCP1XkXNUL1lKR86msZibIH/SqTWAUWh2SSuG
|
||||||
13/5IEx6SecT3E7EVjVZyyTgpjv3lOburIrw1amHqTtxRaewMjloYCQwjVmrgyme
|
UqMORqRksC5pobJkQDra9b2ViNCcjp/S5iq5lokxnuGu3SxQObCnei0ceBKppWy5
|
||||||
BcjZtsHzXjF7/AmlEtwnc6BE0jUwJHznfyfV8rYTwfO0Ew/xrLJ3EAvMTNMOOvfl
|
orkRwuSwMrDUX2bVcR4Zcjdg7kz7CPcqObZTEcadRaxVuWOIi/Jn1zYqOGEOavyT
|
||||||
Ll5DDqA61Ai2/61rVhoUEyjPNDjB8hyY8NB0F81Mbbhm8T4/BY+TAX9MxFv9Rt/y
|
VvEvo9DT486aLGtF9rA6o/+MydRXd1qBRgfjrV7aaBZkRm3F2ofdpLrzXnDwarei
|
||||||
3nBxLL8uIt1LUC7blW4sR+DsUEmk8nlJ/TW+166B+2+M
|
SnXRnd4rimpcL/s09DEevDkyt2aezgS/ngP4OWM1zJOf
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
-----BEGIN CERTIFICATE-----
|
||||||
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkCMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
MIIEBTCCAe2gAwIBAgIJAPk96s/4rNkFMA0GCSqGSIb3DQEBCwUAMDUxEzARBgNV
|
||||||
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
BAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhvcml0eTAe
|
||||||
Fw0yMTExMTExNjM2MTZaFw0yMjExMTExNjM2MTZaMCsxEzARBgNVBAoMClJlZGlz
|
Fw0yMjExMTQwODI1MTRaFw0yMzExMTQwODI1MTRaMCsxEzARBgNVBAoMClJlZGlz
|
||||||
IFRlc3QxFDASBgNVBAMMC1NlcnZlci1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
IFRlc3QxFDASBgNVBAMMC1NlcnZlci1vbmx5MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||||
AQ8AMIIBCgKCAQEApvPQ66+fMPnJMf8BkGMq35EAT3FJIECqd3K/DNS2zox53gSj
|
AQ8AMIIBCgKCAQEApvPQ66+fMPnJMf8BkGMq35EAT3FJIECqd3K/DNS2zox53gSj
|
||||||
P9cPuaW+JBlMUXTpGhgNKSLD8TMwJcA406A/pJScLNrdfoI9RvlKblwWWxcr2QBS
|
P9cPuaW+JBlMUXTpGhgNKSLD8TMwJcA406A/pJScLNrdfoI9RvlKblwWWxcr2QBS
|
||||||
@@ -9,16 +9,16 @@ gFvEcnAYByVQb7S9gEOZev5CHGPw9Bav4jYZ+nTc+ERDuMC6HaqrjbLk1UbkuvAV
|
|||||||
cWipYygtVFeeWx1TdHmez7n+kXcKNVojp1BbNJj5162zYXD7CnWrepA0r8b3ETEs
|
cWipYygtVFeeWx1TdHmez7n+kXcKNVojp1BbNJj5162zYXD7CnWrepA0r8b3ETEs
|
||||||
jTFRmJd6UgjZ/u+apf+DlIQ5UZOWPUs1okzmCjHAL0hp55Mj6lRW7F+ZEX8uC/pG
|
jTFRmJd6UgjZ/u+apf+DlIQ5UZOWPUs1okzmCjHAL0hp55Mj6lRW7F+ZEX8uC/pG
|
||||||
jOz/Qi2AIztZp+tYSQmyXlsEODft88D6StWKLwIDAQABoyIwIDALBgNVHQ8EBAMC
|
jOz/Qi2AIztZp+tYSQmyXlsEODft88D6StWKLwIDAQABoyIwIDALBgNVHQ8EBAMC
|
||||||
BaAwEQYJYIZIAYb4QgEBBAQDAgZAMA0GCSqGSIb3DQEBCwUAA4ICAQAkwYDPD0Qk
|
BaAwEQYJYIZIAYb4QgEBBAQDAgZAMA0GCSqGSIb3DQEBCwUAA4ICAQCEiTikIbaQ
|
||||||
mi3YyIdK/+KtiDcyTAYszQfKx5luSZ1+dU9fSc3xM8vMy2ZogpzOjjq+Gmxm+/mj
|
4reQTD0pYlofKZgczg2BdnkvxVXBp/i/qNQgvIuedKFsAHvNTOtEm4zc5cxspFvW
|
||||||
8FonHMnlBH21tyuCBxs/yXeR8bqNRL1PyGN3lI0/3IF2dlQGGUBhmnSvgt1ZL0G6
|
bEZFMObHYTmRKVJzKawCQOp7uV3+StzqpV46uERn/HVH5PhToapH0ZA/vXp9dB8U
|
||||||
jeonmiLg+DjOPr38lO1B0qY+gwhmrJkGf6+NmwfCWJg6xO7D2fKS9iRRb4DTxfms
|
rCX9FQ9Wp/NeH1fzpToGuXgUUCo3jUKpkwJhxc0OH220/l6xmbN23ivY5UTt2z9v
|
||||||
6UPpFtaHOKSGQMjvDQ86t0tAgavYBYib4xAxRwnkxfriVhncEybOpmlO5tEU1Xl8
|
x6S0gtkCD7VH7x5xxGu2T2HsJGbTefV/dknYcAYvZa5hy2wg4PyPlGSYD/UEZzVs
|
||||||
D1Ax/LYgHFZa0W89NrlFoFx6mVpBHjUml9OBYaZkzrsMix6J+47aJPyceKThh86Q
|
hJQDg3QTXvqFjdc8ZlPBoG1X028T28tiDgUuTwhH2trvY9qjk9VAVax9Wi3mkmYj
|
||||||
TmKEOV1Zko55JBUGoFDzfyCLHYiugdupwrvW1nEJ07JfODbrwbMC6uNRR5CxowgA
|
XfuSzgE/WexXrCljYAaPndUOwrd47XejlilcFCg5Otq5oPsWvFB+aSPyHHQJLG9B
|
||||||
oRS1TTHINqOKFR03AbrqQ1yDf6Ufh4k/2f+L4i8TKeH2A6IKmXfgMEWvqf6gw1tm
|
ZHa1hFP2aV/amfMQxAj9dv7StrpdWHXTk1dvryQqyt3oZl87fUDPsBrmjOgdieFn
|
||||||
7z8j0klDxH5ezQUjSJS0jf65JFLX3TxdbfZEwLvZUg73m0XUNouvq6agUmcIoeHv
|
aGcx5NzCOQG6X6GwF15pdMaA4h51kZuZqM5hkpJOfYZb19eQ0O3YzdsN92Wue4iW
|
||||||
IKycZntJ4YPPerIGMMM9iGh6ij/NWeNZSQQ5Y0wk7yXsI2PPOUj1O9blzDU5NrgN
|
URiFFWbdZWeO5lykmwBDqNFP/4XIrgczEq62/Uzyt62dfKL7f93BfAiT2qtdtKqk
|
||||||
0DXjoVQqRgFln1U6lAtqxCkjp1YIo/LGKtscpXingSj2IRsbGkT5tUMmCv+sOd+x
|
mHoya5ng+uav2TAGbHQgrNQYBJm9sB5MFwRYUWnrvWlig2whOzT/PGNohbc1JKkC
|
||||||
2DenVLRlUlVuEDkkwcA9mwxKYaafCv2tqg==
|
KSW2kUmwl+vdLoKe59o8TMfu/gn3BN+A/g==
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
|
@@ -18,6 +18,7 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error
|
|||||||
func (s *Storage) Delete(key string) error
|
func (s *Storage) Delete(key string) error
|
||||||
func (s *Storage) Reset() error
|
func (s *Storage) Reset() error
|
||||||
func (s *Storage) Close() error
|
func (s *Storage) Close() error
|
||||||
|
func (s *Storage) Conn() *ristretto.Cache
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user