Merge branch 'main' into programmatic-c4

This commit is contained in:
tsmethurst 2022-11-06 13:32:10 +01:00
commit 0dea2801bd
9 changed files with 29 additions and 50 deletions

View file

@ -8,6 +8,8 @@ With GoToSocial, you can keep in touch with your friends, post, read, and share
<img src="./docs/assets/sloth.png" width="300"/>
</p>
**GoToSocial is still [ALPHA SOFTWARE](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)**. It is already deployable and useable, and it federates cleanly with many other Fediverse servers (not yet all). However, many things are not yet implemented, and there are plenty of bugs! We foresee entering beta somewhere in 2023.
Documentation is at [docs.gotosocial.org](https://docs.gotosocial.org). You can skip straight to the API documentation [here](https://docs.gotosocial.org/en/latest/api/swagger/).
Here's a screenshot of the instance landing page!
@ -79,8 +81,6 @@ This project sprang up in February/March 2021 out of a dissatisfaction with the
It began as a solo project, and then picked up steam as more developers became interested and jumped on.
The project is still [alpha software](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha), but is already deployable and very useable, and it federates cleanly with many other Fediverse servers (not yet all).
For a detailed view on what's implemented and what's not, and progress made towards [beta release](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta), please see [the roadmap document](./ROADMAP.md).
## Features

View file

@ -104,7 +104,6 @@ var Start action.GTSAction = func(ctx context.Context) error {
typeConverter := typeutils.NewConverter(dbService)
// Open the storage backend
storage, err := gtsstorage.AutoConfig()
if err != nil {
return fmt.Errorf("error creating storage backend: %w", err)

View file

@ -10,6 +10,8 @@ With GoToSocial, you can keep in touch with your friends, post, read, and share
GoToSocial provides a lightweight, customizable, and safety-focused entryway into the [Fediverse](https://en.wikipedia.org/wiki/Fediverse), and is comparable to (but distinct from) existing projects such as [Mastodon](https://joinmastodon.org/), [Pleroma](https://pleroma.social/), [Friendica](https://friendica.net), and [PixelFed](https://pixelfed.org/).
**GoToSocial is still [ALPHA SOFTWARE](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)**. It is already deployable and useable, and it federates cleanly with many other Fediverse servers (not yet all). However, many things are not yet implemented, and there are plenty of bugs! We foresee entering beta somewhere in 2023.
Here's a screenshot of the instance landing page!
![Screenshot of the landing page for the GoToSocial instance goblin.technology. It shows basic information about the instance; number of users and posts etc.](./assets/instancesplash.png)

2
go.mod
View file

@ -12,7 +12,7 @@ require (
codeberg.org/gruf/go-logger/v2 v2.2.1
codeberg.org/gruf/go-mutexes v1.1.3
codeberg.org/gruf/go-runners v1.3.1
codeberg.org/gruf/go-store/v2 v2.0.4
codeberg.org/gruf/go-store/v2 v2.0.5
github.com/buckket/go-blurhash v1.1.0
github.com/coreos/go-oidc/v3 v3.4.0
github.com/disintegration/imaging v1.6.2

4
go.sum
View file

@ -95,8 +95,8 @@ codeberg.org/gruf/go-runners v1.3.1 h1:d/OQMMMiA6yPaDSbSr0/Jc+lucWmm7AiAZjWffpNK
codeberg.org/gruf/go-runners v1.3.1/go.mod h1:rl0EdZNozkRMb21DAtOL5L4oTfmslYQdZgq2RMMc/H4=
codeberg.org/gruf/go-sched v1.1.1 h1:YtLSQhpypzuD3HTup5oF7LLWB79gTL4nqW06kH4Vwks=
codeberg.org/gruf/go-sched v1.1.1/go.mod h1:SRcdP/5qim+EBT3n3r4aUra1C30yPqV4OJOXuqvgdQM=
codeberg.org/gruf/go-store/v2 v2.0.4 h1:CpGkJUz7qINh3krjtR6dKmKwJKjprbEKKq4dWF+AemI=
codeberg.org/gruf/go-store/v2 v2.0.4/go.mod h1:vKId86ET4ZzG1tE1dMNkfV66rZkcsyqt64UhKt6EYfc=
codeberg.org/gruf/go-store/v2 v2.0.5 h1:AbOka6LkyT9jobPYfK3h5f5dPqx5AjFPhaaqdOWkGyA=
codeberg.org/gruf/go-store/v2 v2.0.5/go.mod h1:vKId86ET4ZzG1tE1dMNkfV66rZkcsyqt64UhKt6EYfc=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=

View file

@ -20,43 +20,13 @@ package storage
import (
"context"
"io"
"net/url"
"codeberg.org/gruf/go-store/v2/kv"
"codeberg.org/gruf/go-store/v2/storage"
)
type Local struct {
KVStore *kv.KVStore
}
func (l *Local) Get(ctx context.Context, key string) ([]byte, error) {
return l.KVStore.Get(ctx, key)
}
func (l *Local) GetStream(ctx context.Context, key string) (io.ReadCloser, error) {
return l.KVStore.GetStream(ctx, key)
}
func (l *Local) PutStream(ctx context.Context, key string, r io.Reader) error {
err := l.KVStore.PutStream(ctx, key, r)
if err == storage.ErrAlreadyExists {
return ErrAlreadyExists
}
return err
}
func (l *Local) Put(ctx context.Context, key string, value []byte) error {
err := l.KVStore.Put(ctx, key, value)
if err == storage.ErrAlreadyExists {
return ErrAlreadyExists
}
return err
}
func (l *Local) Delete(ctx context.Context, key string) error {
return l.KVStore.Delete(ctx, key)
*kv.KVStore
}
func (l *Local) URL(ctx context.Context, key string) *url.URL {

View file

@ -33,8 +33,10 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config"
)
var ErrNotSupported = errors.New("driver does not suppport functionality")
var ErrAlreadyExists = errors.New("storage key already exists")
var (
ErrNotSupported = errors.New("driver does not suppport functionality")
ErrAlreadyExists = storage.ErrAlreadyExists
)
// Driver implements the functionality to store and retrieve blobs
// (images,video,audio)
@ -59,19 +61,19 @@ func AutoConfig() (Driver, error) {
}
return NewS3(mc, config.GetStorageS3BucketName()), nil
case "local":
storageBasePath := config.GetStorageLocalBasePath()
storage, err := kv.OpenDisk(storageBasePath, &storage.DiskConfig{
basePath := config.GetStorageLocalBasePath()
disk, err := storage.OpenDisk(basePath, &storage.DiskConfig{
// Put the store lockfile in the storage dir itself.
// Normally this would not be safe, since we could end up
// overwriting the lockfile if we store a file called 'store.lock'.
// However, in this case it's OK because the keys are set by
// GtS and not the user, so we know we're never going to overwrite it.
LockFile: path.Join(storageBasePath, "store.lock"),
LockFile: path.Join(basePath, "store.lock"),
})
if err != nil {
return nil, fmt.Errorf("error creating storage backend: %s", err)
return nil, fmt.Errorf("error openingdisk storage: %v", err)
}
return &Local{KVStore: storage}, nil
return &Local{kv.New(disk)}, nil
}
return nil, fmt.Errorf("invalid storage backend %s", config.GetStorageBackend())
}

View file

@ -38,10 +38,7 @@ func OpenBlock(path string, cfg *storage.BlockConfig) (*KVStore, error) {
}
func OpenMemory(overwrites bool) *KVStore {
return &KVStore{
mu: mutexes.NewMap(-1, -1),
st: storage.OpenMemory(100, overwrites),
}
return New(storage.OpenMemory(100, overwrites))
}
func OpenS3(endpoint string, bucket string, cfg *storage.S3Config) (*KVStore, error) {
@ -55,6 +52,7 @@ func OpenS3(endpoint string, bucket string, cfg *storage.S3Config) (*KVStore, er
return OpenStorage(storage)
}
// OpenStorage will return a new KVStore instance based on Storage, performing an initial storage.Clean().
func OpenStorage(storage storage.Storage) (*KVStore, error) {
// Perform initial storage clean
err := storage.Clean(context.Background())
@ -63,10 +61,18 @@ func OpenStorage(storage storage.Storage) (*KVStore, error) {
}
// Return new KVStore
return New(storage), nil
}
// New will simply return a new KVStore instance based on Storage.
func New(storage storage.Storage) *KVStore {
if storage == nil {
panic("nil storage")
}
return &KVStore{
mu: mutexes.NewMap(-1, -1),
st: storage,
}, nil
}
}
// RLock acquires a read-lock on supplied key, returning unlock function.

2
vendor/modules.txt vendored
View file

@ -50,7 +50,7 @@ codeberg.org/gruf/go-runners
# codeberg.org/gruf/go-sched v1.1.1
## explicit; go 1.19
codeberg.org/gruf/go-sched
# codeberg.org/gruf/go-store/v2 v2.0.4
# codeberg.org/gruf/go-store/v2 v2.0.5
## explicit; go 1.19
codeberg.org/gruf/go-store/v2/kv
codeberg.org/gruf/go-store/v2/storage