[performance] Add dereference shortcuts to avoid making http calls to self (#430)

* update transport (controller) to allow shortcuts

* go fmt

* expose underlying sig transport to allow test sigs
This commit is contained in:
tobi 2022-03-15 15:01:19 +01:00 committed by GitHub
commit e63b653199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 114 additions and 22 deletions

View file

@ -23,6 +23,8 @@ import (
"net/url"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/superseriousbusiness/gotosocial/internal/config"
)
func (t *transport) BatchDeliver(ctx context.Context, b []byte, recipients []*url.URL) error {
@ -30,6 +32,11 @@ func (t *transport) BatchDeliver(ctx context.Context, b []byte, recipients []*ur
}
func (t *transport) Deliver(ctx context.Context, b []byte, to *url.URL) error {
// if the 'to' host is our own, just skip this delivery since we by definition already have the message!
if to.Host == viper.GetString(config.Keys.Host) {
return nil
}
l := logrus.WithField("func", "Deliver")
l.Debugf("performing POST to %s", to.String())
return t.sigTransport.Deliver(ctx, b, to)