Code Monkey home page Code Monkey logo

apeiro's Introduction

🚀 Quickstart

🏃‍♂️ Run the daemon

$ cargo run --bin apeirod 

🧩 ApeiroJS

  • 📝 log()
  • 📬 $recv(matcher)
  • 📨 $send(pid, msg)
  • 🔢 $pid()
  • 🕒 $send("clock", { sender: $pid(), wait: ms });
  • 🐣 let new_pid = $spawn(fn)

Every file declaring a process must export a default value, that can be:

  • 🧮 a function,
  • 🌐 an async function,
  • 🔄 a generator.

🔢 Create a process that adds two numbers and run through it

$ echo 'export default function main() {
	let a = $recv({$type:["number"]});

	let b = $recv({$type:["number"]});

	if (b > 50) {
		let c = $recv({$type:["number"]});
		return a + b + c;
	}
	
	return a + b;
}' > func.js

$ cargo run --bin ap -- new --src ./func.js
Ok(ProcNewOutput { id: "yVPxlQTnVcclpV0c3tSWq", state: StepResult { status: SUSPEND, val: None, suspension: Some(Object {"$type": Array [String("number")]}) } })

$ cargo run --bin ap -- send yVPxlQTnVcclpV0c3tSWq '{"a":1}'

status: SUSPEND
val: 
suspension: {
  "$type": [
    "number"
  ]
}

$ cargo run --bin ap -- send yVPxlQTnVcclpV0c3tSWq '{"b":51}'

status: SUSPEND
val: 
suspension: {
  "c": {
    "$type": [
      "number"
    ]
  }
}

$ cargo run --bin ap -- send yVPxlQTnVcclpV0c3tSWq '{"c":100}'

status: DONE
val: 152

apeiro's People

Contributors

ianatha avatar dependabot[bot] avatar

Stargazers

Adison Keith avatar  avatar Adan Alvarado avatar Ian Young avatar Matt Corley avatar  avatar Greg Terrono avatar Nec joy avatar Janet Davis avatar LZ91X  avatar Omer Katz avatar  avatar Hanna Liebl avatar developer in development avatar Michael Westermann avatar Alex Lane avatar Ammar Qammaz avatar Dim Kalt avatar Christos Topaloudis avatar Amir Haghighat avatar Michael Andrzejewski avatar John Economou avatar John Papadakis avatar Lipis avatar Adam Simmons avatar  avatar  avatar  avatar

Watchers

 avatar

apeiro's Issues

Bad $recv spec crashes daemon

$recv({"$type":"number"})

causes a crash when $recv is evaluated (i.e. when a msg is being received):

2023-12-23T14:11:01.544168Z  INFO inner_proc_send{proc_id_or_name="Yc4LwY82rHLxFRqCElytu" step_id="8Bv0mS9XuyMCMMSIP2Zk4" body=ProcSendRequest { msg: Object {"x": Number(3)} }}: apeiro_engine::engine: before kickoff
2023-12-23T14:11:01.544482Z  INFO inner_proc_send{proc_id_or_name="Yc4LwY82rHLxFRqCElytu" step_id="8Bv0mS9XuyMCMMSIP2Zk4" body=ProcSendRequest { msg: Object {"x": Number(3)} }}:mbox_callback{scope=HandleScope { _data: 0x6000019fd500, _phantom: PhantomData<&mut v8::data::Context> } args=FunctionCallbackArguments(FunctionCallbackInfo { implicit_args: 0x16e3dc220, values: 0x16e3dc258, length: 1 }) retval=ReturnValue(0x16e3dc238, PhantomData<&()>)}: apeiro_engine::engine: new
thread 'tokio-runtime-worker' panicked at /Users/iwa/.asdf/installs/rust/1.74.1/registry/src/index.crates.io-6f17d22bba15001f/serde_json_matcher-0.1.5/src/lib.rs:219:72:
called `Result::unwrap()` on an `Err` value: Error("invalid type: string \"number\", expected a sequence", line: 0, column: 0)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
zsh: abort      ./target/debug/apeirod

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.