Skip to content

Commit

Permalink
feat(storages): add simplefs (#17)
Browse files Browse the repository at this point in the history
* feat(storages): add simplefs

* fix(simplefs): don't return error if not getting the mapping key

* fix(simplefs): call Start to start the goroutine

* fix(go-redis): support TLS configuration

* feat(deps): bump go-redis client version

* feat(deps): bump to prepare the release
  • Loading branch information
darkweak authored Oct 27, 2024
1 parent 0d6842b commit 88bb38d
Show file tree
Hide file tree
Showing 36 changed files with 1,308 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate_release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

release=("badger" "core" "etcd" "go-redis" "nats" "nuts" "olric" "otter" "redis")
release=("badger" "core" "etcd" "go-redis" "nats" "nuts" "olric" "otter" "redis" "simplefs")

IFS= read -r -d '' tpl <<EOF
name: Tag submodules on release
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,25 @@ jobs:
ref: 'refs/tags/redis/caddy/${{ github.ref_name }}',
sha: context.sha
})
-
name: Create Simplefs tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/simplefs/${{ github.ref_name }}',
sha: context.sha
})
-
name: Create Simplefs caddy tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/simplefs/caddy/${{ github.ref_name }}',
sha: context.sha
})
1 change: 1 addition & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- nuts
- otter
- redis
- simplefs
name: Validate quality
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: bump-version dependencies generate-release golangci-lint unit-tests

MODULES_LIST=badger core etcd go-redis nats nuts olric otter redis
STORAGES_LIST=badger etcd go-redis nats nuts olric otter redis
TESTS_LIST=badger core etcd go-redis nats nuts otter redis
MODULES_LIST=badger core etcd go-redis nats nuts olric otter redis simplefs
STORAGES_LIST=badger etcd go-redis nats nuts olric otter redis simplefs
TESTS_LIST=badger core etcd go-redis nats nuts otter redis simplefs

bump-version:
test $(from)
Expand All @@ -17,6 +17,7 @@ bump-version:
sed -i '' 's/github.com\/darkweak\/storages\/olric $(from)/github.com\/darkweak\/storages\/olric $(to)/' olric/caddy/go.mod
sed -i '' 's/github.com\/darkweak\/storages\/otter $(from)/github.com\/darkweak\/storages\/otter $(to)/' otter/caddy/go.mod
sed -i '' 's/github.com\/darkweak\/storages\/redis $(from)/github.com\/darkweak\/storages\/redis $(to)/' redis/caddy/go.mod
sed -i '' 's/github.com\/darkweak\/storages\/simplefs $(from)/github.com\/darkweak\/storages\/simplefs $(to)/' simplefs/caddy/go.mod

