This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fdk=require('@fnproject/fdk'); | |
| const wasm=require('@crush-157/rust-fn'); | |
| fdk.handle(function(input){ | |
| return wasm.hello_json(input); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fdk=require('@fnproject/fdk'); | |
| const wasm=require('@crush-157/rust-fn'); | |
| fdk.handle(function(input){ | |
| let name = 'World'; | |
| if (input.name) { | |
| name = input.name; | |
| } | |
| return {'message': wasm.hello_string(name) } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "hellofn", | |
| "version": "1.0.0", | |
| "description": "example function", | |
| "main": "func.js", | |
| "author": "", | |
| "license": "Apache-2.0", | |
| "dependencies": { | |
| "@fnproject/fdk": ">=0.0.18", | |
| "@crush-157/rust-fn": ">=0.1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [package] | |
| name = "rust-fn" | |
| version = "0.1.0" | |
| authors = ["Ewan Slater <[email protected]>"] | |
| edition = "2018" | |
| [lib] | |
| crate-type = ["cdylib", "rlib"] | |
| [features] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mod utils; | |
| use wasm_bindgen::prelude::*; | |
| use serde::*; | |
| // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global | |
| // allocator. | |
| #[cfg(feature = "wee_alloc")] | |
| #[global_allocator] | |
| static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "http/server" | |
| require "json" | |
| module FnHelper | |
| def self.socket_path | |
| ENV.["FN_LISTENER"].try(&.[5..]) || "/tmp/iofs/lsnr.sock" | |
| end | |
| def self.handle(&block : JSON::Any -> String) | |
| server = HTTP::Server.new do |context| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "socket" | |
| require "file_utils" | |
| require "http/server" | |
| require "json" | |
| class FnHelper | |
| getter(url : String) { ENV.fetch "FN_LISTENER", "unix:/tmp/iofs/lsnr.sock" } | |
| getter(socket_path : String) { url[5..] } | |
| getter(private_socket_path : String) { socket_path + ".private" } | |
| getter? linked : Bool = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "socket" | |
| require "file_utils" | |
| require "http/server" | |
| require "json" | |
| class FnHelper | |
| getter(url : String) { ENV.fetch "FN_LISTENER", "unix:/tmp/iofs/lsnr.sock" } | |
| getter(socket_path : String) { url[5..] } | |
| getter(private_socket_path : String) { socket_path + ".private" } | |
| getter? linked : Bool = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "socket" | |
| require "file_utils" | |
| class FnHelper | |
| getter(url : String) { ENV.fetch "FN_LISTENER", "unix:/tmp/iofs/lsnr.sock" } | |
| getter(socket_path : String) { url[5..] } | |
| getter(private_socket_path : String) { socket_path + ".private" } | |
| getter? linked : Bool = false | |
| getter(private_socket : UNIXServer) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| STDERR.puts "HELP, I AM TRAPPED IN A CRYSTAL MAZE!" |
NewerOlder