mirror of
				https://github.com/gofiber/storage.git
				synced 2025-10-31 03:36:25 +08:00 
			
		
		
		
	Compare commits
	
		
			92 Commits
		
	
	
		
			rueidis/v1
			...
			minio/v0.1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 1e3b3f6a5e | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 095dbdbf59 | ||
|   | f9a87273bb | ||
|   | b6dbad7d88 | ||
|   | 8400db5161 | ||
|   | 2e2f6ca4de | ||
|   | 04d063e759 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | e50171cdf4 | ||
|   | ffd79887c1 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 994023df1e | ||
|   | e8756d084b | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 919f7f5ae7 | ||
|   | f98f6ff9e0 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | b70ea3d72a | ||
|   | 6eba76bd26 | ||
|   | fee5f98406 | ||
|   | 551552f67f | ||
|   | 6cff923227 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 1399f55ed4 | ||
|   | 79fdc2ef78 | ||
|   | f4a12a2a3b | ||
|   | edf7bf23e3 | ||
|   | 1887a32ca2 | ||
|   | a1405af086 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | de487d56be | ||
|   | 5fd9819f5f | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | b86255479c | ||
|   | 67218b0d19 | ||
|   | cdad22386e | ||
|   | cb6a705473 | ||
|   | e0523db53d | ||
|   | c49bca76d7 | ||
|   | 3d598445e3 | ||
|   | 949c597508 | ||
|   | ca32702aa0 | ||
|   | 0ccc5d3faa | ||
|   | 4c8f4dcdfc | ||
|   | d64fa185db | ||
|   | cd33dc926f | ||
|   | fd63105282 | ||
|   | dda7fcf987 | ||
|   | b597a36454 | ||
|   | b2636aa4c1 | ||
|   | b3fe37dd3d | ||
|   | d62aeb54b9 | ||
|   | dab578a096 | ||
|   | 42ff8d51c0 | ||
|   | 68fe393de4 | ||
|   | 4493457cfa | ||
|   | 5b49d3629c | ||
|   | 244330f96e | ||
|   | 7f002b3158 | ||
|   | d3d3a58f6e | ||
|   | bec8bb64e1 | ||
|   | 580a711cb1 | ||
|   | 23de4dd79e | ||
|   | 21eb34fec7 | ||
|   | 4248a8dadd | ||
|   | 5ac0392c81 | ||
|   | 10e4f45ac0 | ||
|   | 52531187b6 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 91238492d9 | ||
|   | cd048ea1e4 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 72a1732d4f | ||
|   | 3c4d46ec33 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | ef8b444526 | ||
|   | cb5c20b678 | ||
|   | 9a076a7d97 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | b3bc9aa5a8 | ||
|   | ae0bd1f240 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 2f08be65dd | ||
|   | 1276f80f98 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | dc747fad0b | ||
|   | bbbf496e55 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 67e0819a58 | ||
|   | e567a01fec | ||
|   | 41ad317a6d | ||
|   | 9ca7b53525 | ||
|   | 63dc8d573e | ||
|   | 5d97bb6ee7 | ||
|   | 9d99e7dd5b | ||
|   | 4c1b8b2c6f | ||
|   | 9570205b8a | ||
|   | 4b24a4110d | ||
|   | c0cc07ca93 | ||
|   | 32af1f92eb | ||
|   | 7b58635b7a | ||
|   | a638b6d4f2 | ||
|   | 9291b82212 | ||
|   | c338ddedc1 | ||
|   | 02d809987a | ||
|   | 2779bfdf01 | 
							
								
								
									
										6
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							| @@ -68,6 +68,12 @@ updates: | ||||
|             - "🤖 Dependencies" | ||||
|         schedule: | ||||
|             interval: "daily" | ||||
|     - package-ecosystem: "gomod" | ||||
|       directory: "/minio/" # Location of package manifests | ||||
|       labels: | ||||
|           - "🤖 Dependencies" | ||||
|       schedule: | ||||
|           interval: "daily" | ||||
|     -   package-ecosystem: "gomod" | ||||
|         directory: "/mongodb/" # Location of package manifests | ||||
|         labels: | ||||
|   | ||||
							
								
								
									
										50
									
								
								.github/release-drafter-minio.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								.github/release-drafter-minio.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| name-template: 'Minio - v$RESOLVED_VERSION' | ||||
| tag-template: 'minio/v$RESOLVED_VERSION' | ||||
| tag-prefix: minio/v | ||||
| include-paths: | ||||
|   - minio | ||||
| categories: | ||||
|     - title: '❗ Breaking Changes' | ||||
|       labels: | ||||
|           - '❗ BreakingChange' | ||||
|     - title: '🚀 New' | ||||
|       labels: | ||||
|           - '✏️ Feature' | ||||
|     - title: '🧹 Updates' | ||||
|       labels: | ||||
|           - '🧹 Updates' | ||||
|           - '🤖 Dependencies' | ||||
|     - title: '🐛 Fixes' | ||||
|       labels: | ||||
|           - '☢️ Bug' | ||||
|     - title: '📚 Documentation' | ||||
|       labels: | ||||
|           - '📒 Documentation' | ||||
| change-template: '- $TITLE (#$NUMBER)' | ||||
| change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. | ||||
| exclude-contributors: | ||||
|     - dependabot | ||||
|     - dependabot[bot] | ||||
| version-resolver: | ||||
|     major: | ||||
|         labels: | ||||
|             - 'major' | ||||
|             - '❗ BreakingChange' | ||||
|     minor: | ||||
|         labels: | ||||
|             - 'minor' | ||||
|             - '✏️ Feature' | ||||
|     patch: | ||||
|         labels: | ||||
|             - 'patch' | ||||
|             - '📒 Documentation' | ||||
|             - '☢️ Bug' | ||||
|             - '🤖 Dependencies' | ||||
|             - '🧹 Updates' | ||||
|     default: patch | ||||
| template: | | ||||
|     $CHANGES | ||||
|  | ||||
|     **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...minio/v$RESOLVED_VERSION | ||||
|  | ||||
|     Thank you $CONTRIBUTORS for making this update possible. | ||||
							
								
								
									
										2
									
								
								.github/workflows/codeql-analysis.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/codeql-analysis.yml
									
									
									
									
										vendored
									
									
								
							| @@ -16,7 +16,7 @@ jobs: | ||||
|  | ||||
|     steps: | ||||
|     - name: Checkout repository | ||||
|       uses: actions/checkout@v3 | ||||
|       uses: actions/checkout@v4 | ||||
|       with: | ||||
|         # We must fetch at least the immediate parents so that if this is | ||||
|         # a pull request then we can checkout the head. | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/workflows/golangci-lint.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/golangci-lint.yml
									
									
									
									
										vendored
									
									
								
							| @@ -24,7 +24,7 @@ jobs: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Fetch Repository | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
|       - name: Run golangci-lint | ||||
|         uses: reviewdog/action-golangci-lint@v2 | ||||
|         with: | ||||
|   | ||||
							
								
								
									
										8
									
								
								.github/workflows/gosec.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.github/workflows/gosec.yml
									
									
									
									
										vendored
									
									
								
							| @@ -26,7 +26,7 @@ jobs: | ||||
|       GO111MODULE: on | ||||
|     steps: | ||||
|       - name: Fetch Repository | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
|       - name: Install Go | ||||
|         uses: actions/setup-go@v4 | ||||
|         with: | ||||
| @@ -38,7 +38,7 @@ jobs: | ||||
|       - name: Run Gosec (root) | ||||
|         working-directory: . | ||||
|         run: | | ||||
|           gosec -exclude-dir=arangodb -exclude-dir=badger -exclude-dir=couchbase -exclude-dir=dynamodb -exclude-dir=etcd -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 -exclude-dir=pebble -exclude-dir=rueidis -exclude-dir=coherence ./.... | ||||
|           gosec . | ||||
|         # ----- | ||||
|       - name: Run Gosec (arangodb) | ||||
|         working-directory: ./arangodb | ||||
| @@ -72,6 +72,10 @@ jobs: | ||||
|         working-directory: ./memory | ||||
|         run: gosec ./... | ||||
|         # ----- | ||||
|       - name: Run Gosec (minio) | ||||
|         working-directory: ./minio | ||||
|         run: gosec ./... | ||||
|         # ----- | ||||
|       - name: Run Gosec (mongodb) | ||||
|         working-directory: ./mongodb | ||||
|         run: gosec ./... | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/workflows/govulncheck.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/govulncheck.yml
									
									
									
									
										vendored
									
									
								
							| @@ -26,7 +26,7 @@ jobs: | ||||
|       GO111MODULE: on | ||||
|     steps: | ||||
|     - name: Fetch Repository | ||||
|       uses: actions/checkout@v3 | ||||
|       uses: actions/checkout@v4 | ||||
|     - name: Install Go | ||||
|       uses: actions/setup-go@v4 | ||||
|       with: | ||||
|   | ||||
							
								
								
									
										19
									
								
								.github/workflows/release-drafter-memory.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								.github/workflows/release-drafter-memory.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| name: Release Drafter Memory | ||||
| on: | ||||
|     push: | ||||
|         # branches to consider in the event; optional, defaults to all | ||||
|         branches: | ||||
|             - master | ||||
|             - main | ||||
|         paths: | ||||
|             - 'memory/**' | ||||
| jobs: | ||||
|     draft_release_memcache: | ||||
|         runs-on: ubuntu-latest | ||||
|         timeout-minutes: 30 | ||||
|         steps: | ||||
|             -   uses: release-drafter/release-drafter@v5 | ||||
|                 with: | ||||
|                     config-name: release-drafter-memory.yml | ||||
|                 env: | ||||
|                     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||
							
								
								
									
										19
									
								
								.github/workflows/release-drafter-minio.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								.github/workflows/release-drafter-minio.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| name: Release Drafter Minio | ||||
| on: | ||||
|     push: | ||||
|         # branches to consider in the event; optional, defaults to all | ||||
|         branches: | ||||
|             - master | ||||
|             - main | ||||
|         paths: | ||||
|             - 'minio/**' | ||||
| jobs: | ||||
|     draft_release_minio: | ||||
|         runs-on: ubuntu-latest | ||||
|         timeout-minutes: 30 | ||||
|         steps: | ||||
|             -   uses: release-drafter/release-drafter@v5 | ||||
|                 with: | ||||
|                     config-name: release-drafter-minio.yml | ||||
|                 env: | ||||
|                     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||
							
								
								
									
										2
									
								
								.github/workflows/sync-docs.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/sync-docs.yml
									
									
									
									
										vendored
									
									
								
							| @@ -17,7 +17,7 @@ jobs: | ||||
|         runs-on: ubuntu-latest | ||||
|         steps: | ||||
|             - name: Checkout | ||||
|               uses: actions/checkout@v3 | ||||
|               uses: actions/checkout@v4 | ||||
|               with: | ||||
|                   ref: ${{ github.event.pull_request.head.sha }} | ||||
|                   fetch-depth: 2 | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-arangodb.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-arangodb.yml
									
									
									
									
										vendored
									
									
								
							| @@ -22,13 +22,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										4
									
								
								.github/workflows/test-azureblob.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test-azureblob.yml
									
									
									
									
										vendored
									
									
								
							| @@ -15,15 +15,15 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         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: Fetch Repository | ||||
|             uses: actions/checkout@v3 | ||||
|             uses: actions/checkout@v4 | ||||
|         -   name: Install Go | ||||
|             uses: actions/setup-go@v4 | ||||
|             with: | ||||
|   | ||||
							
								
								
									
										4
									
								
								.github/workflows/test-badger.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test-badger.yml
									
									
									
									
										vendored
									
									
								
							| @@ -14,13 +14,13 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         runs-on: ubuntu-latest | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										4
									
								
								.github/workflows/test-bbolt.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test-bbolt.yml
									
									
									
									
										vendored
									
									
								
							| @@ -15,12 +15,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/workflows/test-coherence.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/test-coherence.yml
									
									
									
									
										vendored
									
									
								
							| @@ -20,7 +20,7 @@ jobs: | ||||
