From 50375d5596e39b4fde663223c79a26305da2be53 Mon Sep 17 00:00:00 2001 From: Chris Molozian Date: Wed, 23 May 2018 00:22:19 +0800 Subject: [PATCH] Add timeout option to HTTP request function in code runtime. --- CHANGELOG.md | 3 +++ server/runtime_nakama_module.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f670ebb2..6cae5838b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org). ## [Unreleased] +### Added +- New timeout option to HTTP request function in the code runtime. + ## [2.0.0] - 2018-05-14 diff --git a/server/runtime_nakama_module.go b/server/runtime_nakama_module.go index 8b94143cd..b7849a3f7 100644 --- a/server/runtime_nakama_module.go +++ b/server/runtime_nakama_module.go @@ -532,6 +532,10 @@ func (n *NakamaModule) httpRequest(l *lua.LState) int { return 0 } + // Set a custom timeout if one is provided, or use the default. + timeoutMs := l.OptInt64(5, 5000) + n.client.Timeout = time.Duration(timeoutMs) * time.Millisecond + // Prepare request body, if any. var requestBody io.Reader if body != "" { -- GitLab