Something went wrong. Try again.
xburner is an experimental HTTP and gRPC load generator written in Zig.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586#include "xburner_workflow_guest.h"
#include <stddef.h>#include <stdint.h>
XBURNER_IMPORT("env", "host_set_var")extern int32_t host_set_var(const uint8_t *key, uint32_t key_len, const uint8_t *val, uint32_t val_len);
static xburner_http_request_action_v1_t g_action;static uint8_t g_request_body[] = {0x0a, 0x04, 'p', 'i', 'n', 'g'};static uint32_t g_sent;static uint32_t g_setup_ok;static const uint8_t METHOD_SUFFIX_KEY[] = "setup.METHOD_SUFFIX";static const uint8_t METHOD_SUFFIX_VAL[] = "Unary";
uint32_t get_abi_version(void) { return xburner_get_abi_version_v1(); }
int32_t init(uint32_t vu_id, uint32_t seed_hi, uint32_t seed_lo) { (void)vu_id; (void)seed_hi; (void)seed_lo; return 0;}
int32_t setup(uint32_t input_ptr, uint32_t input_len) { (void)input_ptr; (void)input_len;
if (host_set_var(METHOD_SUFFIX_KEY, sizeof(METHOD_SUFFIX_KEY) - 1, METHOD_SUFFIX_VAL, sizeof(METHOD_SUFFIX_VAL) - 1) != 0) { return 1; } g_setup_ok = 1; return 0;}
int32_t teardown(void) { return g_setup_ok != 0 ? 0 : 1; }
int32_t start_iteration(uint32_t input_ptr, uint32_t input_len) { (void)input_ptr; (void)input_len; g_sent = 0; return 0;}
uint64_t next_request(void) { if (g_sent != 0) { return 0; }
g_sent = 1; g_action.version = XBURNER_ABI_VERSION; g_action.flags = XBURNER_REQUEST_FLAG_HAS_BODY; g_action.request_id = 1; g_action.body_ptr = (uint32_t)(uintptr_t)g_request_body; g_action.body_len = (uint32_t)sizeof(g_request_body); g_action.timeout_ms = 0; g_action.capture_body_max_bytes = 0; return xburner_pack_ptr_len(&g_action, sizeof(g_action));}
int32_t handle_response(uint32_t meta_ptr, uint32_t meta_len, uint32_t body_ptr, uint32_t body_len) { const xburner_grpc_response_meta_v1_t *meta = (const xburner_grpc_response_meta_v1_t *)(uintptr_t)meta_ptr; const uint8_t *body = (const uint8_t *)(uintptr_t)body_ptr; size_t i;
if (meta_len != sizeof(*meta)) { return XBURNER_HANDLE_RESPONSE_FATAL_SCRIPT_ERROR; } if (meta->grpc_status != 0 || meta->transport_code != XBURNER_TRANSPORT_NONE) { return XBURNER_HANDLE_RESPONSE_DONE_FAILED_CHECK; } if (body_len != sizeof(g_request_body)) { return XBURNER_HANDLE_RESPONSE_DONE_FAILED_CHECK; } for (i = 0; i < sizeof(g_request_body); ++i) { if (body[i] != g_request_body[i]) { return XBURNER_HANDLE_RESPONSE_DONE_FAILED_CHECK; } } return XBURNER_HANDLE_RESPONSE_DONE_SUCCESS;}