From 13a2e30a9d0359bb6308626db9eb3132c3bbf058 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 6 Feb 2024 13:51:26 -0500 Subject: [PATCH] Allow custom timeout with dhall coder --- lib/dhall/coder.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dhall/coder.rb b/lib/dhall/coder.rb index 5cf0b72..7dedb25 100644 --- a/lib/dhall/coder.rb +++ b/lib/dhall/coder.rb @@ -35,8 +35,8 @@ module Dhall end end - def self.load(source, transform_keys: :to_s) - new.load(source, transform_keys: transform_keys) + def self.load(source, transform_keys: :to_s, timeout: 10) + new.load(source, transform_keys: transform_keys, timeout: timeout) end def self.dump(obj) @@ -49,17 +49,17 @@ module Dhall @verifier.verify(default, "default value") end - def load_async(source, op="load_async", transform_keys: :to_s) + def load_async(source, op="load_async", transform_keys: :to_s, timeout: 10) return Promise.resolve(@default) if source.nil? return Promise.resolve(source) unless source.is_a?(String) - Dhall.load(source).then do |expr| + Dhall.load(source, timeout: timeout).then do |expr| decode(expr, op, transform_keys: transform_keys) end end - def load(source, transform_keys: :to_s) - load_async(source, "load", transform_keys: transform_keys).sync + def load(source, transform_keys: :to_s, timeout: 10) + load_async(source, "load", transform_keys: transform_keys, timeout: timeout).sync end module ToRuby -- 2.45.2