diff --git a/README.md b/README.md index 54ab2eb..462129c 100644 --- a/README.md +++ b/README.md @@ -406,7 +406,7 @@ Server mode needs only a TTL: client = Schematic::SchematicClient.new( api_key: ENV["SCHEMATIC_API_KEY"], credit_leases: { - default_reservation_ttl: 60 * 1000 # how long the server holds the credits if no track settles them (ms, max 1 hour) + default_reservation_ttl: 60 * 1000 # how long the server holds the credits if no track settles them (ms, max 24 hours) } ) ``` diff --git a/lib/schematic/credits/leases/types.rb b/lib/schematic/credits/leases/types.rb index 92f9823..da7b74c 100644 --- a/lib/schematic/credits/leases/types.rb +++ b/lib/schematic/credits/leases/types.rb @@ -18,11 +18,11 @@ module Leases DEFAULT_LEASE_DURATION_MS = 5 * 60 * 1000 DEFAULT_RESERVATION_TTL_MS = 60 * 1000 - # The API rejects a hold whose expires_at is more than an hour out, so a + # The API rejects a hold whose expires_at is more than 24 hours out, so a # larger reservation TTL would fail every server-mode check. The SDK # clamps to this instead. - MAX_RESERVATION_TTL_MS = 60 * 60 * 1000 - # The API measures that hour against its own clock while the SDK computes + MAX_RESERVATION_TTL_MS = 24 * 60 * 60 * 1000 + # The API measures that cap against its own clock while the SDK computes # expires_at against the caller's, so a client running ahead would be # rejected at exactly the cap. Hold this much back from it. RESERVATION_TTL_SKEW_ALLOWANCE_MS = 60 * 1000 diff --git a/lib/schematic/schematic_client.rb b/lib/schematic/schematic_client.rb index 3536a4a..882452c 100644 --- a/lib/schematic/schematic_client.rb +++ b/lib/schematic/schematic_client.rb @@ -970,7 +970,7 @@ def resolve_credit_lease_mode(value) :auto end - # The API refuses a hold expiring more than an hour after its own clock, and + # The API refuses a hold expiring more than 24 hours after its own clock, and # this TTL is applied to the caller's, so clamp a step below the cap to leave # room for skew. Only server mode sends the value to the API: in client mode # it sizes the local sweep, so clamping there would shorten holds for no diff --git a/test/credits_test.rb b/test/credits_test.rb index 6447330..268c4c1 100644 --- a/test/credits_test.rb +++ b/test/credits_test.rb @@ -1522,10 +1522,10 @@ def test_auto_resolves_per_check_and_falls_to_server_when_the_datastream_goes_aw client&.close end - # The API refuses a hold expiring more than an hour out, measured against its + # The API refuses a hold expiring more than 24 hours out, measured against its # own clock, so a server-mode TTL is clamped a step below the cap. def test_a_server_mode_reservation_ttl_is_clamped_below_the_api_cap - client = build_client(credit_leases: { mode: :server, default_reservation_ttl: 2 * 60 * 60 * 1000 }) + client = build_client(credit_leases: { mode: :server, default_reservation_ttl: 25 * 60 * 60 * 1000 }) assert_equal Leases::MAX_RESERVATION_TTL_MS - Leases::RESERVATION_TTL_SKEW_ALLOWANCE_MS, client.instance_variable_get(:@server_reservation_ttl_ms) @@ -1536,9 +1536,9 @@ def test_a_server_mode_reservation_ttl_is_clamped_below_the_api_cap # In client mode the TTL sizes the local sweep, so clamping it would shorten # holds for no reason. def test_a_client_mode_reservation_ttl_is_left_alone - client = build_client(credit_leases: { mode: :client, default_reservation_ttl: 2 * 60 * 60 * 1000 }) + client = build_client(credit_leases: { mode: :client, default_reservation_ttl: 25 * 60 * 60 * 1000 }) - assert_equal 2 * 60 * 60 * 1000, client.instance_variable_get(:@server_reservation_ttl_ms) + assert_equal 25 * 60 * 60 * 1000, client.instance_variable_get(:@server_reservation_ttl_ms) ensure client&.close end