summaryrefslogtreecommitdiff
path: root/internal/gotosocial
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-02-12 18:27:58 +0000
committerLibravatar GitHub <noreply@github.com>2022-02-12 18:27:58 +0000
commit31935ee206107f077878d3cdb6a26b82436b6893 (patch)
tree2d522bf98013dc5a4539133561b645fd7457eb06 /internal/gotosocial
parent[chore] Add nightly mirror to Codeberg.org (#392) (diff)
parentGo mod tidy (diff)
downloadgotosocial-0.2.0.tar.xz
Merge pull request #361 from superseriousbusiness/media_refactorv0.2.0
Refactor media handler to allow async media resolution
Diffstat (limited to 'internal/gotosocial')
-rw-r--r--internal/gotosocial/gotosocial.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/internal/gotosocial/gotosocial.go b/internal/gotosocial/gotosocial.go
index 01a77ce2a..7b2d16e5e 100644
--- a/internal/gotosocial/gotosocial.go
+++ b/internal/gotosocial/gotosocial.go
@@ -23,6 +23,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@@ -41,19 +42,21 @@ type Server interface {
// NewServer returns a new gotosocial server, initialized with the given configuration.
// An error will be returned the caller if something goes wrong during initialization
// eg., no db or storage connection, port for router already in use, etc.
-func NewServer(db db.DB, apiRouter router.Router, federator federation.Federator) (Server, error) {
+func NewServer(db db.DB, apiRouter router.Router, federator federation.Federator, mediaManager media.Manager) (Server, error) {
return &gotosocial{
- db: db,
- apiRouter: apiRouter,
- federator: federator,
+ db: db,
+ apiRouter: apiRouter,
+ federator: federator,
+ mediaManager: mediaManager,
}, nil
}
// gotosocial fulfils the gotosocial interface.
type gotosocial struct {
- db db.DB
- apiRouter router.Router
- federator federation.Federator
+ db db.DB
+ apiRouter router.Router
+ federator federation.Federator
+ mediaManager media.Manager
}
// Start starts up the gotosocial server. If something goes wrong
@@ -63,13 +66,16 @@ func (gts *gotosocial) Start(ctx context.Context) error {
return nil
}
-// Stop closes down the gotosocial server, first closing the router
-// then the database. If something goes wrong while stopping, an
-// error will be returned.
+// Stop closes down the gotosocial server, first closing the router,
+// then the media manager, then the database.
+// If something goes wrong while stopping, an error will be returned.
func (gts *gotosocial) Stop(ctx context.Context) error {
if err := gts.apiRouter.Stop(ctx); err != nil {
return err
}
+ if err := gts.mediaManager.Stop(); err != nil {
+ return err
+ }
if err := gts.db.Stop(ctx); err != nil {
return err
}