heroiclabs / nakama-defold

Defold client for Nakama server.
https://heroiclabs.com
Apache License 2.0
74 stars 12 forks source link

Added global and per-request retries of failed requests #56

Closed britzl closed 1 year ago

britzl commented 1 year ago

This PR adds support for automatic retries of failed requests. A retry policy can either defined globally and/or set per request:

    local retries = require "nakama.util.retries"

    -- use a global retry policy with 5 attempts with 1 second intervals
    local config = {
        host = "127.0.0.1",
        port = 7350,
        username = "defaultkey",
        password = "",
        retry_policy = retries.fixed(5, 1),
        engine = defold,
    }
    local client = nakama.create_client(config)

    -- use a retry policy specifically for this request
    -- 5 retries at intervals increasing by 1 second between attempts (eg 1s, 2s, 3s, 4s, 5s)
    nakama.list_friends(client, 10, 0, "", retries.incremental(5, 1))

Fixes #39

tomglenn commented 1 year ago

@britzl Last comment sorry, can we update CHANGELOG too.