ic
ic copied to clipboard
feat(outcalls): add flexible outcalls endpoint
This PR adds a new FlexibleHttpRequest as an Ic00 method. Making a well formatted request to it will result in a "Not implemented" error. In the future, this API will return a list of responses. The candid of the request has the following structure:
record {
url : text;
headers : vec http_header;
method : variant { get; head; post };
body : opt blob;
transform : opt record {
function : func (record {response : http_response; context : blob}) -> (http_response) query;
context : blob;
};
requested_counts: opt record {
min_responses: nat64;
max_responses: nat64;
total_requests: nat64;
};
}
compared to the current one used for fully replicated requests:
record {
url : text;
max_response_bytes : opt nat64;
headers : vec http_header;
method : variant { get; head; post };
body : opt blob;
transform : opt record {
function : func (record {response : http_response; context : blob}) -> (http_response) query;
context : blob;
};
is_replicated : opt bool;
pricing_version : opt nat32;
}
Explanation of the differences:
- addition of
total_requests: opt nat32: this field specifies how many replicas should attempt the outcall (making the API "flexible"). If missing, it defaults to the replication factor. It's also the replication factor for fully replicated requests (ie all replicas attempt the outcall) - addition of
min_responses : opt nat32: this field specifies the minimum number of responses that should be contained in the response. This field is non-sensical for fully replicated requests, as they have unique responses - addition of
max_responses: opt nat32: same asmin_responses, but specifies the (inclusive) upper limit. - removal of
is_replicated. This information is already contained in the above three parameters. ifis_replicated = Some(false), this corresponds to(total_requests = N, min_responses = 1, max_responses = 1). - removal of
pricing_version. we will implement flexible outcalls with the "pay-as-you-go" pricing model from the beginning, so there is (currently) no need for maintaining multiple pricing versions. - removal of
max_response_bytes: that parameter is no longer used with the pay-as-you-go pricing model
The candid of the response has not been introduced in the PR, as it's not being created anywhere yet. We'll introduce it once it's created