|           - 1.21.x | ||||
|     steps: | ||||
|       - name: Fetch Repository | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
|       - name: Startup Coherence | ||||
|         run: | | ||||
|           docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5 | ||||
|   | ||||
							
								
								
									
										3
									
								
								.github/workflows/test-couchbase.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/test-couchbase.yml
									
									
									
									
										vendored
									
									
								
							| @@ -17,9 +17,10 @@ jobs: | ||||
|         go-version: | ||||
|           - 1.19.x | ||||
|           - 1.20.x | ||||
|           - 1.21.x | ||||
|     steps: | ||||
|       - name: Fetch Repository | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
|       - name: Install couchbase | ||||
|         run: | | ||||
|           docker run --name couchbase -d -p 8091-8097:8091-8097 -p 9123:9123 -p 11207:11207 -p 11210:11210 -p 11280:11280 -p 18091-18097:18091-18097 couchbase:enterprise-7.1.1 | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-dynamodb.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-dynamodb.yml
									
									
									
									
										vendored
									
									
								
							| @@ -20,13 +20,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										3
									
								
								.github/workflows/test-etcd.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/test-etcd.yml
									
									
									
									
										vendored
									
									
								
							| @@ -17,9 +17,10 @@ jobs: | ||||
|                 go-version: | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install etcd | ||||
|                 run: | | ||||
|                     docker run -d --name Etcd-server \ | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-memcache.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-memcache.yml
									
									
									
									
										vendored
									
									
								
							| @@ -20,13 +20,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-memory.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-memory.yml
									
									
									
									
										vendored
									
									
								
							| @@ -14,14 +14,13 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         runs-on: ubuntu-latest | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										33
									
								
								.github/workflows/test-minio.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								.github/workflows/test-minio.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| on: | ||||
|     push: | ||||
|         branches: | ||||
|             - master | ||||
|             - main | ||||
|         paths: | ||||
|             - 'minio/**' | ||||
|     pull_request: | ||||
|         paths: | ||||
|             - 'minio/**' | ||||
| name: "Tests Minio" | ||||
| jobs: | ||||
|     Tests: | ||||
|         runs-on: ubuntu-latest | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Install MinIO | ||||
|                 run: | | ||||
|                     docker run -d --restart always -p 9000:9000 --name storage-minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server /data | ||||
|  | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|                     go-version: '${{ matrix.go-version }}' | ||||
|             -   name: Run Test | ||||
|                 run: cd ./minio && go test ./... -v -race | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-mongodb.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-mongodb.yml
									
									
									
									
										vendored
									
									
								
							| @@ -20,13 +20,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										4
									
								
								.github/workflows/test-mssql.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test-mssql.yml
									
									
									
									
										vendored
									
									
								
							| @@ -32,12 +32,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-mysql.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-mysql.yml
									
									
									
									
										vendored
									
									
								
							| @@ -28,13 +28,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										3
									
								
								.github/workflows/test-pebble.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/test-pebble.yml
									
									
									
									
										vendored
									
									
								
							| @@ -16,10 +16,11 @@ jobs: | ||||
|         go-version: | ||||
|           - 1.19.x | ||||
|           - 1.20.x | ||||
|           - 1.21.x | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     -   name: Fetch Repository | ||||
|         uses: actions/checkout@v3 | ||||
|         uses: actions/checkout@v4 | ||||
|     -   name: Install Go | ||||
|         uses: actions/setup-go@v4 | ||||
|         with: | ||||
|   | ||||
							
								
								
									
										3
									
								
								.github/workflows/test-postgres.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/test-postgres.yml
									
									
									
									
										vendored
									
									
								
							| @@ -29,9 +29,10 @@ jobs: | ||||
|                 go-version: | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										6
									
								
								.github/workflows/test-redis.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/test-redis.yml
									
									
									
									
										vendored
									
									
								
							| @@ -15,15 +15,15 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|                 redis: | ||||
|                     - '6.x' | ||||
|                     - '7.x' | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|  | ||||
|             -   name: Setup Redis | ||||
|                 uses: shogo82148/actions-setup-redis@v1 | ||||
| @@ -41,7 +41,7 @@ jobs: | ||||
|                     --tls-ca-cert-file ./redis/tests/tls/ca.crt& | ||||
|  | ||||
|             -   name: Setup Redis Cluster | ||||
|                 uses: vishnudxb/redis-cluster@1.0.5 | ||||
|                 uses: vishnudxb/redis-cluster@1.0.8 | ||||
|                 with: | ||||
|                     master1-port: 7000 | ||||
|                     master2-port: 7001 | ||||
|   | ||||
							
								
								
									
										4
									
								
								.github/workflows/test-ristretto.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test-ristretto.yml
									
									
									
									
										vendored
									
									
								
							| @@ -15,12 +15,12 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/workflows/test-rueidis.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/test-rueidis.yml
									
									
									
									
										vendored
									
									
								
							| @@ -22,7 +22,7 @@ jobs: | ||||
|                     - '7.x' | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|  | ||||
|             -   name: Generate TLS certs | ||||
|                 run: ./.github/scripts/gen-test-certs.sh | ||||
|   | ||||
							
								
								
									
										4
									
								
								.github/workflows/test-s3.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test-s3.yml
									
									
									
									
										vendored
									
									
								
							| @@ -15,9 +15,9 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         steps: | ||||
|         -   name: Install MinIO | ||||
|             run: | | ||||
| @@ -29,7 +29,7 @@ jobs: | ||||
|  | ||||
|                 aws --endpoint-url http://127.0.0.1:9000/ s3 mb s3://testbucket | ||||
|         -   name: Fetch Repository | ||||
|             uses: actions/checkout@v3 | ||||
|             uses: actions/checkout@v4 | ||||
|         -   name: Install Go | ||||
|             uses: actions/setup-go@v4 | ||||
|             with: | ||||
|   | ||||
							
								
								
									
										5
									
								
								.github/workflows/test-sqlite3.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/test-sqlite3.yml
									
									
									
									
										vendored
									
									
								
							| @@ -14,14 +14,13 @@ jobs: | ||||
