-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redis-backed S3, Cuckoo Filters, Bot proxy, TLS
- Loading branch information
Showing
24 changed files
with
721 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,4 +111,5 @@ modules.xml | |
# End of https://www.gitignore.io/api/go,jetbrains+all | ||
|
||
www/ | ||
dist/ | ||
dist/ | ||
testdata/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package serve | ||
|
||
import ( | ||
"github.com/Vilsol/yeet/cache" | ||
"github.com/Vilsol/yeet/cmd" | ||
"github.com/Vilsol/yeet/server" | ||
"github.com/Vilsol/yeet/source" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func init() { | ||
s3RedisCmd.Flags().String("network", "tcp", "The network type, either tcp or unix") | ||
s3RedisCmd.Flags().StringP("address", "a", "localhost:6379", "host:port address of Redis") | ||
s3RedisCmd.Flags().String("user", "", "Username of Redis") | ||
s3RedisCmd.Flags().String("pass", "", "Password of Redis") | ||
s3RedisCmd.Flags().Int("db", 0, "DB of Redis") | ||
|
||
_ = s3RedisCmd.MarkFlagRequired("address") | ||
|
||
_ = viper.BindPFlag("network", s3RedisCmd.Flags().Lookup("network")) | ||
_ = viper.BindPFlag("address", s3RedisCmd.Flags().Lookup("address")) | ||
_ = viper.BindPFlag("username", s3RedisCmd.Flags().Lookup("username")) | ||
_ = viper.BindPFlag("password", s3RedisCmd.Flags().Lookup("password")) | ||
_ = viper.BindPFlag("db", s3RedisCmd.Flags().Lookup("db")) | ||
|
||
cmd.ServeCMD.AddCommand(s3RedisCmd) | ||
} | ||
|
||
var s3RedisCmd = &cobra.Command{ | ||
Use: "s3-redis", | ||
Short: "Serve Redis-backed S3 buckets", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if viper.GetBool("watch") { | ||
return errors.New("watch is not supported for s3-redis") | ||
} | ||
|
||
src, err := source.NewS3Redis( | ||
viper.GetString("network"), | ||
viper.GetString("address"), | ||
viper.GetString("username"), | ||
viper.GetString("password"), | ||
viper.GetInt("db"), | ||
) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
c, err := cache.NewHashMapCache(src, true) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
if _, err := c.Index(); err != nil { | ||
return err | ||
} | ||
|
||
return server.Run(c) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## yeet serve s3-redis | ||
|
||
Serve Redis-backed S3 buckets | ||
|
||
``` | ||
yeet serve s3-redis [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-a, --address string host:port address of Redis (default "localhost:6379") | ||
--db int DB of Redis | ||
-h, --help help for s3-redis | ||
--network string The network type, either tcp or unix (default "tcp") | ||
--pass string Password of Redis | ||
--user string Username of Redis | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--bot-agents string Bot User-Agent header regex (default "bot|crawl|spider|external|meta|scrap|archive|discourse") | ||
--bot-proxy string Bot proxy URL | ||
--expiry Use cache expiry | ||
--expiry-interval duration Interval between cache GC's (default 10m0s) | ||
--expiry-time duration Lifetime of a cache entry (default 1h0m0s) | ||
--host string Hostname to bind the webserver | ||
--index-file string The directory default index file (default "index.html") | ||
--log string The log level to output (default "info") | ||
--log-file string File to output logs to | ||
-p, --paths strings Paths to serve on the webserver (default [./www]) | ||
--port int Port to run the webserver on (default 8080) | ||
--quiet Do not log anything to console | ||
--tls-cert string TLS Certificate file path | ||
--tls-key string TLS Key file path | ||
--warmup Load all files into memory on startup | ||
-w, --watch Watch filesystem for changes | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [yeet serve](yeet_serve.md) - Serve files with yeet | ||
|
||
###### Auto generated by spf13/cobra on 7-Jan-2022 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace yeet; | ||
|
||
table S3 { | ||
filter: string; | ||
bucket: string; | ||
key: string; | ||
secret: string; | ||
endpoint: string; | ||
region: string; | ||
} |
Oops, something went wrong.