[feat] Support redis call with wasm-rust (#1417)

This commit is contained in:
007gzs
2024-10-29 19:35:02 +08:00
committed by GitHub
parent 93c1e5c2bb
commit 2219a17898
18 changed files with 1698 additions and 154 deletions

View File

@@ -14,7 +14,7 @@
#![allow(dead_code)]
use proxy_wasm::hostcalls;
use proxy_wasm::hostcalls::{self, RedisCallbackFn};
use proxy_wasm::types::{BufferType, Bytes, MapType, Status};
use std::time::{Duration, SystemTime};
@@ -381,3 +381,24 @@ pub(crate) fn send_http_response(
) {
hostcalls::send_http_response(status_code, headers, body).unwrap()
}
pub(crate) fn redis_init(
upstream: &str,
username: Option<&[u8]>,
password: Option<&[u8]>,
timeout: Duration,
) -> Result<(), Status> {
hostcalls::redis_init(upstream, username, password, timeout)
}
pub(crate) fn dispatch_redis_call(
upstream: &str,
query: &[u8],
call_fn: Box<RedisCallbackFn>,
) -> Result<u32, Status> {
hostcalls::dispatch_redis_call(upstream, query, call_fn)
}
pub(crate) fn get_redis_call_response(start: usize, max_size: usize) -> Option<Bytes> {
hostcalls::get_buffer(BufferType::RedisCallResponse, start, max_size).unwrap()
}