Compare commits
1 Commits
main
...
renovate/c
Author | SHA1 | Date | |
---|---|---|---|
278c07df34 |
229
alloy/Cargo.lock
generated
229
alloy/Cargo.lock
generated
@ -6,8 +6,6 @@ version = 4
|
|||||||
name = "alloy"
|
name = "alloy"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
|
||||||
"minijinja",
|
|
||||||
"wit-bindgen-rt",
|
"wit-bindgen-rt",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -17,233 +15,6 @@ version = "2.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs"
|
|
||||||
version = "5.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-sys"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"option-ext",
|
|
||||||
"redox_users",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "getrandom"
|
|
||||||
version = "0.2.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"wasi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.167"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libredox"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "minijinja"
|
|
||||||
version = "2.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2c37e1b517d1dcd0e51dc36c4567b9d5a29262b3ec8da6cb5d35e27a8fb529b5"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "option-ext"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.92"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.37"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_users"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom",
|
|
||||||
"libredox",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.217"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
|
|
||||||
dependencies = [
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.217"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "2.0.90"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror"
|
|
||||||
version = "1.0.69"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror-impl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror-impl"
|
|
||||||
version = "1.0.69"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-sys"
|
|
||||||
version = "0.48.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
|
||||||
dependencies = [
|
|
||||||
"windows-targets",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-targets"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
|
||||||
dependencies = [
|
|
||||||
"windows_aarch64_gnullvm",
|
|
||||||
"windows_aarch64_msvc",
|
|
||||||
"windows_i686_gnu",
|
|
||||||
"windows_i686_msvc",
|
|
||||||
"windows_x86_64_gnu",
|
|
||||||
"windows_x86_64_gnullvm",
|
|
||||||
"windows_x86_64_msvc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_gnullvm"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_msvc"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnu"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_msvc"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnu"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnullvm"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_msvc"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen-rt"
|
name = "wit-bindgen-rt"
|
||||||
version = "0.36.0"
|
version = "0.36.0"
|
||||||
|
@ -4,8 +4,6 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs = "5.0.1"
|
|
||||||
minijinja = "2.5.0"
|
|
||||||
wit-bindgen-rt = { version = "0.36.0", features = ["bitflags"] }
|
wit-bindgen-rt = { version = "0.36.0", features = ["bitflags"] }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
// Sample config for Alloy.
|
|
||||||
//
|
|
||||||
// For a full configuration reference, see https://grafana.com/docs/alloy
|
|
||||||
logging {
|
|
||||||
level = "warn"
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.exporter.unix "default" {
|
|
||||||
include_exporter_metrics = true
|
|
||||||
disable_collectors = ["mdadm"]
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.scrape "default" {
|
|
||||||
targets = array.concat(
|
|
||||||
prometheus.exporter.unix.default.targets,
|
|
||||||
[{
|
|
||||||
// Self-collect metrics
|
|
||||||
job = "alloy",
|
|
||||||
__address__ = "127.0.0.1:12345",
|
|
||||||
group = "infrastructure",
|
|
||||||
}],
|
|
||||||
)
|
|
||||||
|
|
||||||
forward_to = [
|
|
||||||
// TODO: components to forward metrics to (like prometheus.remote_write or
|
|
||||||
// prometheus.relabel).
|
|
||||||
prometheus.remote_write.default.receiver,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.remote_write "default" {
|
|
||||||
external_labels = {
|
|
||||||
"node" = "{{ node_name }}",
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint {
|
|
||||||
url = "https://prometheus.i.kjuulh.io/api/v1/write"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local.file_match "local_files" {
|
|
||||||
path_targets = [{"__path__" = "/var/log/*.log"}]
|
|
||||||
sync_period = "5s"
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.file "log_scrape" {
|
|
||||||
targets = local.file_match.local_files.targets
|
|
||||||
forward_to = [loki.process.filter_logs.receiver]
|
|
||||||
tail_from_end = true
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.journal "default" {
|
|
||||||
forward_to = [loki.process.filter_logs.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
discovery.docker "linux" {
|
|
||||||
host = "unix:///var/run/docker.sock"
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.docker "default" {
|
|
||||||
host = "unix:///var/run/docker.sock"
|
|
||||||
targets = discovery.docker.linux.targets
|
|
||||||
labels = {"app" = "docker"}
|
|
||||||
forward_to = [loki.write.grafana_loki.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.process "filter_logs" {
|
|
||||||
stage.drop {
|
|
||||||
source = ""
|
|
||||||
expression = ".*Connection closed by authenticating user root"
|
|
||||||
drop_counter_reason = "noisy"
|
|
||||||
}
|
|
||||||
forward_to = [loki.write.grafana_loki.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.write "grafana_loki" {
|
|
||||||
external_labels = {
|
|
||||||
"node" = "{{ node_name }}",
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint {
|
|
||||||
url = "https://loki.i.kjuulh.io/loki/api/v1/push"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,170 +1,4 @@
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub mod component {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub mod churn_tasks {
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod process {
|
|
||||||
#[used]
|
|
||||||
#[doc(hidden)]
|
|
||||||
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
|
|
||||||
use super::super::super::_rt;
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Process {
|
|
||||||
handle: _rt::Resource<Process>,
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
Self {
|
|
||||||
handle: _rt::Resource::from_handle(handle),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(&self) -> u32 {
|
|
||||||
_rt::Resource::take_handle(&self.handle)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(&self) -> u32 {
|
|
||||||
_rt::Resource::handle(&self.handle)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsafe impl _rt::WasmResource for Process {
|
|
||||||
#[inline]
|
|
||||||
unsafe fn drop(_handle: u32) {
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
unreachable!();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
{
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[resource-drop]process"]
|
|
||||||
fn drop(_: u32);
|
|
||||||
}
|
|
||||||
drop(_handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn new() -> Self {
|
|
||||||
unsafe {
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[constructor]process"]
|
|
||||||
fn wit_import() -> i32;
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import() -> i32 {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
let ret = wit_import();
|
|
||||||
Process::from_handle(ret as u32)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn run_process(&self, inputs: &[_rt::String]) -> _rt::String {
|
|
||||||
unsafe {
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
let mut ret_area = RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
let vec1 = inputs;
|
|
||||||
let len1 = vec1.len();
|
|
||||||
let layout1 = _rt::alloc::Layout::from_size_align_unchecked(
|
|
||||||
vec1.len() * 8,
|
|
||||||
4,
|
|
||||||
);
|
|
||||||
let result1 = if layout1.size() != 0 {
|
|
||||||
let ptr = _rt::alloc::alloc(layout1).cast::<u8>();
|
|
||||||
if ptr.is_null() {
|
|
||||||
_rt::alloc::handle_alloc_error(layout1);
|
|
||||||
}
|
|
||||||
ptr
|
|
||||||
} else {
|
|
||||||
::core::ptr::null_mut()
|
|
||||||
};
|
|
||||||
for (i, e) in vec1.into_iter().enumerate() {
|
|
||||||
let base = result1.add(i * 8);
|
|
||||||
{
|
|
||||||
let vec0 = e;
|
|
||||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
|
||||||
let len0 = vec0.len();
|
|
||||||
*base.add(4).cast::<usize>() = len0;
|
|
||||||
*base.add(0).cast::<*mut u8>() = ptr0.cast_mut();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[method]process.run-process"]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8);
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
wit_import((self).handle() as i32, result1, len1, ptr2);
|
|
||||||
let l3 = *ptr2.add(0).cast::<*mut u8>();
|
|
||||||
let l4 = *ptr2.add(4).cast::<usize>();
|
|
||||||
let len5 = l4;
|
|
||||||
let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5);
|
|
||||||
if layout1.size() != 0 {
|
|
||||||
_rt::alloc::dealloc(result1.cast(), layout1);
|
|
||||||
}
|
|
||||||
_rt::string_lift(bytes5)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn get_variable(&self, key: &str) -> _rt::String {
|
|
||||||
unsafe {
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
let mut ret_area = RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
let vec0 = key;
|
|
||||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
|
||||||
let len0 = vec0.len();
|
|
||||||
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[method]process.get-variable"]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8);
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
|
|
||||||
let l2 = *ptr1.add(0).cast::<*mut u8>();
|
|
||||||
let l3 = *ptr1.add(4).cast::<usize>();
|
|
||||||
let len4 = l3;
|
|
||||||
let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4);
|
|
||||||
_rt::string_lift(bytes4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub mod exports {
|
pub mod exports {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub mod component {
|
pub mod component {
|
||||||
@ -248,90 +82,6 @@ pub mod exports {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mod _rt {
|
mod _rt {
|
||||||
use core::fmt;
|
|
||||||
use core::marker;
|
|
||||||
use core::sync::atomic::{AtomicU32, Ordering::Relaxed};
|
|
||||||
/// A type which represents a component model resource, either imported or
|
|
||||||
/// exported into this component.
|
|
||||||
///
|
|
||||||
/// This is a low-level wrapper which handles the lifetime of the resource
|
|
||||||
/// (namely this has a destructor). The `T` provided defines the component model
|
|
||||||
/// intrinsics that this wrapper uses.
|
|
||||||
///
|
|
||||||
/// One of the chief purposes of this type is to provide `Deref` implementations
|
|
||||||
/// to access the underlying data when it is owned.
|
|
||||||
///
|
|
||||||
/// This type is primarily used in generated code for exported and imported
|
|
||||||
/// resources.
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Resource<T: WasmResource> {
|
|
||||||
handle: AtomicU32,
|
|
||||||
_marker: marker::PhantomData<T>,
|
|
||||||
}
|
|
||||||
/// A trait which all wasm resources implement, namely providing the ability to
|
|
||||||
/// drop a resource.
|
|
||||||
///
|
|
||||||
/// This generally is implemented by generated code, not user-facing code.
|
|
||||||
#[allow(clippy::missing_safety_doc)]
|
|
||||||
pub unsafe trait WasmResource {
|
|
||||||
/// Invokes the `[resource-drop]...` intrinsic.
|
|
||||||
unsafe fn drop(handle: u32);
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> Resource<T> {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
debug_assert!(handle != u32::MAX);
|
|
||||||
Self {
|
|
||||||
handle: AtomicU32::new(handle),
|
|
||||||
_marker: marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Takes ownership of the handle owned by `resource`.
|
|
||||||
///
|
|
||||||
/// Note that this ideally would be `into_handle` taking `Resource<T>` by
|
|
||||||
/// ownership. The code generator does not enable that in all situations,
|
|
||||||
/// unfortunately, so this is provided instead.
|
|
||||||
///
|
|
||||||
/// Also note that `take_handle` is in theory only ever called on values
|
|
||||||
/// owned by a generated function. For example a generated function might
|
|
||||||
/// take `Resource<T>` as an argument but then call `take_handle` on a
|
|
||||||
/// reference to that argument. In that sense the dynamic nature of
|
|
||||||
/// `take_handle` should only be exposed internally to generated code, not
|
|
||||||
/// to user code.
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(resource: &Resource<T>) -> u32 {
|
|
||||||
resource.handle.swap(u32::MAX, Relaxed)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(resource: &Resource<T>) -> u32 {
|
|
||||||
resource.handle.load(Relaxed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> fmt::Debug for Resource<T> {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Resource").field("handle", &self.handle).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> Drop for Resource<T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
match self.handle.load(Relaxed) {
|
|
||||||
u32::MAX => {}
|
|
||||||
other => T::drop(other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub use alloc_crate::string::String;
|
|
||||||
pub use alloc_crate::alloc;
|
|
||||||
pub use alloc_crate::vec::Vec;
|
|
||||||
pub unsafe fn string_lift(bytes: Vec<u8>) -> String {
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
String::from_utf8(bytes).unwrap()
|
|
||||||
} else {
|
|
||||||
String::from_utf8_unchecked(bytes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub fn run_ctors_once() {
|
pub fn run_ctors_once() {
|
||||||
wit_bindgen_rt::run_ctors_once();
|
wit_bindgen_rt::run_ctors_once();
|
||||||
@ -343,6 +93,8 @@ mod _rt {
|
|||||||
let layout = alloc::Layout::from_size_align_unchecked(size, align);
|
let layout = alloc::Layout::from_size_align_unchecked(size, align);
|
||||||
alloc::dealloc(ptr, layout);
|
alloc::dealloc(ptr, layout);
|
||||||
}
|
}
|
||||||
|
pub use alloc_crate::string::String;
|
||||||
|
pub use alloc_crate::alloc;
|
||||||
extern crate alloc as alloc_crate;
|
extern crate alloc as alloc_crate;
|
||||||
}
|
}
|
||||||
/// Generates `#[no_mangle]` functions to export the specified type as the
|
/// Generates `#[no_mangle]` functions to export the specified type as the
|
||||||
@ -378,17 +130,13 @@ pub(crate) use __export_alloy_impl as export;
|
|||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
#[link_section = "component-type:wit-bindgen:0.35.0:component:alloy:alloy:encoded world"]
|
#[link_section = "component-type:wit-bindgen:0.35.0:component:alloy:alloy:encoded world"]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 439] = *b"\
|
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 244] = *b"\
|
||||||
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xbb\x02\x01A\x02\x01\
|
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07y\x01A\x02\x01A\x02\x01\
|
||||||
A\x04\x01B\x0a\x04\0\x07process\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x14[constructo\
|
|
||||||
r]process\x01\x02\x01h\0\x01ps\x01@\x02\x04self\x03\x06inputs\x04\0s\x04\0\x1b[m\
|
|
||||||
ethod]process.run-process\x01\x05\x01@\x02\x04self\x03\x03keys\0s\x04\0\x1c[meth\
|
|
||||||
od]process.get-variable\x01\x06\x03\0#component:churn-tasks/process@0.1.0\x05\0\x01\
|
|
||||||
B\x06\x01@\0\0s\x04\0\x02id\x01\0\x01@\0\0\x7f\x04\0\x0ashould-run\x01\x01\x01@\0\
|
B\x06\x01@\0\0s\x04\0\x02id\x01\0\x01@\0\0\x7f\x04\0\x0ashould-run\x01\x01\x01@\0\
|
||||||
\x01\0\x04\0\x07execute\x01\x02\x04\0\x20component:churn-tasks/task@0.1.0\x05\x01\
|
\x01\0\x04\0\x07execute\x01\x02\x04\0\x20component:churn-tasks/task@0.1.0\x05\0\x04\
|
||||||
\x04\0\x15component:alloy/alloy\x04\0\x0b\x0b\x01\0\x05alloy\x03\0\0\0G\x09produ\
|
\0\x15component:alloy/alloy\x04\0\x0b\x0b\x01\0\x05alloy\x03\0\0\0G\x09producers\
|
||||||
cers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x06\
|
\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.35\
|
||||||
0.35.0";
|
.0";
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn __link_custom_section_describing_imports() {
|
pub fn __link_custom_section_describing_imports() {
|
||||||
|
170
alloy/src/lib.rs
170
alloy/src/lib.rs
@ -1,16 +1,8 @@
|
|||||||
use std::{io::Write, path::PathBuf};
|
use bindings::exports::component::churn_tasks::task::Guest;
|
||||||
|
|
||||||
use bindings::{
|
|
||||||
component::churn_tasks::process::Process, exports::component::churn_tasks::task::Guest,
|
|
||||||
};
|
|
||||||
use minijinja::{context, Environment};
|
|
||||||
|
|
||||||
#[allow(warnings)]
|
#[allow(warnings)]
|
||||||
mod bindings;
|
mod bindings;
|
||||||
|
|
||||||
const ALLOY_CONFIG_PATH: &str = "/etc/alloy/config.alloy";
|
|
||||||
const ALLOY_CONFIG_FILE: &str = include_str!("../files/config.alloy");
|
|
||||||
|
|
||||||
struct Component;
|
struct Component;
|
||||||
|
|
||||||
impl Guest for Component {
|
impl Guest for Component {
|
||||||
@ -19,168 +11,12 @@ impl Guest for Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn should_run() -> bool {
|
fn should_run() -> bool {
|
||||||
let output = Process::new().run_process(
|
true
|
||||||
&["systemctl", "is-enabled", "alloy.service"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| i.into())
|
|
||||||
.collect::<Vec<String>>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
if !output.contains("enabled") {
|
|
||||||
println!("alloy is not enabled");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let output = Process::new().run_process(
|
|
||||||
&["systemctl", "is-active", "alloy.service"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| i.into())
|
|
||||||
.collect::<Vec<String>>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
if output.contains("inactive") {
|
|
||||||
println!("alloy is inactive");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
match std::fs::read_to_string(ALLOY_CONFIG_PATH) {
|
|
||||||
Ok(content) => {
|
|
||||||
let process = Process::new();
|
|
||||||
let node_name = process.get_variable("node_name");
|
|
||||||
let config_file = generate_alloy_file(node_name);
|
|
||||||
let is_different = content != config_file;
|
|
||||||
if is_different {
|
|
||||||
println!("config file was different");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
if e.kind() == std::io::ErrorKind::NotFound {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute() {
|
fn execute() {
|
||||||
println!("running alloy installation");
|
println!("I was run");
|
||||||
|
|
||||||
let process = Process::new();
|
|
||||||
let node_name = process.get_variable("node_name");
|
|
||||||
|
|
||||||
let output = Process::new().run_process(
|
|
||||||
&["systemctl", "is-enabled", "alloy.service"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| i.into())
|
|
||||||
.collect::<Vec<String>>(),
|
|
||||||
);
|
|
||||||
if !output.contains("enabled") {
|
|
||||||
install_alloy().expect("to be able to install alloy");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let config_file = generate_alloy_file(node_name);
|
|
||||||
let restart = match std::fs::read_to_string(ALLOY_CONFIG_PATH) {
|
|
||||||
Ok(content) => {
|
|
||||||
if content != config_file {
|
|
||||||
let mut file = std::fs::File::create(ALLOY_CONFIG_PATH)
|
|
||||||
.expect("to be able to create file");
|
|
||||||
file.write_all(config_file.as_bytes())
|
|
||||||
.expect("to be able to write file");
|
|
||||||
file.flush().expect("to be able to flush file");
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
if e.kind() == std::io::ErrorKind::NotFound {
|
|
||||||
if let Some(parent) = PathBuf::from(ALLOY_CONFIG_PATH).parent() {
|
|
||||||
std::fs::create_dir_all(parent)
|
|
||||||
.expect("to be able to create dir for alloy");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut file = std::fs::File::create(ALLOY_CONFIG_PATH)
|
|
||||||
.expect("to be able to create file");
|
|
||||||
file.write_all(config_file.as_bytes())
|
|
||||||
.expect("to be able to write file");
|
|
||||||
file.flush().expect("to be able to flush file");
|
|
||||||
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if restart {
|
|
||||||
restart_alloy().expect("to be able to restart alloy");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
run_and_activate_alloy().expect("to be able to active alloy");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_alloy_file(node_name: String) -> String {
|
|
||||||
let mut env = Environment::new();
|
|
||||||
env.add_template("alloy.config", ALLOY_CONFIG_FILE).unwrap();
|
|
||||||
let tmpl = env.get_template("alloy.config").unwrap();
|
|
||||||
tmpl.render(context! {node_name => node_name}).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn install_alloy() -> Result<(), String> {
|
|
||||||
println!("=== installing alloy ===");
|
|
||||||
run_command(["apt", "install", "-y", "gpg"])?;
|
|
||||||
run_command(["mkdir", "-p", "/etc/apt/keyrings/"])?;
|
|
||||||
run_command(["bash", "-c", "wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null"])?;
|
|
||||||
run_command(["bash", "-c", "echo \"deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main\" | sudo tee /etc/apt/sources.list.d/grafana.list"])?;
|
|
||||||
run_command(["apt-get", "update"])?;
|
|
||||||
run_command([
|
|
||||||
"apt-get",
|
|
||||||
"install",
|
|
||||||
"-o Dpkg::Options::=\"--force-confdef\"",
|
|
||||||
"-o Dpkg::Options::=\"--force-confold\"",
|
|
||||||
"alloy",
|
|
||||||
])?;
|
|
||||||
println!("=== finished installing alloy ===");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn restart_alloy() -> Result<(), String> {
|
|
||||||
println!("=== restarting alloy ===");
|
|
||||||
run_command(["systemctl", "restart", "alloy"])?;
|
|
||||||
println!("=== finished restarting alloy ===");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_and_activate_alloy() -> Result<(), String> {
|
|
||||||
println!("=== starting alloy ===");
|
|
||||||
run_command(["systemctl", "start", "alloy"])?;
|
|
||||||
println!("=== finished starting alloy ===");
|
|
||||||
|
|
||||||
println!("=== enabling alloy ===");
|
|
||||||
run_command(["systemctl", "enable", "alloy"])?;
|
|
||||||
println!("=== finished enabling alloy ===");
|
|
||||||
|
|
||||||
println!("=== adding alloy to docker group ===");
|
|
||||||
run_command(["usermod", "-aG", "docker", "alloy"])?;
|
|
||||||
println!("=== finished adding alloy to docker group ===");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_command(input: impl IntoIterator<Item = impl Into<String>>) -> Result<(), String> {
|
|
||||||
let args = input.into_iter().map(|i| i.into()).collect::<Vec<String>>();
|
|
||||||
|
|
||||||
println!("running {}", args.join(" "));
|
|
||||||
let output = Process::new().run_process(&args);
|
|
||||||
println!("output: {}", output);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bindings::export!(Component with_types_in bindings);
|
bindings::export!(Component with_types_in bindings);
|
||||||
|
@ -2,6 +2,5 @@ package component:alloy;
|
|||||||
|
|
||||||
/// An example world for the component to target.
|
/// An example world for the component to target.
|
||||||
world alloy {
|
world alloy {
|
||||||
import component:churn-tasks/process@0.1.0;
|
|
||||||
export component:churn-tasks/task@0.1.0;
|
export component:churn-tasks/task@0.1.0;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
#[allow(dead_code)]
|
#[doc(hidden)]
|
||||||
pub mod exports {
|
#[allow(non_snake_case)]
|
||||||
#[allow(dead_code)]
|
pub unsafe fn _export_id_cabi<T: Guest>() -> *mut u8 {
|
||||||
pub mod component {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub mod churn_tasks {
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod task {
|
|
||||||
#[used]
|
|
||||||
#[doc(hidden)]
|
|
||||||
static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports;
|
|
||||||
use super::super::super::super::_rt;
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_id_cabi<T: Guest>() -> *mut u8 {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
||||||
let result0 = T::id();
|
let result0 = T::id();
|
||||||
let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
||||||
@ -23,375 +11,83 @@ pub mod exports {
|
|||||||
*ptr1.add(4).cast::<usize>() = len2;
|
*ptr1.add(4).cast::<usize>() = len2;
|
||||||
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
|
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
|
||||||
ptr1
|
ptr1
|
||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe fn __post_return_id<T: Guest>(arg0: *mut u8) {
|
pub unsafe fn __post_return_id<T: Guest>(arg0: *mut u8) {
|
||||||
let l0 = *arg0.add(0).cast::<*mut u8>();
|
let l0 = *arg0.add(0).cast::<*mut u8>();
|
||||||
let l1 = *arg0.add(4).cast::<usize>();
|
let l1 = *arg0.add(4).cast::<usize>();
|
||||||
_rt::cabi_dealloc(l0, l1, 1);
|
_rt::cabi_dealloc(l0, l1, 1);
|
||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe fn _export_should_run_cabi<T: Guest>() -> i32 {
|
pub unsafe fn _export_should_run_cabi<T: Guest>() -> *mut u8 {
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
||||||
let result0 = T::should_run();
|
let result0 = T::should_run();
|
||||||
match result0 {
|
let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
||||||
true => 1,
|
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||||
false => 0,
|
let ptr2 = vec2.as_ptr().cast::<u8>();
|
||||||
}
|
let len2 = vec2.len();
|
||||||
}
|
::core::mem::forget(vec2);
|
||||||
#[doc(hidden)]
|
*ptr1.add(4).cast::<usize>() = len2;
|
||||||
#[allow(non_snake_case)]
|
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
|
||||||
pub unsafe fn _export_execute_cabi<T: Guest>() {
|
ptr1
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
T::execute();
|
|
||||||
}
|
|
||||||
pub trait Guest {
|
|
||||||
fn id() -> _rt::String;
|
|
||||||
fn should_run() -> bool;
|
|
||||||
fn execute();
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
macro_rules! __export_component_churn_tasks_task_0_1_0_cabi {
|
|
||||||
($ty:ident with_types_in $($path_to_types:tt)*) => {
|
|
||||||
const _ : () = { #[export_name =
|
|
||||||
"component:churn-tasks/task@0.1.0#id"] unsafe extern "C" fn
|
|
||||||
export_id() -> * mut u8 { $($path_to_types)*::
|
|
||||||
_export_id_cabi::<$ty > () } #[export_name =
|
|
||||||
"cabi_post_component:churn-tasks/task@0.1.0#id"] unsafe extern
|
|
||||||
"C" fn _post_return_id(arg0 : * mut u8,) { $($path_to_types)*::
|
|
||||||
__post_return_id::<$ty > (arg0) } #[export_name =
|
|
||||||
"component:churn-tasks/task@0.1.0#should-run"] unsafe extern "C"
|
|
||||||
fn export_should_run() -> i32 { $($path_to_types)*::
|
|
||||||
_export_should_run_cabi::<$ty > () } #[export_name =
|
|
||||||
"component:churn-tasks/task@0.1.0#execute"] unsafe extern "C" fn
|
|
||||||
export_execute() { $($path_to_types)*::
|
|
||||||
_export_execute_cabi::<$ty > () } };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub(crate) use __export_component_churn_tasks_task_0_1_0_cabi;
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct _RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
static mut _RET_AREA: _RetArea = _RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod process {
|
|
||||||
#[used]
|
|
||||||
#[doc(hidden)]
|
|
||||||
static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports;
|
|
||||||
use super::super::super::super::_rt;
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Process {
|
|
||||||
handle: _rt::Resource<Process>,
|
|
||||||
}
|
|
||||||
type _ProcessRep<T> = Option<T>;
|
|
||||||
impl Process {
|
|
||||||
/// Creates a new resource from the specified representation.
|
|
||||||
///
|
|
||||||
/// This function will create a new resource handle by moving `val` onto
|
|
||||||
/// the heap and then passing that heap pointer to the component model to
|
|
||||||
/// create a handle. The owned handle is then returned as `Process`.
|
|
||||||
pub fn new<T: GuestProcess>(val: T) -> Self {
|
|
||||||
Self::type_guard::<T>();
|
|
||||||
let val: _ProcessRep<T> = Some(val);
|
|
||||||
let ptr: *mut _ProcessRep<T> = _rt::Box::into_raw(
|
|
||||||
_rt::Box::new(val),
|
|
||||||
);
|
|
||||||
unsafe { Self::from_handle(T::_resource_new(ptr.cast())) }
|
|
||||||
}
|
|
||||||
/// Gets access to the underlying `T` which represents this resource.
|
|
||||||
pub fn get<T: GuestProcess>(&self) -> &T {
|
|
||||||
let ptr = unsafe { &*self.as_ptr::<T>() };
|
|
||||||
ptr.as_ref().unwrap()
|
|
||||||
}
|
|
||||||
/// Gets mutable access to the underlying `T` which represents this
|
|
||||||
/// resource.
|
|
||||||
pub fn get_mut<T: GuestProcess>(&mut self) -> &mut T {
|
|
||||||
let ptr = unsafe { &mut *self.as_ptr::<T>() };
|
|
||||||
ptr.as_mut().unwrap()
|
|
||||||
}
|
|
||||||
/// Consumes this resource and returns the underlying `T`.
|
|
||||||
pub fn into_inner<T: GuestProcess>(self) -> T {
|
|
||||||
let ptr = unsafe { &mut *self.as_ptr::<T>() };
|
|
||||||
ptr.take().unwrap()
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
Self {
|
|
||||||
handle: _rt::Resource::from_handle(handle),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(&self) -> u32 {
|
|
||||||
_rt::Resource::take_handle(&self.handle)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(&self) -> u32 {
|
|
||||||
_rt::Resource::handle(&self.handle)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
fn type_guard<T: 'static>() {
|
|
||||||
use core::any::TypeId;
|
|
||||||
static mut LAST_TYPE: Option<TypeId> = None;
|
|
||||||
unsafe {
|
|
||||||
assert!(! cfg!(target_feature = "atomics"));
|
|
||||||
let id = TypeId::of::<T>();
|
|
||||||
match LAST_TYPE {
|
|
||||||
Some(ty) => {
|
|
||||||
assert!(
|
|
||||||
ty == id, "cannot use two types with this resource type"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
None => LAST_TYPE = Some(id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn dtor<T: 'static>(handle: *mut u8) {
|
|
||||||
Self::type_guard::<T>();
|
|
||||||
let _ = _rt::Box::from_raw(handle as *mut _ProcessRep<T>);
|
|
||||||
}
|
|
||||||
fn as_ptr<T: GuestProcess>(&self) -> *mut _ProcessRep<T> {
|
|
||||||
Process::type_guard::<T>();
|
|
||||||
T::_resource_rep(self.handle()).cast()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// A borrowed version of [`Process`] which represents a borrowed value
|
|
||||||
/// with the lifetime `'a`.
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct ProcessBorrow<'a> {
|
|
||||||
rep: *mut u8,
|
|
||||||
_marker: core::marker::PhantomData<&'a Process>,
|
|
||||||
}
|
|
||||||
impl<'a> ProcessBorrow<'a> {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn lift(rep: usize) -> Self {
|
|
||||||
Self {
|
|
||||||
rep: rep as *mut u8,
|
|
||||||
_marker: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Gets access to the underlying `T` in this resource.
|
|
||||||
pub fn get<T: GuestProcess>(&self) -> &T {
|
|
||||||
let ptr = unsafe { &mut *self.as_ptr::<T>() };
|
|
||||||
ptr.as_ref().unwrap()
|
|
||||||
}
|
|
||||||
fn as_ptr<T: 'static>(&self) -> *mut _ProcessRep<T> {
|
|
||||||
Process::type_guard::<T>();
|
|
||||||
self.rep.cast()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsafe impl _rt::WasmResource for Process {
|
|
||||||
#[inline]
|
|
||||||
unsafe fn drop(_handle: u32) {
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
unreachable!();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
{
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "[export]component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[resource-drop]process"]
|
|
||||||
fn drop(_: u32);
|
|
||||||
}
|
|
||||||
drop(_handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_constructor_process_cabi<T: GuestProcess>() -> i32 {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
let result0 = Process::new(T::new());
|
|
||||||
(result0).take_handle() as i32
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_method_process_run_process_cabi<T: GuestProcess>(
|
|
||||||
arg0: *mut u8,
|
|
||||||
arg1: *mut u8,
|
|
||||||
arg2: usize,
|
|
||||||
) -> *mut u8 {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
let base3 = arg1;
|
|
||||||
let len3 = arg2;
|
|
||||||
let mut result3 = _rt::Vec::with_capacity(len3);
|
|
||||||
for i in 0..len3 {
|
|
||||||
let base = base3.add(i * 8);
|
|
||||||
let e3 = {
|
|
||||||
let l0 = *base.add(0).cast::<*mut u8>();
|
|
||||||
let l1 = *base.add(4).cast::<usize>();
|
|
||||||
let len2 = l1;
|
|
||||||
let bytes2 = _rt::Vec::from_raw_parts(l0.cast(), len2, len2);
|
|
||||||
_rt::string_lift(bytes2)
|
|
||||||
};
|
|
||||||
result3.push(e3);
|
|
||||||
}
|
|
||||||
_rt::cabi_dealloc(base3, len3 * 8, 4);
|
|
||||||
let result4 = T::run_process(
|
|
||||||
ProcessBorrow::lift(arg0 as u32 as usize).get(),
|
|
||||||
result3,
|
|
||||||
);
|
|
||||||
let ptr5 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
|
||||||
let vec6 = (result4.into_bytes()).into_boxed_slice();
|
|
||||||
let ptr6 = vec6.as_ptr().cast::<u8>();
|
|
||||||
let len6 = vec6.len();
|
|
||||||
::core::mem::forget(vec6);
|
|
||||||
*ptr5.add(4).cast::<usize>() = len6;
|
|
||||||
*ptr5.add(0).cast::<*mut u8>() = ptr6.cast_mut();
|
|
||||||
ptr5
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn __post_return_method_process_run_process<T: GuestProcess>(
|
|
||||||
arg0: *mut u8,
|
|
||||||
) {
|
|
||||||
let l0 = *arg0.add(0).cast::<*mut u8>();
|
|
||||||
let l1 = *arg0.add(4).cast::<usize>();
|
|
||||||
_rt::cabi_dealloc(l0, l1, 1);
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_method_process_get_variable_cabi<T: GuestProcess>(
|
|
||||||
arg0: *mut u8,
|
|
||||||
arg1: *mut u8,
|
|
||||||
arg2: usize,
|
|
||||||
) -> *mut u8 {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
let len0 = arg2;
|
|
||||||
let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0);
|
|
||||||
let result1 = T::get_variable(
|
|
||||||
ProcessBorrow::lift(arg0 as u32 as usize).get(),
|
|
||||||
_rt::string_lift(bytes0),
|
|
||||||
);
|
|
||||||
let ptr2 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
|
||||||
let vec3 = (result1.into_bytes()).into_boxed_slice();
|
|
||||||
let ptr3 = vec3.as_ptr().cast::<u8>();
|
|
||||||
let len3 = vec3.len();
|
|
||||||
::core::mem::forget(vec3);
|
|
||||||
*ptr2.add(4).cast::<usize>() = len3;
|
|
||||||
*ptr2.add(0).cast::<*mut u8>() = ptr3.cast_mut();
|
|
||||||
ptr2
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn __post_return_method_process_get_variable<T: GuestProcess>(
|
|
||||||
arg0: *mut u8,
|
|
||||||
) {
|
|
||||||
let l0 = *arg0.add(0).cast::<*mut u8>();
|
|
||||||
let l1 = *arg0.add(4).cast::<usize>();
|
|
||||||
_rt::cabi_dealloc(l0, l1, 1);
|
|
||||||
}
|
|
||||||
pub trait Guest {
|
|
||||||
type Process: GuestProcess;
|
|
||||||
}
|
|
||||||
pub trait GuestProcess: 'static {
|
|
||||||
#[doc(hidden)]
|
|
||||||
unsafe fn _resource_new(val: *mut u8) -> u32
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
{
|
|
||||||
let _ = val;
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
{
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "[export]component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[resource-new]process"]
|
|
||||||
fn new(_: *mut u8) -> u32;
|
|
||||||
}
|
|
||||||
new(val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
fn _resource_rep(handle: u32) -> *mut u8
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
{
|
|
||||||
let _ = handle;
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
{
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "[export]component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[resource-rep]process"]
|
|
||||||
fn rep(_: u32) -> *mut u8;
|
|
||||||
}
|
|
||||||
unsafe { rep(handle) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn new() -> Self;
|
|
||||||
fn run_process(&self, inputs: _rt::Vec<_rt::String>) -> _rt::String;
|
|
||||||
fn get_variable(&self, key: _rt::String) -> _rt::String;
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
macro_rules! __export_component_churn_tasks_process_0_1_0_cabi {
|
|
||||||
($ty:ident with_types_in $($path_to_types:tt)*) => {
|
|
||||||
const _ : () = { #[export_name =
|
|
||||||
"component:churn-tasks/process@0.1.0#[constructor]process"]
|
|
||||||
unsafe extern "C" fn export_constructor_process() -> i32 {
|
|
||||||
$($path_to_types)*:: _export_constructor_process_cabi::<<$ty as
|
|
||||||
$($path_to_types)*:: Guest >::Process > () } #[export_name =
|
|
||||||
"component:churn-tasks/process@0.1.0#[method]process.run-process"]
|
|
||||||
unsafe extern "C" fn export_method_process_run_process(arg0 : *
|
|
||||||
mut u8, arg1 : * mut u8, arg2 : usize,) -> * mut u8 {
|
|
||||||
$($path_to_types)*::
|
|
||||||
_export_method_process_run_process_cabi::<<$ty as
|
|
||||||
$($path_to_types)*:: Guest >::Process > (arg0, arg1, arg2) }
|
|
||||||
#[export_name =
|
|
||||||
"cabi_post_component:churn-tasks/process@0.1.0#[method]process.run-process"]
|
|
||||||
unsafe extern "C" fn _post_return_method_process_run_process(arg0
|
|
||||||
: * mut u8,) { $($path_to_types)*::
|
|
||||||
__post_return_method_process_run_process::<<$ty as
|
|
||||||
$($path_to_types)*:: Guest >::Process > (arg0) } #[export_name =
|
|
||||||
"component:churn-tasks/process@0.1.0#[method]process.get-variable"]
|
|
||||||
unsafe extern "C" fn export_method_process_get_variable(arg0 : *
|
|
||||||
mut u8, arg1 : * mut u8, arg2 : usize,) -> * mut u8 {
|
|
||||||
$($path_to_types)*::
|
|
||||||
_export_method_process_get_variable_cabi::<<$ty as
|
|
||||||
$($path_to_types)*:: Guest >::Process > (arg0, arg1, arg2) }
|
|
||||||
#[export_name =
|
|
||||||
"cabi_post_component:churn-tasks/process@0.1.0#[method]process.get-variable"]
|
|
||||||
unsafe extern "C" fn
|
|
||||||
_post_return_method_process_get_variable(arg0 : * mut u8,) {
|
|
||||||
$($path_to_types)*::
|
|
||||||
__post_return_method_process_get_variable::<<$ty as
|
|
||||||
$($path_to_types)*:: Guest >::Process > (arg0) } const _ : () = {
|
|
||||||
#[doc(hidden)] #[export_name =
|
|
||||||
"component:churn-tasks/process@0.1.0#[dtor]process"]
|
|
||||||
#[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut
|
|
||||||
u8) { $($path_to_types)*:: Process::dtor::< <$ty as
|
|
||||||
$($path_to_types)*:: Guest >::Process > (rep) } }; };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub(crate) use __export_component_churn_tasks_process_0_1_0_cabi;
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct _RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
static mut _RET_AREA: _RetArea = _RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub unsafe fn __post_return_should_run<T: Guest>(arg0: *mut u8) {
|
||||||
|
let l0 = *arg0.add(0).cast::<*mut u8>();
|
||||||
|
let l1 = *arg0.add(4).cast::<usize>();
|
||||||
|
_rt::cabi_dealloc(l0, l1, 1);
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub unsafe fn _export_execute_cabi<T: Guest>() -> *mut u8 {
|
||||||
|
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
||||||
|
let result0 = T::execute();
|
||||||
|
let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
||||||
|
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||||
|
let ptr2 = vec2.as_ptr().cast::<u8>();
|
||||||
|
let len2 = vec2.len();
|
||||||
|
::core::mem::forget(vec2);
|
||||||
|
*ptr1.add(4).cast::<usize>() = len2;
|
||||||
|
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
|
||||||
|
ptr1
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub unsafe fn __post_return_execute<T: Guest>(arg0: *mut u8) {
|
||||||
|
let l0 = *arg0.add(0).cast::<*mut u8>();
|
||||||
|
let l1 = *arg0.add(4).cast::<usize>();
|
||||||
|
_rt::cabi_dealloc(l0, l1, 1);
|
||||||
|
}
|
||||||
|
pub trait Guest {
|
||||||
|
fn id() -> _rt::String;
|
||||||
|
fn should_run() -> _rt::String;
|
||||||
|
fn execute() -> _rt::String;
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
macro_rules! __export_world_task_cabi {
|
||||||
|
($ty:ident with_types_in $($path_to_types:tt)*) => {
|
||||||
|
const _ : () = { #[export_name = "id"] unsafe extern "C" fn export_id() -> * mut
|
||||||
|
u8 { $($path_to_types)*:: _export_id_cabi::<$ty > () } #[export_name =
|
||||||
|
"cabi_post_id"] unsafe extern "C" fn _post_return_id(arg0 : * mut u8,) {
|
||||||
|
$($path_to_types)*:: __post_return_id::<$ty > (arg0) } #[export_name =
|
||||||
|
"should-run"] unsafe extern "C" fn export_should_run() -> * mut u8 {
|
||||||
|
$($path_to_types)*:: _export_should_run_cabi::<$ty > () } #[export_name =
|
||||||
|
"cabi_post_should-run"] unsafe extern "C" fn _post_return_should_run(arg0 : * mut
|
||||||
|
u8,) { $($path_to_types)*:: __post_return_should_run::<$ty > (arg0) }
|
||||||
|
#[export_name = "execute"] unsafe extern "C" fn export_execute() -> * mut u8 {
|
||||||
|
$($path_to_types)*:: _export_execute_cabi::<$ty > () } #[export_name =
|
||||||
|
"cabi_post_execute"] unsafe extern "C" fn _post_return_execute(arg0 : * mut u8,)
|
||||||
|
{ $($path_to_types)*:: __post_return_execute::<$ty > (arg0) } };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub(crate) use __export_world_task_cabi;
|
||||||
|
#[repr(align(4))]
|
||||||
|
struct _RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
||||||
|
static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]);
|
||||||
mod _rt {
|
mod _rt {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub fn run_ctors_once() {
|
pub fn run_ctors_once() {
|
||||||
@ -405,89 +101,6 @@ mod _rt {
|
|||||||
alloc::dealloc(ptr, layout);
|
alloc::dealloc(ptr, layout);
|
||||||
}
|
}
|
||||||
pub use alloc_crate::string::String;
|
pub use alloc_crate::string::String;
|
||||||
use core::fmt;
|
|
||||||
use core::marker;
|
|
||||||
use core::sync::atomic::{AtomicU32, Ordering::Relaxed};
|
|
||||||
/// A type which represents a component model resource, either imported or
|
|
||||||
/// exported into this component.
|
|
||||||
///
|
|
||||||
/// This is a low-level wrapper which handles the lifetime of the resource
|
|
||||||
/// (namely this has a destructor). The `T` provided defines the component model
|
|
||||||
/// intrinsics that this wrapper uses.
|
|
||||||
///
|
|
||||||
/// One of the chief purposes of this type is to provide `Deref` implementations
|
|
||||||
/// to access the underlying data when it is owned.
|
|
||||||
///
|
|
||||||
/// This type is primarily used in generated code for exported and imported
|
|
||||||
/// resources.
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Resource<T: WasmResource> {
|
|
||||||
handle: AtomicU32,
|
|
||||||
_marker: marker::PhantomData<T>,
|
|
||||||
}
|
|
||||||
/// A trait which all wasm resources implement, namely providing the ability to
|
|
||||||
/// drop a resource.
|
|
||||||
///
|
|
||||||
/// This generally is implemented by generated code, not user-facing code.
|
|
||||||
#[allow(clippy::missing_safety_doc)]
|
|
||||||
pub unsafe trait WasmResource {
|
|
||||||
/// Invokes the `[resource-drop]...` intrinsic.
|
|
||||||
unsafe fn drop(handle: u32);
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> Resource<T> {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
debug_assert!(handle != u32::MAX);
|
|
||||||
Self {
|
|
||||||
handle: AtomicU32::new(handle),
|
|
||||||
_marker: marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Takes ownership of the handle owned by `resource`.
|
|
||||||
///
|
|
||||||
/// Note that this ideally would be `into_handle` taking `Resource<T>` by
|
|
||||||
/// ownership. The code generator does not enable that in all situations,
|
|
||||||
/// unfortunately, so this is provided instead.
|
|
||||||
///
|
|
||||||
/// Also note that `take_handle` is in theory only ever called on values
|
|
||||||
/// owned by a generated function. For example a generated function might
|
|
||||||
/// take `Resource<T>` as an argument but then call `take_handle` on a
|
|
||||||
/// reference to that argument. In that sense the dynamic nature of
|
|
||||||
/// `take_handle` should only be exposed internally to generated code, not
|
|
||||||
/// to user code.
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(resource: &Resource<T>) -> u32 {
|
|
||||||
resource.handle.swap(u32::MAX, Relaxed)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(resource: &Resource<T>) -> u32 {
|
|
||||||
resource.handle.load(Relaxed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> fmt::Debug for Resource<T> {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Resource").field("handle", &self.handle).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> Drop for Resource<T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
match self.handle.load(Relaxed) {
|
|
||||||
u32::MAX => {}
|
|
||||||
other => T::drop(other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub use alloc_crate::boxed::Box;
|
|
||||||
pub use alloc_crate::vec::Vec;
|
|
||||||
pub unsafe fn string_lift(bytes: Vec<u8>) -> String {
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
String::from_utf8(bytes).unwrap()
|
|
||||||
} else {
|
|
||||||
String::from_utf8_unchecked(bytes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub use alloc_crate::alloc;
|
pub use alloc_crate::alloc;
|
||||||
extern crate alloc as alloc_crate;
|
extern crate alloc as alloc_crate;
|
||||||
}
|
}
|
||||||
@ -509,36 +122,25 @@ mod _rt {
|
|||||||
/// ```
|
/// ```
|
||||||
#[allow(unused_macros)]
|
#[allow(unused_macros)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! __export_churn_impl {
|
macro_rules! __export_task_impl {
|
||||||
($ty:ident) => {
|
($ty:ident) => {
|
||||||
self::export!($ty with_types_in self);
|
self::export!($ty with_types_in self);
|
||||||
};
|
};
|
||||||
($ty:ident with_types_in $($path_to_types_root:tt)*) => {
|
($ty:ident with_types_in $($path_to_types_root:tt)*) => {
|
||||||
$($path_to_types_root)*::
|
$($path_to_types_root)*:: __export_world_task_cabi!($ty with_types_in
|
||||||
exports::component::churn_tasks::task::__export_component_churn_tasks_task_0_1_0_cabi!($ty
|
$($path_to_types_root)*);
|
||||||
with_types_in $($path_to_types_root)*:: exports::component::churn_tasks::task);
|
|
||||||
$($path_to_types_root)*::
|
|
||||||
exports::component::churn_tasks::process::__export_component_churn_tasks_process_0_1_0_cabi!($ty
|
|
||||||
with_types_in $($path_to_types_root)*::
|
|
||||||
exports::component::churn_tasks::process);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub(crate) use __export_churn_impl as export;
|
pub(crate) use __export_task_impl as export;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
#[link_section = "component-type:wit-bindgen:0.35.0:component:churn-tasks@0.1.0:churn:encoded world"]
|
#[link_section = "component-type:wit-bindgen:0.35.0:component:churn-tasks:task:encoded world"]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 451] = *b"\
|
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 198] = *b"\
|
||||||
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc7\x02\x01A\x02\x01\
|
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07L\x01A\x02\x01A\x04\x01\
|
||||||
A\x04\x01B\x06\x01@\0\0s\x04\0\x02id\x01\0\x01@\0\0\x7f\x04\0\x0ashould-run\x01\x01\
|
@\0\0s\x04\0\x02id\x01\0\x04\0\x0ashould-run\x01\0\x04\0\x07execute\x01\0\x04\0\x1a\
|
||||||
\x01@\0\x01\0\x04\0\x07execute\x01\x02\x04\0\x20component:churn-tasks/task@0.1.0\
|
component:churn-tasks/task\x04\0\x0b\x0a\x01\0\x04task\x03\0\0\0G\x09producers\x01\
|
||||||
\x05\0\x01B\x0a\x04\0\x07process\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x14[construct\
|
\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.35.0";
|
||||||
or]process\x01\x02\x01h\0\x01ps\x01@\x02\x04self\x03\x06inputs\x04\0s\x04\0\x1b[\
|
|
||||||
method]process.run-process\x01\x05\x01@\x02\x04self\x03\x03keys\0s\x04\0\x1c[met\
|
|
||||||
hod]process.get-variable\x01\x06\x04\0#component:churn-tasks/process@0.1.0\x05\x01\
|
|
||||||
\x04\0!component:churn-tasks/churn@0.1.0\x04\0\x0b\x0b\x01\0\x05churn\x03\0\0\0G\
|
|
||||||
\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen\
|
|
||||||
-rust\x060.35.0";
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn __link_custom_section_describing_imports() {
|
pub fn __link_custom_section_describing_imports() {
|
||||||
|
@ -1,20 +1,5 @@
|
|||||||
package component:churn-tasks@0.1.0;
|
package component:churn-tasks@0.1.0;
|
||||||
|
|
||||||
interface process {
|
|
||||||
resource process {
|
|
||||||
constructor();
|
|
||||||
run-process: func(inputs: list<string>) -> string;
|
|
||||||
get-variable: func(key: string) -> string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface http {
|
|
||||||
resource client {
|
|
||||||
constructor();
|
|
||||||
get: func(url: string) -> list<u8>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface task {
|
interface task {
|
||||||
id: func() -> string;
|
id: func() -> string;
|
||||||
should-run: func() -> bool;
|
should-run: func() -> bool;
|
||||||
@ -22,7 +7,5 @@ interface task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
world churn {
|
world churn {
|
||||||
export process;
|
|
||||||
export http;
|
|
||||||
export task;
|
export task;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
[toolchain]
|
|
||||||
# Specify the Rust version to ensure consistency across environments
|
|
||||||
channel = "stable" # You can use "nightly" if your project requires nightly features
|
|
||||||
|
|
||||||
# Add required components
|
|
||||||
components = ["rust-src", "rust-std", "wasm32-wasi"]
|
|
||||||
|
|
||||||
# Specify the target
|
|
||||||
targets = ["wasm32-wasip1"]
|
|
10
dev-packages/.vscode/settings.json
vendored
10
dev-packages/.vscode/settings.json
vendored
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"rust-analyzer.check.overrideCommand": [
|
|
||||||
"cargo",
|
|
||||||
"component",
|
|
||||||
"check",
|
|
||||||
"--workspace",
|
|
||||||
"--all-targets",
|
|
||||||
"--message-format=json"
|
|
||||||
],
|
|
||||||
}
|
|
470
dev-packages/Cargo.lock
generated
470
dev-packages/Cargo.lock
generated
@ -1,470 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 4
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "adler2"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "anyhow"
|
|
||||||
version = "1.0.95"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "2.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crc32fast"
|
|
||||||
version = "1.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dev-packages"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"dirs",
|
|
||||||
"flate2",
|
|
||||||
"minijinja",
|
|
||||||
"tar",
|
|
||||||
"tempfile",
|
|
||||||
"wit-bindgen-rt",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs"
|
|
||||||
version = "5.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-sys"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"option-ext",
|
|
||||||
"redox_users",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "errno"
|
|
||||||
version = "0.3.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fastrand"
|
|
||||||
version = "2.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "filetime"
|
|
||||||
version = "0.2.25"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"libredox",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "flate2"
|
|
||||||
version = "1.0.35"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
|
|
||||||
dependencies = [
|
|
||||||
"crc32fast",
|
|
||||||
"miniz_oxide",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "getrandom"
|
|
||||||
version = "0.2.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"wasi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.169"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libredox"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"libc",
|
|
||||||
"redox_syscall",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "linux-raw-sys"
|
|
||||||
version = "0.4.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "minijinja"
|
|
||||||
version = "2.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2c37e1b517d1dcd0e51dc36c4567b9d5a29262b3ec8da6cb5d35e27a8fb529b5"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "miniz_oxide"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
|
|
||||||
dependencies = [
|
|
||||||
"adler2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.20.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "option-ext"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.92"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.38"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_syscall"
|
|
||||||
version = "0.5.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_users"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom",
|
|
||||||
"libredox",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustix"
|
|
||||||
version = "0.38.42"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"errno",
|
|
||||||
"libc",
|
|
||||||
"linux-raw-sys",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.217"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
|
|
||||||
dependencies = [
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.217"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "2.0.95"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tar"
|
|
||||||
version = "0.4.43"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6"
|
|
||||||
dependencies = [
|
|
||||||
"filetime",
|
|
||||||
"libc",
|
|
||||||
"xattr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tempfile"
|
|
||||||
version = "3.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"fastrand",
|
|
||||||
"getrandom",
|
|
||||||
"once_cell",
|
|
||||||
"rustix",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror"
|
|
||||||
version = "1.0.69"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror-impl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thiserror-impl"
|
|
||||||
version = "1.0.69"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-sys"
|
|
||||||
version = "0.48.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
|
||||||
dependencies = [
|
|
||||||
"windows-targets 0.48.5",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-sys"
|
|
||||||
version = "0.59.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
|
||||||
dependencies = [
|
|
||||||
"windows-targets 0.52.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-targets"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
|
||||||
dependencies = [
|
|
||||||
"windows_aarch64_gnullvm 0.48.5",
|
|
||||||
"windows_aarch64_msvc 0.48.5",
|
|
||||||
"windows_i686_gnu 0.48.5",
|
|
||||||
"windows_i686_msvc 0.48.5",
|
|
||||||
"windows_x86_64_gnu 0.48.5",
|
|
||||||
"windows_x86_64_gnullvm 0.48.5",
|
|
||||||
"windows_x86_64_msvc 0.48.5",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-targets"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
|
||||||
dependencies = [
|
|
||||||
"windows_aarch64_gnullvm 0.52.6",
|
|
||||||
"windows_aarch64_msvc 0.52.6",
|
|
||||||
"windows_i686_gnu 0.52.6",
|
|
||||||
"windows_i686_gnullvm",
|
|
||||||
"windows_i686_msvc 0.52.6",
|
|
||||||
"windows_x86_64_gnu 0.52.6",
|
|
||||||
"windows_x86_64_gnullvm 0.52.6",
|
|
||||||
"windows_x86_64_msvc 0.52.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_gnullvm"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_msvc"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_aarch64_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnu"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnu"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_msvc"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_i686_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnu"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnu"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnullvm"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_gnullvm"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_msvc"
|
|
||||||
version = "0.48.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows_x86_64_msvc"
|
|
||||||
version = "0.52.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wit-bindgen-rt"
|
|
||||||
version = "0.36.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7947d0131c7c9da3f01dfde0ab8bd4c4cf3c5bd49b6dba0ae640f1fa752572ea"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xattr"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e105d177a3871454f754b33bb0ee637ecaaac997446375fd3e5d43a2ed00c909"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"linux-raw-sys",
|
|
||||||
"rustix",
|
|
||||||
]
|
|
@ -1,31 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "dev-packages"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = { version = "1.0.95" }
|
|
||||||
dirs = "5.0.1"
|
|
||||||
flate2 = "1.0.35"
|
|
||||||
minijinja = "2.5.0"
|
|
||||||
tar = "0.4.43"
|
|
||||||
tempfile = "3.15.0"
|
|
||||||
wit-bindgen-rt = { version = "0.36.0", features = ["bitflags"] }
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
codegen-units = 1
|
|
||||||
opt-level = "s"
|
|
||||||
debug = false
|
|
||||||
strip = true
|
|
||||||
lto = true
|
|
||||||
|
|
||||||
[package.metadata.component]
|
|
||||||
package = "component:dev-packages"
|
|
||||||
|
|
||||||
[package.metadata.component.target.dependencies]
|
|
||||||
"component:churn-tasks" = { path = "../churn-tasks/wit" }
|
|
||||||
|
|
||||||
[package.metadata.component.dependencies]
|
|
@ -1,84 +0,0 @@
|
|||||||
// Sample config for Alloy.
|
|
||||||
//
|
|
||||||
// For a full configuration reference, see https://grafana.com/docs/dev-packages
|
|
||||||
logging {
|
|
||||||
level = "warn"
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.exporter.unix "default" {
|
|
||||||
include_exporter_metrics = true
|
|
||||||
disable_collectors = ["mdadm"]
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.scrape "default" {
|
|
||||||
targets = array.concat(
|
|
||||||
prometheus.exporter.unix.default.targets,
|
|
||||||
[{
|
|
||||||
// Self-collect metrics
|
|
||||||
job = "dev-packages",
|
|
||||||
__address__ = "127.0.0.1:12345",
|
|
||||||
group = "infrastructure",
|
|
||||||
}],
|
|
||||||
)
|
|
||||||
|
|
||||||
forward_to = [
|
|
||||||
// TODO: components to forward metrics to (like prometheus.remote_write or
|
|
||||||
// prometheus.relabel).
|
|
||||||
prometheus.remote_write.default.receiver,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.remote_write "default" {
|
|
||||||
external_labels = {
|
|
||||||
"node" = "{{ node_name }}",
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint {
|
|
||||||
url = "https://prometheus.i.kjuulh.io/api/v1/write"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local.file_match "local_files" {
|
|
||||||
path_targets = [{"__path__" = "/var/log/*.log"}]
|
|
||||||
sync_period = "5s"
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.file "log_scrape" {
|
|
||||||
targets = local.file_match.local_files.targets
|
|
||||||
forward_to = [loki.process.filter_logs.receiver]
|
|
||||||
tail_from_end = true
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.journal "default" {
|
|
||||||
forward_to = [loki.process.filter_logs.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
discovery.docker "linux" {
|
|
||||||
host = "unix:///var/run/docker.sock"
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.source.docker "default" {
|
|
||||||
host = "unix:///var/run/docker.sock"
|
|
||||||
targets = discovery.docker.linux.targets
|
|
||||||
labels = {"app" = "docker"}
|
|
||||||
forward_to = [loki.write.grafana_loki.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.process "filter_logs" {
|
|
||||||
stage.drop {
|
|
||||||
source = ""
|
|
||||||
expression = ".*Connection closed by authenticating user root"
|
|
||||||
drop_counter_reason = "noisy"
|
|
||||||
}
|
|
||||||
forward_to = [loki.write.grafana_loki.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.write "grafana_loki" {
|
|
||||||
external_labels = {
|
|
||||||
"node" = "{{ node_name }}",
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint {
|
|
||||||
url = "https://loki.i.kjuulh.io/loki/api/v1/push"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,496 +0,0 @@
|
|||||||
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
|
|
||||||
// Options used:
|
|
||||||
// * runtime_path: "wit_bindgen_rt"
|
|
||||||
#[rustfmt::skip]
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod component {
|
|
||||||
pub mod churn_tasks {
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod process {
|
|
||||||
#[used]
|
|
||||||
#[doc(hidden)]
|
|
||||||
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
|
|
||||||
use super::super::super::_rt;
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Process {
|
|
||||||
handle: _rt::Resource<Process>,
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
Self {
|
|
||||||
handle: _rt::Resource::from_handle(handle),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(&self) -> u32 {
|
|
||||||
_rt::Resource::take_handle(&self.handle)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(&self) -> u32 {
|
|
||||||
_rt::Resource::handle(&self.handle)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsafe impl _rt::WasmResource for Process {
|
|
||||||
#[inline]
|
|
||||||
unsafe fn drop(_handle: u32) {
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
unreachable!();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
{
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[resource-drop]process"]
|
|
||||||
fn drop(_: u32);
|
|
||||||
}
|
|
||||||
drop(_handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn new() -> Self {
|
|
||||||
unsafe {
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[constructor]process"]
|
|
||||||
fn wit_import() -> i32;
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import() -> i32 {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
let ret = wit_import();
|
|
||||||
Process::from_handle(ret as u32)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn run_process(&self, inputs: &[_rt::String]) -> _rt::String {
|
|
||||||
unsafe {
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
let mut ret_area = RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
let vec1 = inputs;
|
|
||||||
let len1 = vec1.len();
|
|
||||||
let layout1 = _rt::alloc::Layout::from_size_align_unchecked(
|
|
||||||
vec1.len() * 8,
|
|
||||||
4,
|
|
||||||
);
|
|
||||||
let result1 = if layout1.size() != 0 {
|
|
||||||
let ptr = _rt::alloc::alloc(layout1).cast::<u8>();
|
|
||||||
if ptr.is_null() {
|
|
||||||
_rt::alloc::handle_alloc_error(layout1);
|
|
||||||
}
|
|
||||||
ptr
|
|
||||||
} else {
|
|
||||||
::core::ptr::null_mut()
|
|
||||||
};
|
|
||||||
for (i, e) in vec1.into_iter().enumerate() {
|
|
||||||
let base = result1.add(i * 8);
|
|
||||||
{
|
|
||||||
let vec0 = e;
|
|
||||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
|
||||||
let len0 = vec0.len();
|
|
||||||
*base.add(4).cast::<usize>() = len0;
|
|
||||||
*base.add(0).cast::<*mut u8>() = ptr0.cast_mut();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[method]process.run-process"]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8);
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
wit_import((self).handle() as i32, result1, len1, ptr2);
|
|
||||||
let l3 = *ptr2.add(0).cast::<*mut u8>();
|
|
||||||
let l4 = *ptr2.add(4).cast::<usize>();
|
|
||||||
let len5 = l4;
|
|
||||||
let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5);
|
|
||||||
if layout1.size() != 0 {
|
|
||||||
_rt::alloc::dealloc(result1.cast(), layout1);
|
|
||||||
}
|
|
||||||
_rt::string_lift(bytes5)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Process {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn get_variable(&self, key: &str) -> _rt::String {
|
|
||||||
unsafe {
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
let mut ret_area = RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
let vec0 = key;
|
|
||||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
|
||||||
let len0 = vec0.len();
|
|
||||||
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(
|
|
||||||
wasm_import_module = "component:churn-tasks/process@0.1.0"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[method]process.get-variable"]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8);
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
|
|
||||||
let l2 = *ptr1.add(0).cast::<*mut u8>();
|
|
||||||
let l3 = *ptr1.add(4).cast::<usize>();
|
|
||||||
let len4 = l3;
|
|
||||||
let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4);
|
|
||||||
_rt::string_lift(bytes4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod http {
|
|
||||||
#[used]
|
|
||||||
#[doc(hidden)]
|
|
||||||
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
|
|
||||||
use super::super::super::_rt;
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Client {
|
|
||||||
handle: _rt::Resource<Client>,
|
|
||||||
}
|
|
||||||
impl Client {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
Self {
|
|
||||||
handle: _rt::Resource::from_handle(handle),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(&self) -> u32 {
|
|
||||||
_rt::Resource::take_handle(&self.handle)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(&self) -> u32 {
|
|
||||||
_rt::Resource::handle(&self.handle)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsafe impl _rt::WasmResource for Client {
|
|
||||||
#[inline]
|
|
||||||
unsafe fn drop(_handle: u32) {
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
unreachable!();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
{
|
|
||||||
#[link(wasm_import_module = "component:churn-tasks/http@0.1.0")]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[resource-drop]client"]
|
|
||||||
fn drop(_: u32);
|
|
||||||
}
|
|
||||||
drop(_handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Client {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn new() -> Self {
|
|
||||||
unsafe {
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(wasm_import_module = "component:churn-tasks/http@0.1.0")]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[constructor]client"]
|
|
||||||
fn wit_import() -> i32;
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import() -> i32 {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
let ret = wit_import();
|
|
||||||
Client::from_handle(ret as u32)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Client {
|
|
||||||
#[allow(unused_unsafe, clippy::all)]
|
|
||||||
pub fn get(&self, url: &str) -> _rt::Vec<u8> {
|
|
||||||
unsafe {
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
let mut ret_area = RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
let vec0 = url;
|
|
||||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
|
||||||
let len0 = vec0.len();
|
|
||||||
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link(wasm_import_module = "component:churn-tasks/http@0.1.0")]
|
|
||||||
extern "C" {
|
|
||||||
#[link_name = "[method]client.get"]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8);
|
|
||||||
}
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
|
|
||||||
let l2 = *ptr1.add(0).cast::<*mut u8>();
|
|
||||||
let l3 = *ptr1.add(4).cast::<usize>();
|
|
||||||
let len4 = l3;
|
|
||||||
_rt::Vec::from_raw_parts(l2.cast(), len4, len4)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[rustfmt::skip]
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod exports {
|
|
||||||
pub mod component {
|
|
||||||
pub mod churn_tasks {
|
|
||||||
#[allow(dead_code, clippy::all)]
|
|
||||||
pub mod task {
|
|
||||||
#[used]
|
|
||||||
#[doc(hidden)]
|
|
||||||
static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports;
|
|
||||||
use super::super::super::super::_rt;
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_id_cabi<T: Guest>() -> *mut u8 {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
let result0 = T::id();
|
|
||||||
let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
|
||||||
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
|
||||||
let ptr2 = vec2.as_ptr().cast::<u8>();
|
|
||||||
let len2 = vec2.len();
|
|
||||||
::core::mem::forget(vec2);
|
|
||||||
*ptr1.add(4).cast::<usize>() = len2;
|
|
||||||
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
|
|
||||||
ptr1
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn __post_return_id<T: Guest>(arg0: *mut u8) {
|
|
||||||
let l0 = *arg0.add(0).cast::<*mut u8>();
|
|
||||||
let l1 = *arg0.add(4).cast::<usize>();
|
|
||||||
_rt::cabi_dealloc(l0, l1, 1);
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_should_run_cabi<T: Guest>() -> i32 {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
let result0 = T::should_run();
|
|
||||||
match result0 {
|
|
||||||
true => 1,
|
|
||||||
false => 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub unsafe fn _export_execute_cabi<T: Guest>() {
|
|
||||||
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
|
|
||||||
T::execute();
|
|
||||||
}
|
|
||||||
pub trait Guest {
|
|
||||||
fn id() -> _rt::String;
|
|
||||||
fn should_run() -> bool;
|
|
||||||
fn execute();
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
macro_rules! __export_component_churn_tasks_task_0_1_0_cabi {
|
|
||||||
($ty:ident with_types_in $($path_to_types:tt)*) => {
|
|
||||||
const _ : () = { #[export_name =
|
|
||||||
"component:churn-tasks/task@0.1.0#id"] unsafe extern "C" fn
|
|
||||||
export_id() -> * mut u8 { $($path_to_types)*::
|
|
||||||
_export_id_cabi::<$ty > () } #[export_name =
|
|
||||||
"cabi_post_component:churn-tasks/task@0.1.0#id"] unsafe extern
|
|
||||||
"C" fn _post_return_id(arg0 : * mut u8,) { $($path_to_types)*::
|
|
||||||
__post_return_id::<$ty > (arg0) } #[export_name =
|
|
||||||
"component:churn-tasks/task@0.1.0#should-run"] unsafe extern "C"
|
|
||||||
fn export_should_run() -> i32 { $($path_to_types)*::
|
|
||||||
_export_should_run_cabi::<$ty > () } #[export_name =
|
|
||||||
"component:churn-tasks/task@0.1.0#execute"] unsafe extern "C" fn
|
|
||||||
export_execute() { $($path_to_types)*::
|
|
||||||
_export_execute_cabi::<$ty > () } };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub(crate) use __export_component_churn_tasks_task_0_1_0_cabi;
|
|
||||||
#[repr(align(4))]
|
|
||||||
struct _RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
|
||||||
static mut _RET_AREA: _RetArea = _RetArea(
|
|
||||||
[::core::mem::MaybeUninit::uninit(); 8],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[rustfmt::skip]
|
|
||||||
mod _rt {
|
|
||||||
use core::fmt;
|
|
||||||
use core::marker;
|
|
||||||
use core::sync::atomic::{AtomicU32, Ordering::Relaxed};
|
|
||||||
/// A type which represents a component model resource, either imported or
|
|
||||||
/// exported into this component.
|
|
||||||
///
|
|
||||||
/// This is a low-level wrapper which handles the lifetime of the resource
|
|
||||||
/// (namely this has a destructor). The `T` provided defines the component model
|
|
||||||
/// intrinsics that this wrapper uses.
|
|
||||||
///
|
|
||||||
/// One of the chief purposes of this type is to provide `Deref` implementations
|
|
||||||
/// to access the underlying data when it is owned.
|
|
||||||
///
|
|
||||||
/// This type is primarily used in generated code for exported and imported
|
|
||||||
/// resources.
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct Resource<T: WasmResource> {
|
|
||||||
handle: AtomicU32,
|
|
||||||
_marker: marker::PhantomData<T>,
|
|
||||||
}
|
|
||||||
/// A trait which all wasm resources implement, namely providing the ability to
|
|
||||||
/// drop a resource.
|
|
||||||
///
|
|
||||||
/// This generally is implemented by generated code, not user-facing code.
|
|
||||||
#[allow(clippy::missing_safety_doc)]
|
|
||||||
pub unsafe trait WasmResource {
|
|
||||||
/// Invokes the `[resource-drop]...` intrinsic.
|
|
||||||
unsafe fn drop(handle: u32);
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> Resource<T> {
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub unsafe fn from_handle(handle: u32) -> Self {
|
|
||||||
debug_assert!(handle != u32::MAX);
|
|
||||||
Self {
|
|
||||||
handle: AtomicU32::new(handle),
|
|
||||||
_marker: marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Takes ownership of the handle owned by `resource`.
|
|
||||||
///
|
|
||||||
/// Note that this ideally would be `into_handle` taking `Resource<T>` by
|
|
||||||
/// ownership. The code generator does not enable that in all situations,
|
|
||||||
/// unfortunately, so this is provided instead.
|
|
||||||
///
|
|
||||||
/// Also note that `take_handle` is in theory only ever called on values
|
|
||||||
/// owned by a generated function. For example a generated function might
|
|
||||||
/// take `Resource<T>` as an argument but then call `take_handle` on a
|
|
||||||
/// reference to that argument. In that sense the dynamic nature of
|
|
||||||
/// `take_handle` should only be exposed internally to generated code, not
|
|
||||||
/// to user code.
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn take_handle(resource: &Resource<T>) -> u32 {
|
|
||||||
resource.handle.swap(u32::MAX, Relaxed)
|
|
||||||
}
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn handle(resource: &Resource<T>) -> u32 {
|
|
||||||
resource.handle.load(Relaxed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> fmt::Debug for Resource<T> {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Resource").field("handle", &self.handle).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: WasmResource> Drop for Resource<T> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
match self.handle.load(Relaxed) {
|
|
||||||
u32::MAX => {}
|
|
||||||
other => T::drop(other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub use alloc_crate::string::String;
|
|
||||||
pub use alloc_crate::alloc;
|
|
||||||
pub use alloc_crate::vec::Vec;
|
|
||||||
pub unsafe fn string_lift(bytes: Vec<u8>) -> String {
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
String::from_utf8(bytes).unwrap()
|
|
||||||
} else {
|
|
||||||
String::from_utf8_unchecked(bytes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
pub fn run_ctors_once() {
|
|
||||||
wit_bindgen_rt::run_ctors_once();
|
|
||||||
}
|
|
||||||
pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) {
|
|
||||||
if size == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let layout = alloc::Layout::from_size_align_unchecked(size, align);
|
|
||||||
alloc::dealloc(ptr, layout);
|
|
||||||
}
|
|
||||||
extern crate alloc as alloc_crate;
|
|
||||||
}
|
|
||||||
/// Generates `#[no_mangle]` functions to export the specified type as the
|
|
||||||
/// root implementation of all generated traits.
|
|
||||||
///
|
|
||||||
/// For more information see the documentation of `wit_bindgen::generate!`.
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// # macro_rules! export{ ($($t:tt)*) => (); }
|
|
||||||
/// # trait Guest {}
|
|
||||||
/// struct MyType;
|
|
||||||
///
|
|
||||||
/// impl Guest for MyType {
|
|
||||||
/// // ...
|
|
||||||
/// }
|
|
||||||
///
|
|
||||||
/// export!(MyType);
|
|
||||||
/// ```
|
|
||||||
#[allow(unused_macros)]
|
|
||||||
#[doc(hidden)]
|
|
||||||
macro_rules! __export_dev_packages_impl {
|
|
||||||
($ty:ident) => {
|
|
||||||
self::export!($ty with_types_in self);
|
|
||||||
};
|
|
||||||
($ty:ident with_types_in $($path_to_types_root:tt)*) => {
|
|
||||||
$($path_to_types_root)*::
|
|
||||||
exports::component::churn_tasks::task::__export_component_churn_tasks_task_0_1_0_cabi!($ty
|
|
||||||
with_types_in $($path_to_types_root)*:: exports::component::churn_tasks::task);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#[doc(inline)]
|
|
||||||
pub(crate) use __export_dev_packages_impl as export;
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
#[link_section = "component-type:wit-bindgen:0.36.0:component:dev-packages:dev-packages:encoded world"]
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 588] = *b"\
|
|
||||||
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc9\x03\x01A\x02\x01\
|
|
||||||
A\x06\x01B\x0a\x04\0\x07process\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x14[constructo\
|
|
||||||
r]process\x01\x02\x01h\0\x01ps\x01@\x02\x04self\x03\x06inputs\x04\0s\x04\0\x1b[m\
|
|
||||||
ethod]process.run-process\x01\x05\x01@\x02\x04self\x03\x03keys\0s\x04\0\x1c[meth\
|
|
||||||
od]process.get-variable\x01\x06\x03\0#component:churn-tasks/process@0.1.0\x05\0\x01\
|
|
||||||
B\x08\x04\0\x06client\x03\x01\x01i\0\x01@\0\0\x01\x04\0\x13[constructor]client\x01\
|
|
||||||
\x02\x01h\0\x01p}\x01@\x02\x04self\x03\x03urls\0\x04\x04\0\x12[method]client.get\
|
|
||||||
\x01\x05\x03\0\x20component:churn-tasks/http@0.1.0\x05\x01\x01B\x06\x01@\0\0s\x04\
|
|
||||||
\0\x02id\x01\0\x01@\0\0\x7f\x04\0\x0ashould-run\x01\x01\x01@\0\x01\0\x04\0\x07ex\
|
|
||||||
ecute\x01\x02\x04\0\x20component:churn-tasks/task@0.1.0\x05\x02\x04\0#component:\
|
|
||||||
dev-packages/dev-packages\x04\0\x0b\x12\x01\0\x0cdev-packages\x03\0\0\0G\x09prod\
|
|
||||||
ucers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x06\
|
|
||||||
0.36.0";
|
|
||||||
#[inline(never)]
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn __link_custom_section_describing_imports() {
|
|
||||||
wit_bindgen_rt::maybe_link_cabi_realloc();
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
use std::{
|
|
||||||
fs::{self},
|
|
||||||
io::{Cursor, Write},
|
|
||||||
path::PathBuf,
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
use bindings::{
|
|
||||||
component::churn_tasks::{http, process::Process},
|
|
||||||
exports::component::churn_tasks::task::Guest,
|
|
||||||
};
|
|
||||||
use flate2::bufread::GzDecoder;
|
|
||||||
use tar::Archive;
|
|
||||||
|
|
||||||
#[allow(warnings)]
|
|
||||||
mod bindings;
|
|
||||||
|
|
||||||
struct Component;
|
|
||||||
|
|
||||||
impl Guest for Component {
|
|
||||||
fn id() -> String {
|
|
||||||
"clank/dev-packages".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn should_run() -> bool {
|
|
||||||
if !std::path::PathBuf::from("/usr/local/bin/starship").exists() {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
if !std::path::PathBuf::from("/root/.bashrc").exists() {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Ok(content) = std::fs::read_to_string("/root/.bashrc") {
|
|
||||||
if !content.contains("starship") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !std::path::PathBuf::from("/usr/local/bin/zellij").exists() {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
false
|
|
||||||
}
|
|
||||||
fn execute() {
|
|
||||||
println!("running dev-packages installation");
|
|
||||||
|
|
||||||
Process::new().run_process(
|
|
||||||
&[
|
|
||||||
"bash",
|
|
||||||
"-c",
|
|
||||||
"curl -sS https://starship.rs/install.sh | sh -s -- --force",
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| i.to_string())
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
println!("downloaded starship");
|
|
||||||
if !std::path::PathBuf::from("/root/.bashrc").exists() {
|
|
||||||
println!("appending to bashrc");
|
|
||||||
if let Ok(content) = std::fs::read_to_string("/root/.bashrc") {
|
|
||||||
if !content.contains("starship") {
|
|
||||||
let mut bashrc = std::fs::File::options()
|
|
||||||
.write(true)
|
|
||||||
.open("/root/.bashrc")
|
|
||||||
.expect("failed to open bash");
|
|
||||||
|
|
||||||
bashrc
|
|
||||||
.write_all(r#"eval "$(starship init bash)"#.as_bytes())
|
|
||||||
.expect("failed to write to bashrc file");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let mut bashrc = std::fs::File::create("/root/.bashrc").expect("failed to open bash");
|
|
||||||
bashrc
|
|
||||||
.write_all(r#"eval "$(starship init bash)""#.as_bytes())
|
|
||||||
.expect("failed to write to bashrc file");
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("installing zellij");
|
|
||||||
if !PathBuf::from("/usr/local/bin/zellij").exists() {
|
|
||||||
if let Err(err) = install_zellij() {
|
|
||||||
panic!("failed to install zellij: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn install_zellij() -> anyhow::Result<()> {
|
|
||||||
let url = "https://github.com/zellij-org/zellij/releases/download/v0.41.2/zellij-x86_64-unknown-linux-musl.tar.gz";
|
|
||||||
|
|
||||||
// TODO: Until this is merged: https://github.com/bytecodealliance/wasmtime/pull/9582 we just spawn a runtime
|
|
||||||
|
|
||||||
println!("getting zellij");
|
|
||||||
let content = http::Client::new().get(url);
|
|
||||||
|
|
||||||
println!("creating tempdir");
|
|
||||||
let temp_dir = PathBuf::from("/tmp/zellij_install/");
|
|
||||||
if let Err(e) = std::fs::remove_dir_all(&temp_dir) {
|
|
||||||
println!("failed to remove tmp dir: {e}");
|
|
||||||
}
|
|
||||||
std::fs::create_dir_all(&temp_dir).context("creating tmp dir")?;
|
|
||||||
|
|
||||||
let mut zellij_archive = std::fs::File::create(temp_dir.join("zellij.tar.gz"))?;
|
|
||||||
zellij_archive.write_all(&content)?;
|
|
||||||
zellij_archive.flush()?;
|
|
||||||
|
|
||||||
Process::new().run_process(
|
|
||||||
&[
|
|
||||||
"tar",
|
|
||||||
"-xvf",
|
|
||||||
&temp_dir.join("zellij.tar.gz").display().to_string(),
|
|
||||||
"-C",
|
|
||||||
&temp_dir.display().to_string(),
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| i.to_string())
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Move binary to /usr/local/bin
|
|
||||||
println!("move binary");
|
|
||||||
let binary_path = temp_dir.join("zellij");
|
|
||||||
fs::File::create("/usr/local/bin/zellij")?;
|
|
||||||
fs::copy(&binary_path, "/usr/local/bin/zellij")?;
|
|
||||||
|
|
||||||
Process::new().run_process(
|
|
||||||
&["chmod", "+x", "/usr/local/bin/zellij"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|i| i.to_string())
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set executable permissions using std::fs::Permissions
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
//use std::os::unix::fs::PermissionsExt;
|
|
||||||
//let mut perms = fs::metadata("/usr/local/bin/zellij")?.permissions();
|
|
||||||
//perms.set_mode(0o755);
|
|
||||||
//fs::set_permissions("/usr/local/bin/zellij", perms)
|
|
||||||
// .context("Failed to set executable permissions")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
bindings::export!(Component with_types_in bindings);
|
|
@ -1,8 +0,0 @@
|
|||||||
package component:dev-packages;
|
|
||||||
|
|
||||||
/// An example world for the component to target.
|
|
||||||
world dev-packages {
|
|
||||||
import component:churn-tasks/process@0.1.0;
|
|
||||||
import component:churn-tasks/http@0.1.0;
|
|
||||||
export component:churn-tasks/task@0.1.0;
|
|
||||||
}
|
|
3
renovate.json
Normal file
3
renovate.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
31
upload.sh
31
upload.sh
@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "signing in to onepass"
|
|
||||||
op signin
|
|
||||||
|
|
||||||
export AWS_ACCESS_KEY_ID=$(op read op://personal/minio.front.kjuulh.io/username)
|
|
||||||
export AWS_SECRET_ACCESS_KEY=$(op read op://personal/minio.front.kjuulh.io/password)
|
|
||||||
export AWS_REGION=eu-west-1
|
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
|
||||||
print "Usage: $0 [arguments...]"
|
|
||||||
print "Please provide at least one argument"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for arg in $@; do
|
|
||||||
echo "building and uploading: $arg"
|
|
||||||
|
|
||||||
lowercase_arg=${arg//-/_}
|
|
||||||
|
|
||||||
echo "processing: $arg"
|
|
||||||
|
|
||||||
echo "building rust project"
|
|
||||||
(cd $arg && cargo component build --release)
|
|
||||||
|
|
||||||
echo "upload"
|
|
||||||
aws s3 cp $arg/target/wasm32-wasip1/release/$lowercase_arg.wasm s3://churn-registry/$lowercase_arg/0.1.0/$lowercase_arg.wasm --endpoint-url https://api-minio.front.kjuulh.io
|
|
||||||
done
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user