/* * Copyright (C) 2024-present ScyllaDB */ /* * SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0 */ #pragma once #include #include "rust/wasmtime_bindings.hh" #include "lang/wasm_instance_cache.hh" #include "lang/wasm_alien_thread_runner.hh" #include "cql3/functions/user_function.hh" namespace wasm { struct context; } namespace lang { class manager : public seastar::peering_sharded_service { std::shared_ptr> _engine; std::optional _instance_cache; std::shared_ptr _alien_runner; public: const uint64_t wasm_yield_fuel; const uint64_t wasm_total_fuel; const unsigned lua_max_bytes; const unsigned lua_max_contiguous; const std::chrono::milliseconds lua_timeout; public: struct wasm_config { size_t udf_memory_limit; size_t cache_size; size_t cache_instance_size; std::chrono::milliseconds cache_timer_period; uint64_t yield_fuel; uint64_t total_fuel; }; struct lua_config { unsigned max_bytes; unsigned max_contiguous; std::chrono::milliseconds timeout; }; struct config { std::optional wasm; lua_config lua; }; manager(config); future<> start(); future<> stop(); void remove(const db::functions::function_name& name, const std::vector& arg_types) noexcept { _instance_cache->remove(name, arg_types); } using context = std::optional; future create(sstring language, sstring name, const std::vector& arg_names, std::string script); }; } // lang namespace