|         strategy: | ||||
|             matrix: | ||||
|                 go-version: | ||||
|                     - 1.17.x | ||||
|                     - 1.18.x | ||||
|                     - 1.19.x | ||||
|                     - 1.20.x | ||||
|                     - 1.21.x | ||||
|         runs-on: ubuntu-latest | ||||
|         steps: | ||||
|             -   name: Fetch Repository | ||||
|                 uses: actions/checkout@v3 | ||||
|                 uses: actions/checkout@v4 | ||||
|             -   name: Install Go | ||||
|                 uses: actions/setup-go@v4 | ||||
|                 with: | ||||
|   | ||||
| @@ -60,6 +60,7 @@ type Storage interface { | ||||
| - [Etcd](./etcd/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Etcd%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-etcd.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
| - [Memcache](./memcache/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Memcache%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memcache.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
| - [Memory](./memory/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Local+Storage%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-memory.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
| - [Minio](./minio/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Minio%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-minio.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
| - [MongoDB](./mongodb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Mongodb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mongodb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
| - [MSSQL](./mssql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MSSQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mssql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
| - [MySQL](./mysql/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+MySQL%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-mysql.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a> | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: ArangoDB | ||||
|  | ||||
| A ArangoDB storage driver using `arangodb/go-driver` and [arangodb/go-driver](https://github.com/arangodb/go-driver). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -35,13 +37,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the mysql implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/arangodb | ||||
| go get github.com/gofiber/storage/arangodb/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/arangodb" | ||||
| import "github.com/gofiber/storage/arangodb/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import ( | ||||
|  | ||||
| 	"github.com/arangodb/go-driver" | ||||
| 	"github.com/arangodb/go-driver/http" | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/gofiber/utils/v2" | ||||
| ) | ||||
|  | ||||
| // Storage interface that is implemented by storage providers | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New(Config{ | ||||
| @@ -18,7 +18,7 @@ func Test_ARANGODB_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Upsert(t *testing.T) { | ||||
| @@ -28,10 +28,10 @@ func Test_ARANGODB_Upsert(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Get(t *testing.T) { | ||||
| @@ -41,11 +41,11 @@ func Test_ARANGODB_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Set_Expiration(t *testing.T) { | ||||
| @@ -56,26 +56,23 @@ func Test_ARANGODB_Set_Expiration(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, exp) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(1100 * time.Millisecond) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Get_Expired(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
| 	key := "john" | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Get_NotExist(t *testing.T) { | ||||
|  | ||||
| 	result, err := testStore.Get("notexist") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Delete(t *testing.T) { | ||||
| @@ -85,54 +82,52 @@ func Test_ARANGODB_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Non_UTF8(t *testing.T) { | ||||
| 	val := []byte("0xF5") | ||||
|  | ||||
| 	err := testStore.Set("0xF6", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("0xF6") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_ARANGODB_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -1,13 +1,18 @@ | ||||
| module github.com/gofiber/storage/arangodb | ||||
| module github.com/gofiber/storage/arangodb/v2 | ||||
|  | ||||
| go 1.17 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/arangodb/go-driver v1.6.0 | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/gofiber/utils/v2 v2.0.0-beta.3 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e // indirect | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/google/uuid v1.3.1 // indirect | ||||
| 	github.com/pkg/errors v0.9.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -2,53 +2,23 @@ github.com/arangodb/go-driver v1.6.0 h1:NFWj/idqXZxhFVueihMSI2R9NotNIsgvNfM/xmpe | ||||
| github.com/arangodb/go-driver v1.6.0/go.mod h1:HQmdGkvNMVBTE3SIPSQ8T/ZddC6iwNsfMR+dDJQxIsI= | ||||
| github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e h1:Xg+hGrY2LcQBbxd0ZFdbGSyRKTYMZCfBbw/pMJFOk1g= | ||||
| github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e/go.mod h1:mq7Shfa/CaixoDxiyAAc5jZ6CVBAyPaNQCGS7mkj4Ho= | ||||
| github.com/coreos/go-iptables v0.6.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q= | ||||
| github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | ||||
| github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= | ||||
| github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| github.com/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/gofiber/utils/v2 v2.0.0-beta.3 h1:pfOhUDDVjBJpkWv6C5jaDyYLvpui7zQ97zpyFFsUOKw= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3/go.mod h1:jsl17+MsKfwJjM3ONCE9Rzji/j8XNbwjhUVTjzgfDCo= | ||||
| github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= | ||||
| github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= | ||||
| github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||||
| golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||||
| golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | ||||
| golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= | ||||
| 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-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||||
| golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||||
| golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||||
| golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | ||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -11,7 +11,7 @@ title: 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) | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
|  | ||||
| @@ -44,7 +44,7 @@ go mod init github.com/<user>/<repo> | ||||
| And then install the azure blob implementation: | ||||
|  | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/azureblob | ||||
| go get github.com/gofiber/storage/azureblob/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| @@ -52,7 +52,7 @@ go get github.com/gofiber/storage/azureblob | ||||
| Import the storage package. | ||||
|  | ||||
| ```go | ||||
| import "github.com/gofiber/storage/azureblob" | ||||
| import "github.com/gofiber/storage/azureblob/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -4,10 +4,11 @@ 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" | ||||
|  | ||||
| 	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" | ||||
| 	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror" | ||||
| ) | ||||
|  | ||||
| // Storage interface that is implemented by storage providers | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| package azureblob | ||||
|  | ||||
| import ( | ||||
| 	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror" | ||||
| 	"github.com/gofiber/fiber/v2/utils" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| func newStore() *Storage { | ||||
| @@ -17,6 +18,7 @@ func newStore() *Storage { | ||||
| 		}, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Get(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| @@ -25,11 +27,11 @@ func Test_AzureBlob_Get(t *testing.T) { | ||||
| 	testStore := newStore() | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Set(t *testing.T) { | ||||
| @@ -40,7 +42,7 @@ func Test_AzureBlob_Set(t *testing.T) { | ||||
|  | ||||
| 	testStore := newStore() | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Delete(t *testing.T) { | ||||
| @@ -51,10 +53,10 @@ func Test_AzureBlob_Delete(t *testing.T) { | ||||
| 	testStore := newStore() | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	if err != nil { | ||||
| @@ -62,8 +64,8 @@ func Test_AzureBlob_Delete(t *testing.T) { | ||||
| 			err = nil | ||||
| 		} | ||||
| 	} | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Override(t *testing.T) { | ||||
| @@ -74,10 +76,10 @@ func Test_AzureBlob_Override(t *testing.T) { | ||||
| 	testStore := newStore() | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Get_NotExist(t *testing.T) { | ||||
| @@ -88,24 +90,22 @@ func Test_AzureBlob_Get_NotExist(t *testing.T) { | ||||
| 			err = nil | ||||
| 		} | ||||
| 	} | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
| 	testStore := newStore() | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	if err != nil { | ||||
| @@ -113,8 +113,8 @@ func Test_AzureBlob_Reset(t *testing.T) { | ||||
| 			err = nil | ||||
| 		} | ||||
| 	} | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	if err != nil { | ||||
| @@ -122,16 +122,16 @@ func Test_AzureBlob_Reset(t *testing.T) { | ||||
| 			err = nil | ||||
| 		} | ||||
| 	} | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_S3_Conn(t *testing.T) { | ||||
| 	testStore := newStore() | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|  | ||||
| func Test_AzureBlob_Close(t *testing.T) { | ||||
| 	testStore := newStore() | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|   | ||||
| @@ -1,17 +1,18 @@ | ||||
| module github.com/gofiber/storage/azureblob | ||||
| module github.com/gofiber/storage/azureblob/v2 | ||||
|  | ||||
| go 1.18 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1 | ||||
| 	github.com/gofiber/fiber/v2 v2.48.0 | ||||
| 	github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| 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.2 // indirect | ||||
| 	github.com/google/uuid v1.3.0 // indirect | ||||
| 	golang.org/x/crypto v0.7.0 // indirect | ||||
| 	golang.org/x/net v0.8.0 // indirect | ||||
| 	golang.org/x/text v0.8.0 // indirect | ||||
| 	github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 // indirect | ||||
| 	github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	golang.org/x/net v0.14.0 // indirect | ||||
| 	golang.org/x/text v0.12.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -1,28 +1,31 @@ | ||||
| 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.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1 h1:YvQv9Mz6T8oR5ypQOL6erY0Z5t71ak1uHV4QFokCOZk= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.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/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0 h1:nVocQV40OQne5613EeLayJiRAJuKlBGy+m22qWG+WRg= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0/go.mod h1:7QJP7dr2wznCMeqIrhMgWGf7XpAQnVrJqDm9nvV3Cu4= | ||||
| github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= | ||||
| github.com/gofiber/fiber/v2 v2.48.0 h1:cRVMCb9aUJDsyHxGFLwz/sGzDggdailZZyptU9F9cU0= | ||||
| github.com/gofiber/fiber/v2 v2.48.0/go.mod h1:xqJgfqrc23FJuqGOW6DVgi3HyZEm2Mn9pRqUb2kHSX8= | ||||
| github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= | ||||
| github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= | ||||
| 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= | ||||
| 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.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= | ||||
| golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= | ||||
| golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= | ||||
| golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= | ||||
| golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= | ||||
| golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= | ||||
| golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= | ||||
| golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= | ||||
| golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= | ||||
| golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: Badger | ||||
|  | ||||
| A fast key-value DB using [dgraph-io/badger](https://github.com/dgraph-io/badger) | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
|  | ||||
| - [Signatures](#signatures) | ||||
| @@ -42,7 +44,7 @@ go mod init github.com/<user>/<repo> | ||||
| And then install the badger implementation: | ||||
|  | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/badger | ||||
| go get github.com/gofiber/storage/badger/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| @@ -50,7 +52,7 @@ go get github.com/gofiber/storage/badger | ||||
| Import the storage package. | ||||
|  | ||||
| ```go | ||||
| import "github.com/gofiber/storage/badger" | ||||
| import "github.com/gofiber/storage/badger/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/dgraph-io/badger/v3" | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/gofiber/utils/v2" | ||||
| ) | ||||
|  | ||||
| // Storage interface that is implemented by storage providers | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New() | ||||
| @@ -16,7 +16,7 @@ func Test_Badger_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Set_Override(t *testing.T) { | ||||
| @@ -26,10 +26,10 @@ func Test_Badger_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Get(t *testing.T) { | ||||
| @@ -39,11 +39,11 @@ func Test_Badger_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Set_Expiration(t *testing.T) { | ||||
| @@ -54,26 +54,23 @@ func Test_Badger_Set_Expiration(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, exp) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(1100 * time.Millisecond) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Get_Expired(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
| 	key := "john" | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Get_NotExist(t *testing.T) { | ||||
|  | ||||
| 	result, err := testStore.Get("notexist") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Delete(t *testing.T) { | ||||
| @@ -83,43 +80,41 @@ func Test_Badger_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| } | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| package badger | ||||
|  | ||||
| import ( | ||||
| 	"github.com/dgraph-io/badger/v3" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/dgraph-io/badger/v3" | ||||
| ) | ||||
|  | ||||
| // Config defines the config for storage. | ||||
|   | ||||
| @@ -1,14 +1,15 @@ | ||||
| package badger | ||||
|  | ||||
| import ( | ||||
| 	"github.com/dgraph-io/badger/v3" | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/dgraph-io/badger/v3" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| func assertRecoveryPanic(t *testing.T) { | ||||
| 	err := recover() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.Nil(t, nil, err) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Only_Name(t *testing.T) { | ||||
| @@ -17,7 +18,7 @@ func Test_Badger_Only_Name(t *testing.T) { | ||||
| 		Database:  "fiber.config.badger", | ||||
| 		UseLogger: false, | ||||
| 	}) | ||||
| 	utils.AssertEqual(t, nil, testDB.Close()) | ||||
| 	require.Nil(t, testDB.Close()) | ||||
| } | ||||
|  | ||||
| func Test_Badger_Options(t *testing.T) { | ||||
| @@ -26,11 +27,11 @@ func Test_Badger_Options(t *testing.T) { | ||||
| 		BadgerOptions: badger.DefaultOptions("fiber.with_options.badger"), | ||||
| 		UseLogger:     false, | ||||
| 	}) | ||||
| 	utils.AssertEqual(t, nil, testDB.Close()) | ||||
| 	require.Nil(t, testDB.Close()) | ||||
| } | ||||
|  | ||||
| func Test_Empty_Config(t *testing.T) { | ||||
| 	defer assertRecoveryPanic(t) | ||||
| 	testDB := New(Config{}) | ||||
| 	utils.AssertEqual(t, nil, testDB.Close()) | ||||
| 	require.Nil(t, testDB.Close()) | ||||
| } | ||||
|   | ||||
| @@ -1,27 +1,32 @@ | ||||
| module github.com/gofiber/storage/badger | ||||
| module github.com/gofiber/storage/badger/v2 | ||||
|  | ||||
| go 1.18 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/dgraph-io/badger/v3 v3.2103.5 | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/gofiber/utils/v2 v2.0.0-beta.3 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/cespare/xxhash v1.1.0 // indirect | ||||
| 	github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||||
| 	github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/dgraph-io/ristretto v0.1.1 // indirect | ||||
| 	github.com/dustin/go-humanize v1.0.0 // indirect | ||||
| 	github.com/dustin/go-humanize v1.0.1 // indirect | ||||
| 	github.com/gogo/protobuf v1.3.2 // indirect | ||||
| 	github.com/golang/glog v1.0.0 // indirect | ||||
| 	github.com/golang/glog v1.1.2 // 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.3 // indirect | ||||
| 	github.com/golang/snappy v0.0.4 // indirect | ||||
| 	github.com/google/flatbuffers v22.10.26+incompatible // indirect | ||||
| 	github.com/klauspost/compress v1.15.12 // indirect | ||||
| 	github.com/google/flatbuffers v23.5.26+incompatible // indirect | ||||
| 	github.com/google/uuid v1.3.1 // indirect | ||||
| 	github.com/klauspost/compress v1.16.7 // indirect | ||||
| 	github.com/pkg/errors v0.9.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	go.opencensus.io v0.24.0 // indirect | ||||
| 	golang.org/x/net v0.7.0 // indirect | ||||
| 	golang.org/x/sys v0.5.0 // indirect | ||||
| 	google.golang.org/protobuf v1.28.1 // indirect | ||||
| 	golang.org/x/net v0.14.0 // indirect | ||||
| 	golang.org/x/sys v0.11.0 // indirect | ||||
| 	google.golang.org/protobuf v1.31.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -7,8 +7,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA | ||||
| github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= | ||||
| github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= | ||||
| github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | ||||
| github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= | ||||
| github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | ||||
| github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= | ||||
| github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | ||||
| github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= | ||||
| github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= | ||||
| github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= | ||||
| @@ -24,20 +24,21 @@ github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWa | ||||
| 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/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= | ||||
| github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= | ||||
| github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | ||||
| github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= | ||||
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= | ||||
| github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | ||||
| github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= | ||||
| github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= | ||||
| github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3 h1:pfOhUDDVjBJpkWv6C5jaDyYLvpui7zQ97zpyFFsUOKw= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3/go.mod h1:jsl17+MsKfwJjM3ONCE9Rzji/j8XNbwjhUVTjzgfDCo= | ||||
| github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | ||||
| github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | ||||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= | ||||
| github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= | ||||
| github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= | ||||
| github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= | ||||
| github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= | ||||
| github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= | ||||
| github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= | ||||
| github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= | ||||
| @@ -54,14 +55,14 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq | ||||
| github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= | ||||
| github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= | ||||
| github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= | ||||
| github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= | ||||
| github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= | ||||
| github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= | ||||
| github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= | ||||
| github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||
| github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= | ||||
| github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||
| github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= | ||||
| github.com/google/flatbuffers v22.10.26+incompatible h1:z1QiaMyPu1x3Z6xf2u1dsLj1ZxicdGSeaLpCuIsQNZM= | ||||
| github.com/google/flatbuffers v22.10.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= | ||||
| github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= | ||||
| github.com/google/flatbuffers v23.5.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.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| @@ -72,15 +73,19 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | ||||
| github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= | ||||
| github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= | ||||
| github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= | ||||
| github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= | ||||
| github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | ||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||
| github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= | ||||
| github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= | ||||
| github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= | ||||
| github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | ||||
| github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | ||||
| github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= | ||||
| github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||||
| github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||||
| github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= | ||||
| github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||||
| github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= | ||||
| github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= | ||||
| @@ -108,8 +113,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= | ||||
| github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= | ||||
| github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= | ||||
| github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| @@ -136,8 +142,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL | ||||
| golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-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.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= | ||||
| golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= | ||||
| golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= | ||||
| golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= | ||||
| golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | ||||
| golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| @@ -152,8 +158,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w | ||||
| golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= | ||||
| golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| @@ -192,9 +198,10 @@ 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.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.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= | ||||
| google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||
| google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= | ||||
| google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= | ||||
| gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -11,6 +11,7 @@ title: 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. | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| @@ -36,13 +37,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the s3 implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/bbolt | ||||
| go get github.com/gofiber/storage/bbolt/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/bbolt" | ||||
| import "github.com/gofiber/storage/bbolt/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -3,7 +3,7 @@ package bbolt | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/gofiber/utils/v2" | ||||
| 	"go.etcd.io/bbolt" | ||||
| ) | ||||
|  | ||||
| @@ -18,7 +18,7 @@ func New(config ...Config) *Storage { | ||||
| 	// Set default config | ||||
| 	cfg := configDefault(config...) | ||||
|  | ||||
| 	conn, err := bbolt.Open(cfg.Database, 0666, &bbolt.Options{ | ||||
| 	conn, err := bbolt.Open(cfg.Database, 0o666, &bbolt.Options{ | ||||
| 		Timeout:  cfg.Timeout, | ||||
| 		ReadOnly: cfg.ReadOnly, | ||||
| 	}) | ||||
| @@ -42,7 +42,6 @@ func New(config ...Config) *Storage { | ||||
| 		conn:   conn, | ||||
| 		bucket: cfg.Bucket, | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| // Get value by key | ||||
|   | ||||
| @@ -3,7 +3,7 @@ package bbolt | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New() | ||||
| @@ -15,7 +15,7 @@ func Test_Bbolt_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Bbolt_Set_Override(t *testing.T) { | ||||
| @@ -25,10 +25,10 @@ func Test_Bbolt_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Bbolt_Get(t *testing.T) { | ||||
| @@ -38,18 +38,17 @@ func Test_Bbolt_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(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) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Bbolt_Delete(t *testing.T) { | ||||
| @@ -59,43 +58,41 @@ func Test_Bbolt_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Bbolt_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Bbolt_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_Bbolt_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
							
								
								
									
										15
									
								
								bbolt/go.mod
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								bbolt/go.mod
									
									
									
									
									
								
							| @@ -1,10 +1,17 @@ | ||||
| module github.com/gofiber/storage/bbolt | ||||
| module github.com/gofiber/storage/bbolt/v2 | ||||
|  | ||||
| go 1.18 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/gofiber/utils v1.0.1 | ||||
| 	github.com/gofiber/utils/v2 v2.0.0-beta.3 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| 	go.etcd.io/bbolt v1.3.7 | ||||
| ) | ||||
|  | ||||
| require golang.org/x/sys v0.4.0 // indirect | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/google/uuid v1.3.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	golang.org/x/sys v0.11.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										18
									
								
								bbolt/go.sum
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								bbolt/go.sum
									
									
									
									
									
								
							| @@ -1,10 +1,18 @@ | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| 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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3 h1:pfOhUDDVjBJpkWv6C5jaDyYLvpui7zQ97zpyFFsUOKw= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3/go.mod h1:jsl17+MsKfwJjM3ONCE9Rzji/j8XNbwjhUVTjzgfDCo= | ||||
| github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= | ||||
| github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= | ||||
| go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= | ||||
| golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= | ||||
| golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| package bbolt | ||||
|  | ||||
| import ( | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/gofiber/utils/v2" | ||||
| 	"go.etcd.io/bbolt" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -35,7 +35,7 @@ necessary for the client to operate correctly. | ||||
| To start a Coherence cluster using Docker, issue the following: | ||||
|  | ||||
| ```bash | ||||
| docker run -d -p 1408:1408 ghcr.io/oracle/coherencestore-ce:22.06.5 | ||||
| docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:22.06.5 | ||||
| ``` | ||||
|  | ||||
| See the documentation [here](https://pkg.go.dev/github.com/oracle/coherence-go-client/coherence#hdr-Obtaining_a_Session) on connection options | ||||
|   | ||||
| @@ -1,17 +1,18 @@ | ||||
| module coherence | ||||
| module github.com/gofiber/storage/coherence | ||||
|  | ||||
| go 1.19 | ||||
|  | ||||
| require github.com/oracle/coherence-go-client v1.0.1 | ||||
|  | ||||
| require google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect | ||||
|  | ||||
| require ( | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/golang/protobuf v1.5.2 // indirect | ||||
| 	github.com/google/uuid v1.3.0 // indirect | ||||
| 	golang.org/x/net v0.8.0 // indirect | ||||
| 	golang.org/x/sys v0.6.0 // indirect | ||||
| 	golang.org/x/text v0.8.0 // indirect | ||||
| 	google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect | ||||
| 	google.golang.org/grpc v1.53.0 // indirect | ||||
| 	google.golang.org/protobuf v1.28.1 // indirect | ||||
| 	github.com/golang/protobuf v1.5.3 // indirect | ||||
| 	github.com/google/uuid v1.3.1 // indirect | ||||
| 	golang.org/x/net v0.14.0 // indirect | ||||
| 	golang.org/x/sys v0.11.0 // indirect | ||||
| 	golang.org/x/text v0.12.0 // indirect | ||||
| 	google.golang.org/grpc v1.57.0 // indirect | ||||
| 	google.golang.org/protobuf v1.31.0 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| 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.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= | ||||
| github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= | ||||
| github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | ||||
| github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | ||||
| github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= | ||||
| github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= | ||||
| github.com/oracle/coherence-go-client v1.0.1 h1:MJ9S46+G8DHg/b3c/XB+mGA58wmTE0HdBCH1t+WrIBs= | ||||
| github.com/oracle/coherence-go-client v1.0.1/go.mod h1:tdIKuX6brsdTCARlbxeRYiOF0TA4tA8ujHO4BCS1mjk= | ||||
| golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= | ||||
| golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= | ||||
| golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= | ||||
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= | ||||
| golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= | ||||
| golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= | ||||
| golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= | ||||
| golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= | ||||
| google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= | ||||
| google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= | ||||
| google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= | ||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= | ||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= | ||||
| google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= | ||||
| google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= | ||||
| 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.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= | ||||
| google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||
| google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= | ||||
| google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||
| gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: Couchbase | ||||
|  | ||||
| A Couchbase storage driver using [couchbase/gocb](https://github.com/couchbase/gocb). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -35,13 +37,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the Couchbase implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/couchbase | ||||
| go get github.com/gofiber/storage/couchbase/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/couchbase" | ||||
| import "github.com/gofiber/storage/couchbase/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -26,7 +26,6 @@ func New(config ...Config) *Storage { | ||||
| 		}, | ||||
| 		Transcoder: gocb.NewLegacyTranscoder(), | ||||
| 	}) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| func TestSetCouchbase_ShouldReturnNoError(t *testing.T) { | ||||
| @@ -17,7 +17,7 @@ func TestSetCouchbase_ShouldReturnNoError(t *testing.T) { | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("test"), 0) | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestGetCouchbase_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) { | ||||
| @@ -30,8 +30,8 @@ func TestGetCouchbase_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) { | ||||
|  | ||||
| 	val, err := testStorage.Get("not_found_key") | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, 0, len(val)) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(val)) | ||||
| } | ||||
|  | ||||
| func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) { | ||||
| @@ -43,12 +43,12 @@ func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	val, err := testStorage.Get("test") | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, []byte("fiber_test_value")) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, []byte("fiber_test_value")) | ||||
| } | ||||
|  | ||||
| func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) { | ||||
| @@ -60,14 +60,14 @@ func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 3*time.Second) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(6 * time.Second) | ||||
|  | ||||
| 	val, err := testStorage.Get("test") | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, 0, len(val)) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(val)) | ||||
| } | ||||
|  | ||||
| func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) { | ||||
| @@ -79,13 +79,13 @@ func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStorage.Delete("test") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	_, err = testStorage.Get("test") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) { | ||||
| @@ -97,13 +97,13 @@ func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStorage.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	_, err = testStorage.Get("test") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestClose_CloseShouldReturn_NoError(t *testing.T) { | ||||
| @@ -115,7 +115,7 @@ func TestClose_CloseShouldReturn_NoError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Close() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestGetConn_ReturnsNotNill(t *testing.T) { | ||||
| @@ -125,6 +125,5 @@ func TestGetConn_ReturnsNotNill(t *testing.T) { | ||||
| 		Host:     "127.0.0.1:8091", | ||||
| 		Bucket:   "fiber_storage", | ||||
| 	}) | ||||
| 	conn := testStorage.Conn() | ||||
| 	utils.AssertEqual(t, true, conn != nil) | ||||
| 	require.True(t, testStorage.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -1,14 +1,17 @@ | ||||
| module github.com/gofiber/storage/couchbase | ||||
| module github.com/gofiber/storage/couchbase/v2 | ||||
|  | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/couchbase/gocb/v2 v2.6.3 | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/couchbase/gocbcore/v10 v10.2.3 // indirect | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/golang/snappy v0.0.4 // indirect | ||||
| 	github.com/google/uuid v1.3.0 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -8,8 +8,6 @@ github.com/couchbaselabs/gocaves/client v0.0.0-20230404095311-05e3ba4f0259/go.mo | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= | ||||
| github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||
| github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | ||||
| @@ -22,8 +20,10 @@ github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= | ||||
| github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= | ||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= | ||||
| github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| 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= | ||||
|   | ||||
| @@ -13,7 +13,7 @@ A DynamoDB storage driver using [aws/aws-sdk-go-v2](https://github.com/aws/aws-s | ||||
|  | ||||
| **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) | ||||
|  | ||||
| .... | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| @@ -43,13 +43,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the dynamodb implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/dynamodb | ||||
| go get github.com/gofiber/storage/dynamodb/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/dynamodb" | ||||
| import "github.com/gofiber/storage/dynamodb/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -3,7 +3,7 @@ package dynamodb | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New( | ||||
| @@ -25,7 +25,7 @@ func Test_DynamoDB_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_DynamoDB_Set_Override(t *testing.T) { | ||||
| @@ -35,10 +35,10 @@ func Test_DynamoDB_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_DynamoDB_Get(t *testing.T) { | ||||
| @@ -48,18 +48,17 @@ func Test_DynamoDB_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(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) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_DynamoDB_Delete(t *testing.T) { | ||||
| @@ -69,43 +68,41 @@ func Test_DynamoDB_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_DynamoDB_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_DynamoDB_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_DynamoDB_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -1,28 +1,31 @@ | ||||
| module github.com/gofiber/storage/dynamodb | ||||
| module github.com/gofiber/storage/dynamodb/v2 | ||||
|  | ||||
| go 1.17 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/aws/aws-sdk-go-v2 v1.20.3 | ||||
| 	github.com/aws/aws-sdk-go-v2/config v1.18.35 | ||||
| 	github.com/aws/aws-sdk-go-v2/credentials v1.13.34 | ||||
| 	github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.38 | ||||
| 	github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.4 | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/aws/aws-sdk-go-v2 v1.21.0 | ||||
| 	github.com/aws/aws-sdk-go-v2/config v1.18.38 | ||||
| 	github.com/aws/aws-sdk-go-v2/credentials v1.13.36 | ||||
| 	github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.39 | ||||
| 	github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.5 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.10 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.40 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.34 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/internal/ini v1.3.41 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.4 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.5 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.34 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.34 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/sso v1.13.4 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.4 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/sts v1.21.4 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.35 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect | ||||
| 	github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect | ||||
| 	github.com/aws/smithy-go v1.14.2 // indirect | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/jmespath/go-jmespath v0.4.0 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -1,41 +1,40 @@ | ||||
| github.com/aws/aws-sdk-go-v2 v1.20.3 h1:lgeKmAZhlj1JqN43bogrM75spIvYnRxqTAh1iupu1yE= | ||||
| github.com/aws/aws-sdk-go-v2 v1.20.3/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= | ||||
| github.com/aws/aws-sdk-go-v2/config v1.18.35 h1:uU9rgCzrW/pVRUUlRULiwKQe8RoEDst1NQu4Qo8kOtk= | ||||
| github.com/aws/aws-sdk-go-v2/config v1.18.35/go.mod h1:7xF1yr9GBMfYRQI4PLHO8iceqKLM6DpGVEvXI38HB/A= | ||||
| github.com/aws/aws-sdk-go-v2/credentials v1.13.34 h1:/EYG4lzayDd5PY6HQQ2Qyj/cD6CR3kz96BjTZAO5tNo= | ||||
| github.com/aws/aws-sdk-go-v2/credentials v1.13.34/go.mod h1:+wgdxCGNulHme6kTMZuDL9KOagLPloemoYkfjpQkSEU= | ||||
| github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.38 h1:8qKhDyyVtFd4YG1mz7AhX4laQ0wkxKJuNsdX1Si+gDk= | ||||
| github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.38/go.mod h1:3NuokqGQKXxywI3RhwIGliwcsz73Ioja/tIZFpgXZ68= | ||||
| github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.10 h1:mgOrtwYfJZ4e3QJe1TrliC/xIkauafGMdLLuCExOqcs= | ||||
| github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.10/go.mod h1:wMsSLVM2hRpDVhd+3dtLUzqwm7/fjuhNN+b1aOLDt6g= | ||||
| github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.40 h1:CXceCS9BrDInRc74GDCQ8Qyk/Gp9VLdK+Rlve+zELSE= | ||||
| github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.40/go.mod h1:5kKmFhLeOVy6pwPDpDNA6/hK/d6URC98pqDDqHgdBx4= | ||||
| github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.34 h1:B+nZtd22cbko5+793hg7LEaTeLMiZwlgCLUrN5Y0uzg= | ||||
| github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.34/go.mod h1:RZP0scceAyhMIQ9JvFp7HvkpcgqjL4l/4C+7RAeGbuM= | ||||
| github.com/aws/aws-sdk-go-v2/internal/ini v1.3.41 h1:EcSFdpLdkF3FWizimox0qYLuorn9e4PNMR27mvshGLs= | ||||
| github.com/aws/aws-sdk-go-v2/internal/ini v1.3.41/go.mod h1:mKxUXW+TuwpCKKHVlmHGVVuBi9y9LKW8AiQodg23M5E= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.4 h1:x3V1JRHq7q9RUbDpaeNpLH7QoipGpCo3fdnMMuSeABU= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.4/go.mod h1:aryF4jxgjhbqpdhj8QybUZI3xYrX8MQIKm4WbOv8Whg= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.4 h1:W7zl4rdlkSRWa31l7wOtUND6wKcWPW2POvPxMFMBvHM= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.4/go.mod h1:W+Ct7i87BUgyqJy50w1NpC0idqnW2w67XLzihxCb5Hk= | ||||
| github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= | ||||
| github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= | ||||
| github.com/aws/aws-sdk-go-v2/config v1.18.38 h1:CByQCELMgm2tM1lAehx3XNg0R/pfeXsYzqn0Aq2chJQ= | ||||
| github.com/aws/aws-sdk-go-v2/config v1.18.38/go.mod h1:vNm9Hf5VgG2fSUWhT3zFrqN/RosGcabFMYgiSoxKFU8= | ||||
| github.com/aws/aws-sdk-go-v2/credentials v1.13.36 h1:ps0cPswZjpsOk6sLwG6fdXTzrYjCplgPEyG3OUbbdqE= | ||||
| github.com/aws/aws-sdk-go-v2/credentials v1.13.36/go.mod h1:sY2phUzxbygoyDtTXhqi7GjGjCQ1S5a5Rj8u3ksBxCg= | ||||
| github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.39 h1:DX/r3aNL7pIVn0K5a+ESL0Fw9ti7Rj05pblEiIJtPmQ= | ||||
| github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.10.39/go.mod h1:oTk09orqXlwSKnKf+UQhy+4Ci7aCo9x8hn0ZvPCLrns= | ||||
| github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= | ||||
| github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= | ||||
| github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= | ||||
| github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= | ||||
| github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= | ||||
| github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= | ||||
| github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= | ||||
| github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.5 h1:EeNQ3bDA6hlx3vifHf7LT/l9dh9w7D2XgCdaD11TRU4= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.5/go.mod h1:X3ThW5RPV19hi7bnQ0RMAiBjZbzxj4rZlj+qdctbMWY= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.5 h1:xoalM/e1YsT6jkLKl6KA9HUiJANwn2ypJsM9lhW2WP0= | ||||
| github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.15.5/go.mod h1:7QtKdGj66zM4g5hPgxHRQgFGLGal4EgwggTw5OZH56c= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 h1:m0QTSI6pZYJTk5WSKx3fm5cNW/DCicVzULBgU/6IyD0= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14/go.mod h1:dDilntgHy9WnHXsh7dDtUPgHKEfTJIBUTHM8OWm0f/0= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.34 h1:JlxVMFDHivlhNOIxd2O/9z4O0wC2zIC4lRB71lejVHU= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.34/go.mod h1:CDPcT6pljRaqz1yLsOgPUvOPOczFvXuJxOKzDzAbF0c= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.34 h1:JwvXk+1ePAD9xkFHprhHYqwsxLDcbNFsPI1IAT2sPS0= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.34/go.mod h1:ytsF+t+FApY2lFnN51fJKPhH6ICKOPXKEcwwgmJEdWI= | ||||
| github.com/aws/aws-sdk-go-v2/service/sso v1.13.4 h1:WZPZ7Zf6Yo13lsfTetFrLU/7hZ9CXESDpdIHvmLxQFQ= | ||||
| github.com/aws/aws-sdk-go-v2/service/sso v1.13.4/go.mod h1:FP05hDXTLouXwAMQ1swqybHy7tHySblMkBMKSumaKg0= | ||||
| github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.4 h1:pYFM2U/3/4RLrlMSYXwL1XPBCWvaePk2p+0+i/BgHOs= | ||||
| github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.4/go.mod h1:4pdlNASc29u0j9bq2jIQcBghG5Lx2oQAIj91vo1u1t8= | ||||
| github.com/aws/aws-sdk-go-v2/service/sts v1.21.4 h1:zj4jxK3L54tGyqKleKDMK4vHolENxlq11dF0v1oBkJo= | ||||
| github.com/aws/aws-sdk-go-v2/service/sts v1.21.4/go.mod h1:CQRMCzYvl5eeAQW3AWkRLS+zGGXCucBnsiQlrs+tCeo= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.35 h1:UKjpIDLVF90RfV88XurdduMoTxPqtGHZMIDYZQM7RO4= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.35/go.mod h1:B3dUg0V6eJesUTi+m27NUkj7n8hdDKYUpxj8f4+TqaQ= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= | ||||
| github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= | ||||
| github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 h1:2PylFCfKCEDv6PeSN09pC/VUiRd10wi1VfHG5FrW0/g= | ||||
| github.com/aws/aws-sdk-go-v2/service/sso v1.13.6/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= | ||||
| github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= | ||||
| github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= | ||||
| github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= | ||||
| github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= | ||||
| github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= | ||||
| github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= | ||||
| github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/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= | ||||
| @@ -45,6 +44,11 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= | ||||
| gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: Etcd | ||||
|  | ||||
| A Etcd storage driver using [`etcd-io/etcd`](https://github.com/etcd-io/etcd). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -36,13 +38,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the etcd implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/etcd | ||||
| go get github.com/gofiber/storage/etcd/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/etcd" | ||||
| import "github.com/gofiber/storage/etcd/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -2,8 +2,9 @@ package etcd | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"go.etcd.io/etcd/client/v3" | ||||
| 	"time" | ||||
|  | ||||
| 	"go.etcd.io/etcd/client/v3" | ||||
| ) | ||||
|  | ||||
| type Storage struct { | ||||
| @@ -36,7 +37,6 @@ func (s *Storage) Get(key string) ([]byte, error) { | ||||
| 		return nil, nil | ||||
| 	} | ||||
| 	item, err := s.db.Get(context.Background(), key) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -55,7 +55,6 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error { | ||||
| 	} | ||||
|  | ||||
| 	lease, err := s.db.Grant(context.Background(), int64(exp.Seconds())) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -83,7 +82,6 @@ func (s *Storage) Delete(key string) error { | ||||
|  | ||||
| func (s *Storage) Reset() error { | ||||
| 	_, err := s.db.Delete(context.Background(), "", clientv3.WithPrefix()) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| package etcd | ||||
|  | ||||
| import ( | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| func TestSetEtcd_ShouldReturnNoError(t *testing.T) { | ||||
| @@ -17,7 +18,7 @@ func TestSetEtcd_ShouldReturnNoError(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStorage.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestGetEtcd_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) { | ||||
| @@ -27,8 +28,8 @@ func TestGetEtcd_ShouldReturnNil_WhenDocumentNotFound(t *testing.T) { | ||||
|  | ||||
| 	val, err := testStorage.Get("not_found_key") | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, 0, len(val)) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(val)) | ||||
| } | ||||
|  | ||||
| func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) { | ||||
| @@ -37,12 +38,12 @@ func TestSetAndGet_GetShouldReturn_SettedValueWithoutError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	val, err := testStorage.Get("test") | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, []byte("fiber_test_value")) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, []byte("fiber_test_value")) | ||||
| } | ||||
|  | ||||
| func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) { | ||||
| @@ -51,14 +52,14 @@ func TestSetAndGet_GetShouldReturnNil_WhenTTLExpired(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 3*time.Second) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(6 * time.Second) | ||||
|  | ||||
| 	val, err := testStorage.Get("test") | ||||
|  | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, 0, len(val)) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(val)) | ||||
| } | ||||
|  | ||||
| func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) { | ||||
| @@ -67,13 +68,13 @@ func TestSetAndDelete_DeleteShouldReturn_NoError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStorage.Delete("test") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	_, err = testStorage.Get("test") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) { | ||||
| @@ -82,13 +83,13 @@ func TestSetAndReset_ResetShouldReturn_NoError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Set("test", []byte("fiber_test_value"), 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStorage.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	_, err = testStorage.Get("test") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestClose_CloseShouldReturn_NoError(t *testing.T) { | ||||
| @@ -97,7 +98,7 @@ func TestClose_CloseShouldReturn_NoError(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	err := testStorage.Close() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func TestGetConn_ReturnsNotNill(t *testing.T) { | ||||
| @@ -105,6 +106,5 @@ func TestGetConn_ReturnsNotNill(t *testing.T) { | ||||
| 		Endpoints: []string{"localhost:2379"}, | ||||
| 	}) | ||||
|  | ||||
| 	conn := testStorage.Conn() | ||||
| 	utils.AssertEqual(t, true, conn != nil) | ||||
| 	require.True(t, testStorage.Conn() != nil) | ||||
| } | ||||
|   | ||||
							
								
								
									
										28
									
								
								etcd/go.mod
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								etcd/go.mod
									
									
									
									
									
								
							| @@ -1,26 +1,30 @@ | ||||
| module github.com/gofiber/storage/etcd | ||||
| module github.com/gofiber/storage/etcd/v2 | ||||
|  | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| 	go.etcd.io/etcd/client/v3 v3.5.9 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/coreos/go-semver v0.3.1 // indirect | ||||
| 	github.com/coreos/go-systemd/v22 v22.3.2 // indirect | ||||
| 	github.com/coreos/go-systemd/v22 v22.5.0 // indirect | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/gogo/protobuf v1.3.2 // indirect | ||||
| 	github.com/golang/protobuf v1.5.3 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	go.etcd.io/etcd/api/v3 v3.5.9 // indirect | ||||
| 	go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect | ||||
| 	go.uber.org/atomic v1.7.0 // indirect | ||||
| 	go.uber.org/multierr v1.6.0 // indirect | ||||
| 	go.uber.org/zap v1.24.0 // indirect | ||||
| 	golang.org/x/net v0.8.0 // indirect | ||||
| 	golang.org/x/sys v0.6.0 // indirect | ||||
| 	golang.org/x/text v0.8.0 // indirect | ||||
| 	google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect | ||||
| 	google.golang.org/grpc v1.55.0 // indirect | ||||
| 	google.golang.org/protobuf v1.30.0 // indirect | ||||
| 	go.uber.org/multierr v1.11.0 // indirect | ||||
| 	go.uber.org/zap v1.25.0 // indirect | ||||
| 	golang.org/x/net v0.14.0 // indirect | ||||
| 	golang.org/x/sys v0.11.0 // indirect | ||||
| 	golang.org/x/text v0.12.0 // indirect | ||||
| 	google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect | ||||
| 	google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect | ||||
| 	google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect | ||||
| 	google.golang.org/grpc v1.57.0 // indirect | ||||
| 	google.golang.org/protobuf v1.31.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										56
									
								
								etcd/go.sum
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								etcd/go.sum
									
									
									
									
									
								
							| @@ -1,14 +1,11 @@ | ||||
| github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= | ||||
| github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= | ||||
| github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= | ||||
| github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= | ||||
| github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= | ||||
| github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= | ||||
| github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | ||||
| 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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | ||||
| github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | ||||
| github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= | ||||
| @@ -18,12 +15,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ | ||||
| github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | ||||
| github.com/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/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||||
| github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| go.etcd.io/etcd/api/v3 v3.5.9 h1:4wSsluwyTbGGmyjJktOf3wFQoTBIURXHnq9n/G/JQHs= | ||||
| @@ -32,13 +27,11 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.9 h1:oidDC4+YEuSIQbsR94rY9gur91UPL6DnxDCIYd2I | ||||
| go.etcd.io/etcd/client/pkg/v3 v3.5.9/go.mod h1:y+CzeSmkMpWN2Jyu1npecjB9BBnABxGM4pN8cGuJeL4= | ||||
| go.etcd.io/etcd/client/v3 v3.5.9 h1:r5xghnU7CwbUxD/fbUtRyJGaYNfDun8sp/gTr1hew6E= | ||||
| go.etcd.io/etcd/client/v3 v3.5.9/go.mod h1:i/Eo5LrZ5IKqpbtpPDuaUnDOUv471oDg8cjQaUr2MbA= | ||||
| go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= | ||||
| go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= | ||||
| go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= | ||||
| go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= | ||||
| go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= | ||||
| go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= | ||||
| go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= | ||||
| go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= | ||||
| go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | ||||
| go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | ||||
| go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= | ||||
| go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||||
| @@ -48,20 +41,20 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn | ||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-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.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= | ||||
| golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= | ||||
| golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= | ||||
| golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-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.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= | ||||
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/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.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= | ||||
| golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= | ||||
| golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= | ||||
| golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= | ||||
| @@ -70,14 +63,19 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T | ||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= | ||||
| google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= | ||||
| google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= | ||||
| google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= | ||||
| google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= | ||||
| google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= | ||||
| google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= | ||||
| google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= | ||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= | ||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= | ||||
| google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= | ||||
| google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= | ||||
| 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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= | ||||
| google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||
| google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= | ||||
| google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: Memcache | ||||
|  | ||||
| A Memcache storage driver using [`bradfitz/gomemcache`](https://github.com/bradfitz/gomemcache). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -36,7 +38,7 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the memory implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/memory | ||||
| go get github.com/gofiber/storage/memory/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
|   | ||||
| @@ -1,8 +1,14 @@ | ||||
| module github.com/gofiber/storage/memcache | ||||
| module github.com/gofiber/storage/memcache/v2 | ||||
|  | ||||
| go 1.17 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822 | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/bradfitz/gomemcache v0.0.0-20230611145640-acc696258285 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -1,4 +1,12 @@ | ||||
| github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822 h1:hjXJeBcAMS1WGENGqDpzvmgS43oECTx8UXq31UBu0Jw= | ||||
| github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/bradfitz/gomemcache v0.0.0-20230611145640-acc696258285 h1:Dr+ezPI5ivhMn/3WOoB86XzMhie146DNaBbhaQWZHMY= | ||||
| github.com/bradfitz/gomemcache v0.0.0-20230611145640-acc696258285/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= | ||||
| 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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	mc "github.com/bradfitz/gomemcache/memcache" | ||||
| 	"github.com/gofiber/utils" | ||||
| ) | ||||
|  | ||||
| // Storage interface that is implemented by storage providers | ||||
| @@ -21,7 +20,7 @@ func New(config ...Config) *Storage { | ||||
| 	cfg := configDefault(config...) | ||||
|  | ||||
| 	// Split comma separated servers into slice | ||||
| 	serverList := strings.Split(utils.Trim(cfg.Servers, ' '), ",") | ||||
| 	serverList := strings.Split(strings.TrimSpace(cfg.Servers), ",") | ||||
|  | ||||
| 	// Create db | ||||
| 	db := mc.New(serverList...) | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New() | ||||
| @@ -16,7 +16,7 @@ func Test_Memcache_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Set_Override(t *testing.T) { | ||||
| @@ -26,10 +26,10 @@ func Test_Memcache_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Get(t *testing.T) { | ||||
| @@ -39,11 +39,11 @@ func Test_Memcache_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Set_Expiration(t *testing.T) { | ||||
| @@ -54,26 +54,23 @@ func Test_Memcache_Set_Expiration(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, exp) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(1100 * time.Millisecond) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Get_Expired(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
| 	key := "john" | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Get_NotExist(t *testing.T) { | ||||
|  | ||||
| 	result, err := testStore.Get("notexist") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Delete(t *testing.T) { | ||||
| @@ -83,43 +80,41 @@ func Test_Memcache_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_Memcache_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,8 @@ title: Memory | ||||
|  | ||||
| An in-memory storage driver. | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -38,13 +40,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the memory implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/memory | ||||
| go get github.com/gofiber/storage/memory/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/memory" | ||||
| import "github.com/gofiber/storage/memory/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -1,5 +1,15 @@ | ||||
| module github.com/gofiber/storage/memory | ||||
| module github.com/gofiber/storage/memory/v2 | ||||
|  | ||||
| go 1.17 | ||||
| go 1.19 | ||||
|  | ||||
| require github.com/gofiber/utils v1.1.0 | ||||
| require ( | ||||
| 	github.com/gofiber/utils/v2 v2.0.0-beta.3 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/google/uuid v1.3.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -1,2 +1,14 @@ | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3 h1:pfOhUDDVjBJpkWv6C5jaDyYLvpui7zQ97zpyFFsUOKw= | ||||
| github.com/gofiber/utils/v2 v2.0.0-beta.3/go.mod h1:jsl17+MsKfwJjM3ONCE9Rzji/j8XNbwjhUVTjzgfDCo= | ||||
| github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= | ||||
| github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -5,12 +5,12 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| 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) | ||||
| 	require.True(t, actualCurrent >= expectedCurrent-1 || actualCurrent <= expectedCurrent+1) | ||||
| } | ||||
|  | ||||
| func Test_TimeStampUpdater(t *testing.T) { | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import ( | ||||
| 	"sync/atomic" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/storage/memory/internal" | ||||
| 	"github.com/gofiber/storage/memory/v2/internal" | ||||
| ) | ||||
|  | ||||
| // Storage interface that is implemented by storage providers | ||||
|   | ||||
| @@ -4,7 +4,8 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/gofiber/utils/v2" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New() | ||||
| @@ -16,7 +17,7 @@ func Test_Storage_Memory_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Set_Override(t *testing.T) { | ||||
| @@ -26,10 +27,10 @@ func Test_Storage_Memory_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Get(t *testing.T) { | ||||
| @@ -39,11 +40,11 @@ func Test_Storage_Memory_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Set_Expiration(t *testing.T) { | ||||
| @@ -54,26 +55,23 @@ func Test_Storage_Memory_Set_Expiration(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, exp) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(1100 * time.Millisecond) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Get_Expired(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
| 	key := "john" | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Get_NotExist(t *testing.T) { | ||||
|  | ||||
| 	result, err := testStore.Get("notexist") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Delete(t *testing.T) { | ||||
| @@ -83,48 +81,45 @@ func Test_Storage_Memory_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_Storage_Memory_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|  | ||||
|  | ||||
| // go test -v -run=^$ -bench=Benchmark_Storage_Memory -benchmem -count=4 | ||||
| func Benchmark_Storage_Memory(b *testing.B) { | ||||
| 	keyLength := 1000 | ||||
|   | ||||
							
								
								
									
										126
									
								
								minio/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								minio/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,126 @@ | ||||
| # Minio | ||||
|  | ||||
| A Minio storage driver using [minio/minio-go](https://github.com/minio/minio-go). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| - [Examples](#examples) | ||||
| - [Config](#config) | ||||
| - [Default Config](#default-config) | ||||
|  | ||||
| ### Signatures | ||||
| ```go | ||||
| func New(config ...Config) Storage | ||||
| func (s *Storage) Get(key string) ([]byte, error) | ||||
| func (s *Storage) Set(key string, val []byte, exp time.Duration) error | ||||
| func (s *Storage) Delete(key string) error | ||||
| func (s *Storage) Reset() error | ||||
| func (s *Storage) Close() error | ||||
| func (s *Storage) CheckBucket() error | ||||
| func (s *Storage) CreateBucket() error | ||||
| func (s *Storage) RemoveBucket() error | ||||
| func (s *Storage) Conn() *minio.Client | ||||
| ``` | ||||
| ### Installation | ||||
| Install the Minio implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/minio | ||||
| ``` | ||||
| And then run minio on Docker | ||||
| ```bash | ||||
| docker run -d --restart always -p 9000:9000 -p 9001:9001 --name storage-minio --volume=minio:/var/lib/minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server --console-address ":9001" /var/lib/minio | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/minio" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
| ```go | ||||
| // Initialize default config | ||||
| store := minio.New() | ||||
|  | ||||
| // Initialize custom config | ||||
| store := minio.New(minio.Config{ | ||||
|     Bucket:   "fiber-bucket", | ||||
|     Endpoint: "localhost:9000", | ||||
|     Credentials: Credentials{ | ||||
|         accessKeyID:     "minio-user", | ||||
|         secretAccessKey: "minio-password", | ||||
|     }, | ||||
| }) | ||||
| ``` | ||||
|  | ||||
| ### Config | ||||
| ```go | ||||
| // Config defines the config for storage. | ||||
| type Config struct { | ||||
|     // Bucket | ||||
|     // Default fiber-bucket | ||||
|     Bucket string | ||||
|      | ||||
|     // Endpoint is a host name or an IP address | ||||
|     Endpoint string | ||||
|      | ||||
|     // Region Set this value to override region cache | ||||
|     // Optional | ||||
|     Region string | ||||
|      | ||||
|     // Token Set this value to provide x-amz-security-token (AWS S3 specific) | ||||
|     // Optional, Default is false | ||||
|     Token string | ||||
|      | ||||
|     // Secure If set to true, https is used instead of http. | ||||
|     // Default is false | ||||
|     Secure bool | ||||
|      | ||||
|     // Reset clears any existing keys in existing Bucket | ||||
|     // Optional. Default is false | ||||
|     Reset bool | ||||
|      | ||||
|     // Credentials Minio access key and Minio secret key. | ||||
|     // Need to be defined | ||||
|     Credentials Credentials | ||||
|      | ||||
|     // GetObjectOptions Options for GET requests specifying additional options like encryption, If-Match | ||||
|     GetObjectOptions minio.GetObjectOptions | ||||
|      | ||||
|     // PutObjectOptions | ||||
|     // Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation. | ||||
|     PutObjectOptions minio.PutObjectOptions | ||||
|      | ||||
|     // ListObjectsOptions Options per to list objects | ||||
|     ListObjectsOptions minio.ListObjectsOptions | ||||
|      | ||||
|     // RemoveObjectOptions Allows user to set options | ||||
|     RemoveObjectOptions minio.RemoveObjectOptions | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### Default Config | ||||
| The default configuration lacks Bucket, Region, and Endpoint which are all required and must be overwritten: | ||||
| ```go | ||||
| // ConfigDefault is the default config | ||||
| var ConfigDefault = Config{ | ||||
|     Bucket:              "fiber-bucket", | ||||
|     Endpoint:            "", | ||||
|     Region:              "", | ||||
|     Token:               "", | ||||
|     Secure:              false, | ||||
|     Reset:               false, | ||||
|     Credentials:         Credentials{}, | ||||
|     GetObjectOptions:    minio.GetObjectOptions{}, | ||||
|     PutObjectOptions:    minio.PutObjectOptions{}, | ||||
|     ListObjectsOptions:  minio.ListObjectsOptions{}, | ||||
|     RemoveObjectOptions: minio.RemoveObjectOptions{}, | ||||
| } | ||||
| type Credentials struct { | ||||
|     AccessKeyID     string | ||||
|     SecretAccessKey string | ||||
| } | ||||
| ``` | ||||
							
								
								
									
										88
									
								
								minio/config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								minio/config.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| package minio | ||||
|  | ||||
| import ( | ||||
| 	"github.com/minio/minio-go/v7" | ||||
| ) | ||||
|  | ||||
| // Config defines the config for storage. | ||||
| type Config struct { | ||||
| 	// Bucket | ||||
| 	// Default fiber-bucket | ||||
| 	Bucket string | ||||
|  | ||||
| 	// Endpoint is a host name or an IP address | ||||
| 	Endpoint string | ||||
|  | ||||
| 	// Region Set this value to override region cache | ||||
| 	// Optional | ||||
| 	Region string | ||||
|  | ||||
| 	// Token Set this value to provide x-amz-security-token (AWS S3 specific) | ||||
| 	// Optional, Default is false | ||||
| 	Token string | ||||
|  | ||||
| 	// Secure If set to true, https is used instead of http. | ||||
| 	// Default is false | ||||
| 	Secure bool | ||||
|  | ||||
| 	// Reset clears any existing keys in existing Bucket | ||||
| 	// Optional. Default is false | ||||
| 	Reset bool | ||||
|  | ||||
| 	// Credentials Minio access key and Minio secret key. | ||||
| 	// Need to be defined | ||||
| 	Credentials Credentials | ||||
|  | ||||
| 	// GetObjectOptions Options for GET requests specifying additional options like encryption, If-Match | ||||
| 	GetObjectOptions minio.GetObjectOptions | ||||
|  | ||||
| 	// PutObjectOptions | ||||
| 	// Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation. | ||||
| 	PutObjectOptions minio.PutObjectOptions | ||||
|  | ||||
| 	// ListObjectsOptions Options per to list objects | ||||
| 	ListObjectsOptions minio.ListObjectsOptions | ||||
|  | ||||
| 	// RemoveObjectOptions Allows user to set options | ||||
| 	RemoveObjectOptions minio.RemoveObjectOptions | ||||
| } | ||||
|  | ||||
| type Credentials struct { | ||||
| 	// AccessKeyID is like user-id that uniquely identifies your account. | ||||
| 	AccessKeyID string | ||||
| 	// SecretAccessKey is the password to your account. | ||||
| 	SecretAccessKey string | ||||
| } | ||||
|  | ||||
| // ConfigDefault is the default config | ||||
| var ConfigDefault = Config{ | ||||
| 	Bucket:              "fiber-bucket", | ||||
| 	Endpoint:            "", | ||||
| 	Region:              "", | ||||
| 	Token:               "", | ||||
| 	Secure:              false, | ||||
| 	Reset:               false, | ||||
| 	Credentials:         Credentials{}, | ||||
| 	GetObjectOptions:    minio.GetObjectOptions{}, | ||||
| 	PutObjectOptions:    minio.PutObjectOptions{}, | ||||
| 	ListObjectsOptions:  minio.ListObjectsOptions{}, | ||||
| 	RemoveObjectOptions: minio.RemoveObjectOptions{}, | ||||
| } | ||||
|  | ||||
| // Helper function to set default values | ||||
| func configDefault(config ...Config) Config { | ||||
| 	// Return default config if nothing provided | ||||
| 	if len(config) < 1 { | ||||
| 		return ConfigDefault | ||||
| 	} | ||||
|  | ||||
| 	// Override default config | ||||
| 	cfg := config[0] | ||||
|  | ||||
| 	// Set default values | ||||
| 	if cfg.Bucket == "" { | ||||
| 		cfg.Bucket = ConfigDefault.Bucket | ||||
| 	} | ||||
|  | ||||
| 	return cfg | ||||
| } | ||||
							
								
								
									
										31
									
								
								minio/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								minio/go.mod
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| module github.com/gofiber/storage/minio | ||||
|  | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/minio/minio-go/v7 v7.0.63 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| 	github.com/valyala/bytebufferpool v1.0.0 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/dustin/go-humanize v1.0.1 // indirect | ||||
| 	github.com/google/uuid v1.3.1 // indirect | ||||
| 	github.com/json-iterator/go v1.1.12 // indirect | ||||
| 	github.com/klauspost/compress v1.16.7 // indirect | ||||
| 	github.com/klauspost/cpuid/v2 v2.2.5 // indirect | ||||
| 	github.com/minio/md5-simd v1.1.2 // indirect | ||||
| 	github.com/minio/sha256-simd v1.0.1 // indirect | ||||
| 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||||
| 	github.com/modern-go/reflect2 v1.0.2 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	github.com/rs/xid v1.5.0 // indirect | ||||
| 	github.com/sirupsen/logrus v1.9.3 // indirect | ||||
| 	golang.org/x/crypto v0.12.0 // indirect | ||||
| 	golang.org/x/net v0.14.0 // indirect | ||||
| 	golang.org/x/sys v0.11.0 // indirect | ||||
| 	golang.org/x/text v0.12.0 // indirect | ||||
| 	gopkg.in/ini.v1 v1.67.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
							
								
								
									
										56
									
								
								minio/go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								minio/go.sum
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= | ||||
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= | ||||
| github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= | ||||
| github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= | ||||
| github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= | ||||
| github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= | ||||
| github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | ||||
| github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | ||||
| github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= | ||||
| github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= | ||||
| github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= | ||||
| github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= | ||||
| github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= | ||||
| github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurwcbQ= | ||||
| github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4= | ||||
| github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= | ||||
| github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= | ||||
| github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | ||||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= | ||||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | ||||
| github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= | ||||
| github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= | ||||
| github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= | ||||
| github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||||
| github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= | ||||
| github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= | ||||
| golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= | ||||
| golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= | ||||
| golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= | ||||
| golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= | ||||
| golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= | ||||
| golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= | ||||
| gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
							
								
								
									
										171
									
								
								minio/minio.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								minio/minio.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,171 @@ | ||||
| package minio | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"log" | ||||
| 	"net/http" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/minio/minio-go/v7" | ||||
| 	"github.com/minio/minio-go/v7/pkg/credentials" | ||||
| 	"github.com/valyala/bytebufferpool" | ||||
| ) | ||||
|  | ||||
| // Storage interface that is implemented by storage providers | ||||
| type Storage struct { | ||||
| 	minio *minio.Client | ||||
| 	cfg   Config | ||||
| 	ctx   context.Context | ||||
| } | ||||
|  | ||||
| // New creates a new storage | ||||
| func New(config ...Config) *Storage { | ||||
|  | ||||
| 	// Set default config | ||||
| 	cfg := configDefault(config...) | ||||
|  | ||||
| 	// Minio instance | ||||
| 	minioClient, err := minio.New(cfg.Endpoint, &minio.Options{ | ||||
| 		Creds:  credentials.NewStaticV4(cfg.Credentials.AccessKeyID, cfg.Credentials.SecretAccessKey, cfg.Token), | ||||
| 		Secure: cfg.Secure, | ||||
| 		Region: cfg.Region, | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|  | ||||
| 	storage := &Storage{minio: minioClient, cfg: cfg, ctx: context.Background()} | ||||
|  | ||||
| 	// Reset all entries if set to true | ||||
| 	if cfg.Reset { | ||||
| 		if err = storage.Reset(); err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// check bucket | ||||
| 	err = storage.CheckBucket() | ||||
| 	if err != nil { | ||||
| 		// create bucket | ||||
| 		err = storage.CreateBucket() | ||||
| 		if err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return storage | ||||
| } | ||||
|  | ||||
| // Get value by key | ||||
| func (s *Storage) Get(key string) ([]byte, error) { | ||||
|  | ||||
| 	if len(key) <= 0 { | ||||
| 		return nil, errors.New("the key value is required") | ||||
| 	} | ||||
|  | ||||
| 	// get object | ||||
| 	object, err := s.minio.GetObject(s.ctx, s.cfg.Bucket, key, s.cfg.GetObjectOptions) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	// convert to byte | ||||
| 	bb := bytebufferpool.Get() | ||||
| 	defer bytebufferpool.Put(bb) | ||||
| 	_, err = bb.ReadFrom(object) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return bb.Bytes(), nil | ||||
| } | ||||
|  | ||||
| // Set key with value | ||||
| func (s *Storage) Set(key string, val []byte, exp time.Duration) error { | ||||
|  | ||||
| 	if len(key) <= 0 { | ||||
| 		return errors.New("the key value is required") | ||||
| 	} | ||||
|  | ||||
| 	// create Reader | ||||
| 	file := bytes.NewReader(val) | ||||
|  | ||||
| 	// set content type | ||||
| 	s.cfg.PutObjectOptions.ContentType = http.DetectContentType(val) | ||||
|  | ||||
| 	// put object | ||||
| 	_, err := s.minio.PutObject(s.ctx, s.cfg.Bucket, key, file, file.Size(), s.cfg.PutObjectOptions) | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Delete entry by key | ||||
| func (s *Storage) Delete(key string) error { | ||||
|  | ||||
| 	if len(key) <= 0 { | ||||
| 		return errors.New("the key value is required") | ||||
| 	} | ||||
|  | ||||
| 	// remove | ||||
| 	err := s.minio.RemoveObject(s.ctx, s.cfg.Bucket, key, s.cfg.RemoveObjectOptions) | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Reset all entries, including unexpired | ||||
| func (s *Storage) Reset() error { | ||||
|  | ||||
| 	objectsCh := make(chan minio.ObjectInfo) | ||||
|  | ||||
| 	// Send object names that are needed to be removed to objectsCh | ||||
| 	go func() { | ||||
| 		defer close(objectsCh) | ||||
| 		// List all objects from a bucket-name with a matching prefix. | ||||
| 		for object := range s.minio.ListObjects(s.ctx, s.cfg.Bucket, s.cfg.ListObjectsOptions) { | ||||
| 			if object.Err != nil { | ||||
| 				log.Println(object.Err) | ||||
| 			} | ||||
| 			objectsCh <- object | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	opts := minio.RemoveObjectsOptions{ | ||||
| 		GovernanceBypass: true, | ||||
| 	} | ||||
|  | ||||
| 	for err := range s.minio.RemoveObjects(s.ctx, s.cfg.Bucket, objectsCh, opts) { | ||||
| 		log.Println("Error detected during deletion: ", err) | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Close the storage | ||||
| func (s *Storage) Close() error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // CheckBucket Check to see if bucket already exists | ||||
| func (s *Storage) CheckBucket() error { | ||||
| 	exists, err := s.minio.BucketExists(s.ctx, s.cfg.Bucket) | ||||
| 	if !exists || err != nil { | ||||
| 		return errors.New("the specified bucket does not exist") | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // CreateBucket Bucket not found so Make a new bucket | ||||
| func (s *Storage) CreateBucket() error { | ||||
| 	return s.minio.MakeBucket(s.ctx, s.cfg.Bucket, minio.MakeBucketOptions{Region: s.cfg.Region}) | ||||
| } | ||||
|  | ||||
| // RemoveBucket Bucket remove if bucket is empty | ||||
| func (s *Storage) RemoveBucket() error { | ||||
| 	return s.minio.RemoveBucket(s.ctx, s.cfg.Bucket) | ||||
| } | ||||
|  | ||||
| // Conn Return minio client | ||||
| func (s *Storage) Conn() *minio.Client { | ||||
| 	return s.minio | ||||
| } | ||||
							
								
								
									
										184
									
								
								minio/minio_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								minio/minio_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,184 @@ | ||||
| package minio | ||||
|  | ||||
| import ( | ||||
| 	"strconv" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New( | ||||
| 	Config{ | ||||
| 		Bucket:   "fiber-bucket", | ||||
| 		Endpoint: "localhost:9000", | ||||
| 		Credentials: Credentials{ | ||||
| 			AccessKeyID:     "minio-user", | ||||
| 			SecretAccessKey: "minio-password", | ||||
| 		}, | ||||
| 	}, | ||||
| ) | ||||
|  | ||||
| func Test_Get(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
|  | ||||
| 	result, err = testStore.Get("doe") | ||||
| 	require.Error(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_Get_Empty_Key(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "" | ||||
| 	) | ||||
|  | ||||
| 	_, err := testStore.Get(key) | ||||
| 	require.Error(t, err) | ||||
| 	require.EqualError(t, err, "the key value is required") | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Get_Not_Exists_Key(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "not-exists" | ||||
| 	) | ||||
|  | ||||
| 	_, err := testStore.Get(key) | ||||
| 	require.Error(t, err) | ||||
| 	require.EqualError(t, err, "The specified key does not exist.") | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Get_Not_Exists_Bucket(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
|  | ||||
| 	// random bucket name | ||||
| 	testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	require.Error(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| 	require.EqualError(t, err, "The specified bucket does not exist") | ||||
|  | ||||
| 	testStore.cfg.Bucket = "fiber-bucket" | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Set(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_Set_Empty_Key(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "" | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
|  | ||||
| 	require.Error(t, err) | ||||
| 	require.EqualError(t, err, "the key value is required") | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Set_Not_Exists_Bucket(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	// random bucket name | ||||
| 	testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	require.Error(t, err) | ||||
| 	require.EqualError(t, err, "The specified bucket does not exist") | ||||
|  | ||||
| 	testStore.cfg.Bucket = "fiber-bucket" | ||||
| } | ||||
|  | ||||
| func Test_Delete(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Delete_Empty_Key(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "" | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
|  | ||||
| 	require.Error(t, err) | ||||
| 	require.EqualError(t, err, "the key value is required") | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Delete_Not_Exists_Bucket(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
|  | ||||
| 	// random bucket name | ||||
| 	testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10) | ||||
|  | ||||
| 	err := testStore.Delete(key) | ||||
|  | ||||
| 	require.Error(t, err) | ||||
| 	require.EqualError(t, err, "The specified bucket does not exist") | ||||
|  | ||||
| 	testStore.cfg.Bucket = "fiber-bucket" | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	require.Error(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| } | ||||
|  | ||||
| func Test_Close(t *testing.T) { | ||||
| 	require.NoError(t, testStore.Close()) | ||||
| } | ||||
| @@ -11,6 +11,8 @@ title: MongoDB | ||||
|  | ||||
| A MongoDB storage driver using [mongodb/mongo-go-driver](https://github.com/mongodb/mongo-go-driver). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -35,13 +37,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the mongodb implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/mongodb | ||||
| go get github.com/gofiber/storage/mongodb/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/mongodb" | ||||
| import "github.com/gofiber/storage/mongodb/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
| @@ -1,21 +1,24 @@ | ||||
| module github.com/gofiber/storage/mongodb | ||||
| module github.com/gofiber/storage/mongodb/v2 | ||||
|  | ||||
| go 1.17 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| 	go.mongodb.org/mongo-driver v1.12.1 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/golang/snappy v0.0.4 // indirect | ||||
| 	github.com/klauspost/compress v1.13.6 // indirect | ||||
| 	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect | ||||
| 	github.com/klauspost/compress v1.16.7 // indirect | ||||
| 	github.com/montanaflynn/stats v0.7.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect | ||||
| 	github.com/xdg-go/scram v1.1.2 // indirect | ||||
| 	github.com/xdg-go/stringprep v1.0.4 // indirect | ||||
| 	github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect | ||||
| 	golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect | ||||
| 	golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect | ||||
| 	golang.org/x/text v0.7.0 // indirect | ||||
| 	golang.org/x/crypto v0.12.0 // indirect | ||||
| 	golang.org/x/sync v0.3.0 // indirect | ||||
| 	golang.org/x/text v0.12.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
| @@ -1,16 +1,20 @@ | ||||
| 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/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| 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/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||
| github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= | ||||
| github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= | ||||
| github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= | ||||
| github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= | ||||
| github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= | ||||
| github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= | ||||
| github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= | ||||
| github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= | ||||
| github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= | ||||
| github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= | ||||
| github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= | ||||
| @@ -26,8 +30,9 @@ go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl | ||||
| 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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||||
| golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= | ||||
| golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | ||||
| golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= | ||||
| golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= | ||||
| golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| @@ -35,8 +40,9 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v | ||||
| golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||||
| golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= | ||||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= | ||||
| golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= | ||||
| 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-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| @@ -51,11 +57,16 @@ 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.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= | ||||
| golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= | ||||
| golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= | ||||
| golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= | ||||
| golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-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= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New(Config{ | ||||
| @@ -18,7 +18,7 @@ func Test_MongoDB_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Set_Override(t *testing.T) { | ||||
| @@ -28,10 +28,10 @@ func Test_MongoDB_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Get(t *testing.T) { | ||||
| @@ -41,11 +41,11 @@ func Test_MongoDB_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Set_Expiration(t *testing.T) { | ||||
| @@ -56,26 +56,23 @@ func Test_MongoDB_Set_Expiration(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, exp) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(1100 * time.Millisecond) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Get_Expired(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
| 	key := "john" | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Get_NotExist(t *testing.T) { | ||||
|  | ||||
| 	result, err := testStore.Get("notexist") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Delete(t *testing.T) { | ||||
| @@ -85,43 +82,41 @@ func Test_MongoDB_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_MongoDB_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: MSSQL | ||||
|  | ||||
| A MSSQL storage driver using [microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -35,13 +37,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the mssql implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/mssql | ||||
| go get github.com/gofiber/storage/mssql/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/mssql" | ||||
| import "github.com/gofiber/storage/mssql/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
							
								
								
									
										14
									
								
								mssql/go.mod
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								mssql/go.mod
									
									
									
									
									
								
							| @@ -1,14 +1,18 @@ | ||||
| module github.com/gofiber/storage/mssql | ||||
| module github.com/gofiber/storage/mssql/v2 | ||||
|  | ||||
| go 1.18 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/microsoft/go-mssqldb v1.5.0 | ||||
| 	github.com/microsoft/go-mssqldb v1.6.0 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect | ||||
| 	github.com/golang-sql/sqlexp v0.1.0 // indirect | ||||
| 	golang.org/x/crypto v0.9.0 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	golang.org/x/crypto v0.12.0 // indirect | ||||
| 	golang.org/x/text v0.12.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										110
									
								
								mssql/go.sum
									
									
									
									
									
								
							
							
						
						
									
										110
									
								
								mssql/go.sum
									
									
									
									
									
								
							| @@ -1,94 +1,32 @@ | ||||
| github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= | ||||
| github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 h1:yfJe15aSwEQ6Oo6J+gdfdulPNoZ3TEhmbhLIoxZcA+U= | ||||
| github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 h1:T028gtTPiYt/RMUfs8nVsAL7FDQrfLlrm/NnRG/zcC4= | ||||
| github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 h1:HCc0+LpPfpCKs6LGGLAhwBARt9632unrVcI6i8s/8os= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/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.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= | ||||
| github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= | ||||
| github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= | ||||
| 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.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/hashicorp/go-uuid v1.0.3/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.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo= | ||||
| github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= | ||||
| github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= | ||||
| github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= | ||||
| github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= | ||||
| github.com/microsoft/go-mssqldb v1.5.0 h1:CgENxkwtOBNj3Jg6T1X209y2blCfTTcwuOlznd2k9fk= | ||||
| github.com/microsoft/go-mssqldb v1.5.0/go.mod h1:lmWsjHD8XX/Txr0f8ZqgbEZSC+BZjmEQy/Ms+rLrvho= | ||||
| github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= | ||||
| github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= | ||||
| github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= | ||||
| github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | ||||
| github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= | ||||
| github.com/microsoft/go-mssqldb v1.6.0 h1:mM3gYdVwEPFrlg/Dvr2DNVEgYFG7L42l+dGc67NNNpc= | ||||
| github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU= | ||||
| github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||||
| github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | ||||
| github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||||
| golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= | ||||
| golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= | ||||
| golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= | ||||
| golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= | ||||
| golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||||
| golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | ||||
| 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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||||
| golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | ||||
| golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= | ||||
| golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= | ||||
| golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= | ||||
| golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||||
| golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||||
| golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= | ||||
| golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= | ||||
| golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||||
| golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= | ||||
| golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= | ||||
| golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | ||||
| golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= | ||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= | ||||
| golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= | ||||
| golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= | ||||
| golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||||
| golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= | ||||
| golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gofiber/utils" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| ) | ||||
|  | ||||
| var testStore = New(Config{ | ||||
| @@ -23,7 +23,7 @@ func Test_MSSQL_Set(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Set_Override(t *testing.T) { | ||||
| @@ -33,10 +33,10 @@ func Test_MSSQL_Set_Override(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Get(t *testing.T) { | ||||
| @@ -46,11 +46,11 @@ func Test_MSSQL_Get(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(t, val, result) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Set_Expiration(t *testing.T) { | ||||
| @@ -61,26 +61,23 @@ func Test_MSSQL_Set_Expiration(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, exp) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	time.Sleep(1100 * time.Millisecond) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Get_Expired(t *testing.T) { | ||||
| 	var ( | ||||
| 		key = "john" | ||||
| 	) | ||||
| 	key := "john" | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| 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) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Delete(t *testing.T) { | ||||
| @@ -90,79 +87,74 @@ func Test_MSSQL_Delete(t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	err := testStore.Set(key, val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Delete(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get(key) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Reset(t *testing.T) { | ||||
| 	var ( | ||||
| 		val = []byte("doe") | ||||
| 	) | ||||
| 	val := []byte("doe") | ||||
|  | ||||
| 	err := testStore.Set("john1", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Set("john2", val, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	err = testStore.Reset() | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("john1") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
|  | ||||
| 	result, err = testStore.Get("john2") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, true, len(result) == 0) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Zero(t, len(result)) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_GC(t *testing.T) { | ||||
| 	var ( | ||||
| 		testVal = []byte("doe") | ||||
| 	) | ||||
| 	testVal := []byte("doe") | ||||
|  | ||||
| 	// This key should expire | ||||
| 	err := testStore.Set("john", testVal, time.Nanosecond) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	testStore.gc(time.Now()) | ||||
| 	row := testStore.db.QueryRow(testStore.sqlSelect, "john") | ||||
| 	err = row.Scan(nil, nil) | ||||
| 	utils.AssertEqual(t, sql.ErrNoRows, err) | ||||
| 	require.Equal(t, sql.ErrNoRows, err) | ||||
|  | ||||
| 	// This key should not expire | ||||
| 	err = testStore.Set("john", testVal, 0) | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	testStore.gc(time.Now()) | ||||
| 	val, err := testStore.Get("john") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, testVal, val) | ||||
|  | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(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) | ||||
| 	require.NoError(t, err) | ||||
|  | ||||
| 	result, err := testStore.Get("0xF6") | ||||
| 	utils.AssertEqual(t, nil, err) | ||||
| 	utils.AssertEqual(t, val, result) | ||||
| 	require.NoError(t, err) | ||||
| 	require.Equal(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`") | ||||
| 			require.Equalf(t, true, nil, "Connection was established with a `require`") | ||||
| 		} | ||||
| 	}() | ||||
| 	_ = New(Config{ | ||||
| @@ -175,9 +167,9 @@ func Test_SslRequiredMode(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Close(t *testing.T) { | ||||
| 	utils.AssertEqual(t, nil, testStore.Close()) | ||||
| 	require.Nil(t, testStore.Close()) | ||||
| } | ||||
|  | ||||
| func Test_MSSQL_Conn(t *testing.T) { | ||||
| 	utils.AssertEqual(t, true, testStore.Conn() != nil) | ||||
| 	require.True(t, testStore.Conn() != nil) | ||||
| } | ||||
|   | ||||
| @@ -11,6 +11,8 @@ title: MySQL | ||||
|  | ||||
| A MySQL storage driver using `database/sql` and [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql). | ||||
|  | ||||
| **Note: Requires Go 1.19 and above** | ||||
|  | ||||
| ### Table of Contents | ||||
| - [Signatures](#signatures) | ||||
| - [Installation](#installation) | ||||
| @@ -35,13 +37,13 @@ go mod init github.com/<user>/<repo> | ||||
| ``` | ||||
| And then install the mysql implementation: | ||||
| ```bash | ||||
| go get github.com/gofiber/storage/mysql | ||||
| go get github.com/gofiber/storage/mysql/v2 | ||||
| ``` | ||||
|  | ||||
| ### Examples | ||||
| Import the storage package. | ||||
| ```go | ||||
| import "github.com/gofiber/storage/mysql" | ||||
| import "github.com/gofiber/storage/mysql/v2" | ||||
| ``` | ||||
|  | ||||
| You can use the following possibilities to create a storage: | ||||
|   | ||||
							
								
								
									
										12
									
								
								mysql/go.mod
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								mysql/go.mod
									
									
									
									
									
								
							| @@ -1,8 +1,14 @@ | ||||
| module github.com/gofiber/storage/mysql | ||||
| module github.com/gofiber/storage/mysql/v2 | ||||
|  | ||||
| go 1.17 | ||||
| go 1.19 | ||||
|  | ||||
| require ( | ||||
| 	github.com/go-sql-driver/mysql v1.7.1 | ||||
| 	github.com/gofiber/utils v1.1.0 | ||||
| 	github.com/stretchr/testify v1.8.4 | ||||
| ) | ||||
|  | ||||
| require ( | ||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| ) | ||||
|   | ||||
							
								
								
									
										12
									
								
								mysql/go.sum
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								mysql/go.sum
									
									
									
									
									
								
							| @@ -1,4 +1,12 @@ | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= | ||||
| github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= | ||||
| github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= | ||||
| github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||||
| github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user