-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adjust code structure * Squashed commit of the following: commit 4cc24fe Author: slhmy <[email protected]> Date: Wed Sep 13 22:26:58 2023 +0800 Perf commit 75f9073 Author: slhmy <[email protected]> Date: Wed Sep 13 22:14:38 2023 +0800 Project refactor commit d132b9f Author: slhmy <[email protected]> Date: Wed Sep 13 11:28:30 2023 +0000 Perf code structure * Resolve conflicts * Adjust project structure * Remove outdated part of README.md * Make code more real world * Refactor and support login * Perf according to new structure
- Loading branch information
Showing
42 changed files
with
814 additions
and
334 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
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
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,53 @@ | ||
package minio | ||
|
||
import ( | ||
"context" | ||
"io/fs" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/minio/minio-go/v7" | ||
) | ||
|
||
func PutLocalObjects(ctx context.Context, rootName, localPath string) error { | ||
minioClient := GetMinioClient() | ||
bucketName := GetBucketName() | ||
|
||
// Remove old | ||
objectsCh := minioClient.ListObjects(ctx, bucketName, minio.ListObjectsOptions{ | ||
Prefix: rootName, | ||
Recursive: true, | ||
}) | ||
for objInfo := range objectsCh { | ||
if objInfo.Err != nil { | ||
return objInfo.Err | ||
} | ||
|
||
err := minioClient.RemoveObject(ctx, bucketName, objInfo.Key, minio.RemoveObjectOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
filepath.Walk(localPath, func(path string, info fs.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if info.IsDir() { | ||
return nil | ||
} | ||
|
||
objectName := filepath.Join(rootName, strings.Replace(path, localPath, "", 1)) | ||
_, err = minioClient.FPutObject(ctx, bucketName, | ||
objectName, path, | ||
minio.PutObjectOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
return nil | ||
} |
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,14 @@ | ||
package redis | ||
|
||
import "github.com/redis/go-redis/v9" | ||
|
||
var redisClient *redis.Client | ||
|
||
func GetDefaultRedisClient() *redis.Client { | ||
if redisClient == nil { | ||
redisClient = redis.NewClient(&redis.Options{ | ||
Addr: "localhost:6379", | ||
}) | ||
} | ||
return redisClient | ||
} |
Oops, something went wrong.