mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
feat: add participant-scoped proposal recovery
This commit is contained in:
@@ -52,6 +52,12 @@ func recover_queue(ticket_id: String) -> Error:
|
||||
return _start_request("queue_recover", HTTPClient.METHOD_GET, "/v1/queue/" + ticket_id, {}, "")
|
||||
|
||||
|
||||
func recover_proposal(proposal_id: String) -> Error:
|
||||
if proposal_id.is_empty():
|
||||
return ERR_INVALID_PARAMETER
|
||||
return _start_request("proposal_recover", HTTPClient.METHOD_GET, "/v1/proposals/" + proposal_id, {}, "")
|
||||
|
||||
|
||||
func heartbeat(ticket_id: String, expected_revision: int) -> Error:
|
||||
if ticket_id.is_empty() or expected_revision < 0:
|
||||
return ERR_INVALID_PARAMETER
|
||||
@@ -105,7 +111,7 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
var operation := _operation
|
||||
_operation = ""
|
||||
if result != HTTPRequest.RESULT_SUCCESS:
|
||||
if operation == "queue_create" or operation == "queue_recover":
|
||||
if operation == "queue_create" or operation == "queue_recover" or operation == "proposal_recover":
|
||||
state.fail("Control-plane request failed")
|
||||
else:
|
||||
state.set_notice("Control-plane request failed; retrying is safe")
|
||||
@@ -113,7 +119,7 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
return
|
||||
var parsed = JSON.parse_string(body.get_string_from_utf8())
|
||||
if not parsed is Dictionary:
|
||||
if operation == "queue_create" or operation == "queue_recover":
|
||||
if operation == "queue_create" or operation == "queue_recover" or operation == "proposal_recover":
|
||||
state.fail("Control-plane returned invalid JSON")
|
||||
else:
|
||||
state.set_notice("Control-plane returned invalid JSON; retrying is safe")
|
||||
@@ -121,7 +127,7 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
return
|
||||
if response_code < 200 or response_code >= 300:
|
||||
var detail := String(parsed.get("error", "request rejected"))
|
||||
if operation == "queue_create" or operation == "queue_recover":
|
||||
if operation == "queue_create" or operation == "queue_recover" or operation == "proposal_recover":
|
||||
state.fail(detail)
|
||||
else:
|
||||
state.set_notice(detail)
|
||||
|
||||
Reference in New Issue
Block a user