mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[performance]: make s3 urls cacheable (#1194)
Implements #864 and should speed up s3 based installations by a lot. With more static urls, we can then also implement #1026 for even better performance when used in conjunction with CDNs
This commit is contained in:
@ -26,9 +26,6 @@ import (
|
||||
|
||||
"codeberg.org/gruf/go-store/v2/kv"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
gtsstorage "github.com/superseriousbusiness/gotosocial/internal/storage"
|
||||
)
|
||||
|
||||
@ -41,38 +38,6 @@ func NewInMemoryStorage() *gtsstorage.Driver {
|
||||
}
|
||||
}
|
||||
|
||||
func NewS3Storage() *gtsstorage.Driver {
|
||||
endpoint := config.GetStorageS3Endpoint()
|
||||
access := config.GetStorageS3AccessKey()
|
||||
secret := config.GetStorageS3SecretKey()
|
||||
secure := config.GetStorageS3UseSSL()
|
||||
bucket := config.GetStorageS3BucketName()
|
||||
proxy := config.GetStorageS3Proxy()
|
||||
|
||||
s3, err := storage.OpenS3(endpoint, bucket, &storage.S3Config{
|
||||
CoreOpts: minio.Options{
|
||||
Creds: credentials.NewStaticV4(access, secret, ""),
|
||||
Secure: secure,
|
||||
},
|
||||
GetOpts: minio.GetObjectOptions{},
|
||||
PutOpts: minio.PutObjectOptions{},
|
||||
PutChunkSize: 5 * 1024 * 1024, // 2MiB
|
||||
StatOpts: minio.StatObjectOptions{},
|
||||
RemoveOpts: minio.RemoveObjectOptions{},
|
||||
ListSize: 200,
|
||||
})
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error opening s3 storage: %w", err))
|
||||
}
|
||||
|
||||
return >sstorage.Driver{
|
||||
KVStore: kv.New(s3),
|
||||
Storage: s3,
|
||||
Proxy: proxy,
|
||||
Bucket: bucket,
|
||||
}
|
||||
}
|
||||
|
||||
// StandardStorageSetup populates the storage with standard test entries from the given directory.
|
||||
func StandardStorageSetup(storage *gtsstorage.Driver, relativePath string) {
|
||||
storedA := newTestStoredAttachments()
|
||||
|
Reference in New Issue
Block a user