for storage in $(STORAGES_LIST) ; do \
sed -i '' 's/github.com\/darkweak\/storages\/core $(from)/github.com\/darkweak\/storages\/core $(to)/' $$storage/go.mod ; \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Using caddy, you can build your instance using the following template `xcaddy bu
* [Olric](https://github.com/buraksezer/olric)
* [Otter](https://github.com/maypok86/otter)
* [Redis](https://github.com/redis/rueidis)
* [Simplefs](https://github.com/darkweak/simplefs)
4 changes: 2 additions & 2 deletions badger/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/badger v0.0.10
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/badger v0.0.11
github.com/darkweak/storages/core v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion badger/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.1

require (
dario.cat/mergo v1.0.0
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/dgraph-io/badger/v3 v3.2103.5
github.com/pierrec/lz4/v4 v4.1.21
go.uber.org/zap v1.27.0
Expand Down
4 changes: 2 additions & 2 deletions etcd/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/etcd v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/etcd v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion etcd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.1
replace github.com/darkweak/storages/core => ../core

require (
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/pierrec/lz4/v4 v4.1.21
go.etcd.io/etcd/client/v3 v3.5.14
go.uber.org/zap v1.27.0
Expand Down
6 changes: 3 additions & 3 deletions go-redis/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/go-redis v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/go-redis v0.0.11
)

require (
Expand Down Expand Up @@ -75,7 +75,7 @@ require (
github.com/prometheus/procfs v0.12.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/quic-go v0.44.0 // indirect
github.com/redis/go-redis/v9 v9.5.4 // indirect
github.com/redis/go-redis/v9 v9.6.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go-redis/caddy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/quic-go v0.44.0 h1:So5wOr7jyO4vzL2sd8/pD9Kesciv91zSk8BoFngItQ0=
github.com/quic-go/quic-go v0.44.0/go.mod h1:z4cx/9Ny9UtGITIPzmPTXh1ULfOyWh4qGQlpnPcWmek=
github.com/redis/go-redis/v9 v9.5.4 h1:vOFYDKKVgrI5u++QvnMT7DksSMYg7Aw/Np4vLJLKLwY=
github.com/redis/go-redis/v9 v9.5.4/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/redis/go-redis/v9 v9.6.0 h1:NLck+Rab3AOTHw21CGRpvQpgTrAU4sgdCswqGtlhGRA=
github.com/redis/go-redis/v9 v9.6.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
Expand Down
15 changes: 15 additions & 0 deletions go-redis/go-redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package redis
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -51,6 +52,20 @@ func Factory(redisConfiguration core.CacheProvider, logger core.Logger, stale ti
hashtags = v
}
}

if value, ok := redisConfig["TLSConfig"]; ok {
tlsConfigBytes, err := json.Marshal(value)
if err != nil {
return nil, err
}

var tlsConfig tls.Config
if err = json.Unmarshal(tlsConfigBytes, &tlsConfig); err != nil {
return nil, err
}

options.TLSConfig = &tlsConfig
}
}
} else {
options = redis.UniversalOptions{
Expand Down
4 changes: 2 additions & 2 deletions go-redis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.22.1
replace github.com/darkweak/storages/core => ../core

require (
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/pierrec/lz4/v4 v4.1.21
github.com/redis/go-redis/v9 v9.5.4
github.com/redis/go-redis/v9 v9.6.0
go.uber.org/zap v1.27.0
)

Expand Down
4 changes: 2 additions & 2 deletions go-redis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
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/redis/go-redis/v9 v9.5.4 h1:vOFYDKKVgrI5u++QvnMT7DksSMYg7Aw/Np4vLJLKLwY=
github.com/redis/go-redis/v9 v9.5.4/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/redis/go-redis/v9 v9.6.0 h1:NLck+Rab3AOTHw21CGRpvQpgTrAU4sgdCswqGtlhGRA=
github.com/redis/go-redis/v9 v9.6.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
Expand Down
2 changes: 2 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ use (
./otter/caddy
./redis
./redis/caddy
./simplefs
./simplefs/caddy
)
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ github.com/rabbitmq/amqp091-go v1.2.0 h1:1pHBxAsQh54R9eX/xo679fUEAfv3loMqi0pvRFO
github.com/rabbitmq/amqp091-go v1.2.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.6.0 h1:NLck+Rab3AOTHw21CGRpvQpgTrAU4sgdCswqGtlhGRA=
github.com/redis/go-redis/v9 v9.6.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/ryanuber/columnize v2.1.0+incompatible h1:j1Wcmh8OrK4Q7GXY+V7SVSY8nUWQxHW5TkBe7YUl+2s=
Expand Down
4 changes: 2 additions & 2 deletions nats/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/nats v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/nats v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion nats/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/darkweak/storages/core => ../core

require (
dario.cat/mergo v1.0.0
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/nats-io/nats.go v1.36.0
github.com/pierrec/lz4/v4 v4.1.21
go.uber.org/zap v1.27.0
Expand Down
4 changes: 2 additions & 2 deletions nuts/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/nuts v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/nuts v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion nuts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/darkweak/storages/core => ../core

require (
dario.cat/mergo v1.0.0
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/nutsdb/nutsdb v1.0.4
github.com/pierrec/lz4/v4 v4.1.21
go.uber.org/zap v1.27.0
Expand Down
4 changes: 2 additions & 2 deletions olric/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/olric v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/olric v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion olric/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/darkweak/storages/core => ../core

require (
github.com/buraksezer/olric v0.5.6
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/pierrec/lz4/v4 v4.1.21
go.uber.org/zap v1.27.0
)
Expand Down
4 changes: 2 additions & 2 deletions otter/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/otter v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/otter v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion otter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.1
replace github.com/darkweak/storages/core => ../core

require (
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/maypok86/otter v1.2.1
github.com/pierrec/lz4/v4 v4.1.21
go.uber.org/zap v1.27.0
Expand Down
2 changes: 1 addition & 1 deletion otter/otter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (provider *Otter) MapKeys(prefix string) map[string]string {
keys := map[string]string{}

provider.cache.Range(func(key string, val []byte) bool {
if !strings.HasPrefix(key, prefix) {
if strings.HasPrefix(key, prefix) {
k, _ := strings.CutPrefix(key, prefix)
keys[k] = string(val)
}
Expand Down
4 changes: 2 additions & 2 deletions redis/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.1

require (
github.com/caddyserver/caddy/v2 v2.8.4
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/redis v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/darkweak/storages/redis v0.0.11
)

require (
Expand Down
2 changes: 1 addition & 1 deletion redis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.1
replace github.com/darkweak/storages/core => ../core

require (
github.com/darkweak/storages/core v0.0.10
github.com/darkweak/storages/core v0.0.11
github.com/pierrec/lz4/v4 v4.1.21
github.com/redis/rueidis v1.0.39
go.uber.org/zap v1.27.0
Expand Down
20 changes: 20 additions & 0 deletions simplefs/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
debug
cache {
simplefs
}
}

http://localhost {
route /hello {
cache
}

route /any {
cache {
simplefs {
size 100000
}
}
}
}
7 changes: 7 additions & 0 deletions simplefs/caddy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY:

build:
go mod tidy
go mod download
XCADDY_RACE_DETECTOR=1 XCADDY_DEBUG=1 xcaddy build --with github.com/darkweak/storages/core=../../core/ --with github.com/darkweak/storages/simplefs=../ --with github.com/darkweak/storages/simplefs/caddy=./
./caddy run
Loading

0 comments on commit 88bb38d

Please sign in to comment.