all repos — honk @ f70755137e324c6ff4f506aa38be47087b7bf22b

my fork of honk

make the timeouts configurable
Ted Unangst tedu@tedunangst.com
Fri, 20 May 2022 12:33:48 -0400
commit

f70755137e324c6ff4f506aa38be47087b7bf22b

parent

a6e299aa8342c31214f2d1ab3b71a22854ba1c53

2 files changed, 8 insertions(+), 3 deletions(-)

jump to
M activity.goactivity.go

@@ -46,6 +46,9 @@ }

var itiswhatitis = "https://www.w3.org/ns/activitystreams" var thewholeworld = "https://www.w3.org/ns/activitystreams#Public" +var fastTimeout time.Duration = 5 +var slowTimeout time.Duration = 30 + func friendorfoe(ct string) bool { ct = strings.ToLower(ct) for _, at := range falsenames {

@@ -80,7 +83,7 @@ }

req.Header.Set("User-Agent", "honksnonk/5.0; "+serverName) req.Header.Set("Content-Type", theonetruename) httpsig.SignRequest(keyname, key, req, msg) - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 2*slowTimeout*time.Second) defer cancel() req = req.WithContext(ctx) resp, err := client.Do(req)

@@ -100,11 +103,11 @@ return nil

} func GetJunk(url string) (junk.Junk, error) { - return GetJunkTimeout(url, 30*time.Second) + return GetJunkTimeout(url, slowTimeout*time.Second) } func GetJunkFast(url string) (junk.Junk, error) { - return GetJunkTimeout(url, 5*time.Second) + return GetJunkTimeout(url, fastTimeout*time.Second) } func GetJunkHardMode(url string) (junk.Junk, error) {
M honk.gohonk.go

@@ -320,6 +320,8 @@ serverPrefix = fmt.Sprintf("https://%s/", serverName)

getconfig("usersep", &userSep) getconfig("honksep", &honkSep) getconfig("devel", &develMode) + getconfig("fasttimeout", &fastTimeout) + getconfig("slowtimeout", &slowTimeout) prepareStatements(db) switch cmd { case "admin":