feat: release Dever 0.1.5 with direct workers and long transactions
This commit is contained in:
1 parent
89629c2197
commit
a900d7e8db
153 files changed
+3676
-3708
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#include "dever_ffi.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern long long fixture_triple(long long value);
|
||||
|
||||
static int invoke(void *context, dever_ffi_slice operation, dever_ffi_slice payload, dever_ffi_output *output) {
|
||||
(void)context;
|
||||
if (operation.size == 6 && memcmp(operation.data, "reject", 6) == 0) {
|
||||
const char *error = "{\"error\":\"example.Rejected\",\"payload\":null}";
|
||||
memcpy(output->data, error, strlen(error));
|
||||
output->size = strlen(error);
|
||||
return DEVER_FFI_ERROR;
|
||||
}
|
||||
if (operation.size == 10 && memcmp(operation.data, "bad_length", 10) == 0) {
|
||||
output->size = output->capacity + 1;
|
||||
return DEVER_FFI_OK;
|
||||
}
|
||||
if (operation.size == 5 && memcmp(operation.data, "fault", 5) == 0) return DEVER_FFI_FAULT;
|
||||
if (payload.size >= 64) return DEVER_FFI_FAULT;
|
||||
char input[64];
|
||||
memcpy(input, payload.data, (size_t)payload.size);
|
||||
input[payload.size] = 0;
|
||||
long long value = 0;
|
||||
if (sscanf(input, "{\"value\":%lld}", &value) != 1 || value > 1000000 || value < -1000000) return DEVER_FFI_FAULT;
|
||||
int size = snprintf(output->data, (size_t)output->capacity, "{\"value\":%lld}", fixture_triple(value));
|
||||
if (size < 0 || (uint64_t)size >= output->capacity) return DEVER_FFI_FAULT;
|
||||
output->size = (uint64_t)size;
|
||||
return DEVER_FFI_OK;
|
||||
}
|
||||
|
||||
static void closed(void *context) {
|
||||
(void)context;
|
||||
fputs("closed\n", stderr);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
const dever_ffi_handler handler = {DEVER_FFI_ABI_V1, NULL, NULL, invoke, closed};
|
||||
return dever_ffi_serve(&handler);
|
||||
}
|
||||
Reference in new issue
Block a user