Coder Social home page Coder Social logo

balena-temen's Issues

Context aware evaluation

Specification allows to evaluate expression containing relative paths. Currently there's no support for this.

Remove now() fn workaround

src/context.rs:

#[cfg(not(target_arch = "wasm32"))]
fn utc_now() -> DateTime<Utc> {
    Utc::now()
}

// chrono crate doesn't support wasm32 arch yet, workaround
#[cfg(target_arch = "wasm32")]
fn utc_now() -> DateTime<Utc> {
    let now = js_sys::Date::new_0();
    let millisecs_since_unix_epoch: u64 = now.get_time() as u64;
    let secs = millisecs_since_unix_epoch / 1000;
    let nanos = 1_000_000 * (millisecs_since_unix_epoch - 1000 * secs);
    let naive = NaiveDateTime::from_timestamp(secs as i64, nanos as u32);
    DateTime::from_utc(naive, Utc)
}

Add fuzzer

Current implementation of the fuzzer is kind of useless. There's no way how to get the crashing input, etc. Useless fuzzer was removed.

We have to come up with some fuzzing strategy like:

  • when to run it,
  • where to run it,
  • for how long,
  • how often,
  • etc.

Remove uuidv4() fn workaround

Once new uuid crate is released and #352 fixed, we can remove our uuid & rand workaround.

  • Remove rand dependency
  • Enable v4 feature (uuid crate)
  • Enable wasm-bindgen feature (uuid crate, wasm32 arch)
  • Replace custom uuidv4() fn body with Uuid::new_v4()

Optimise

Once all features will be in place, fully working, optimise the whole crate, because it:

  • contains unnecessary allocations,
  • does not leverage references, lifetimes, cow,
  • etc.

uuidv4() generator doesn't work

Reproducible Node case:

const bt = require('balena-temen');

console.log(
    bt.evaluate({
        "uuid": {
            "$$eval": "uuidv4()"
        }
    })
);

The error message:

panicked at 'could not initialize thread_rng: No entropy sources available (permanently unavailable)', /Users/robertvojta/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.5.5/src/rngs/thread.rs:84:17
wasm://wasm/004488ea:574

RuntimeError: unreachable
    at __rust_start_panic (wasm-function[573]:1)
    at rust_panic (wasm-function[570]:30)
    at std::panicking::rust_panic_with_hook::h6790e8431e342a60 (wasm-function[565]:444)
    at std::panicking::continue_panic_fmt::h3b66c044a41127bf (wasm-function[564]:120)
    at std::panicking::begin_panic_fmt::h522439ba8a0fbac4 (wasm-function[561]:95)
    at rand::rngs::thread::THREAD_RNG_KEY::__init::_$u7b$$u7b$closure$u7d$$u7d$::hdd28f475617c5274 (wasm-function[357]:91)
    at rand::rngs::thread::thread_rng::hef4638d394e756b1 (wasm-function[356]:1024)
    at uuid::v4::_$LT$impl$u20$uuid..Uuid$GT$::new_v4::h9644a31e3bf57f8d (wasm-function[345]:14)
    at balena_temen::builtin::function::uuidv4::uuidv4::h3ce10819a87f445f (wasm-function[200]:18)
    at balena_temen::engine::Engine::eval_function::he1b50994ba503a6b (wasm-function[233]:943)

Same error in both nodeJS & browser.

Add Katapult generators

@mikesimos Flowdock thread message:

Just an update, here is a list of DSL generators (+validators ideally) we use/ll be using in balena configuration:

  • DH-Param (could be the output of require('dhparam')(bits))
  • RSA Keypair
  • x.509 CACert
  • x.509 Cert
  • EC PrivateKey
  • EC keyid
  • EC Cert

More info about EC *.

Add helper function to evaluate the whole JSON

Imagine you have a JSON like this one ...

{
  "uuid": {
    "$$eval": "uuidv4()"
  },
  "id: {
    "$$eval": "ssid | slugify"
  },
  "ssid": "Zrzka 5G"
}

... and you'd like to evaluate everything at once to get something like ...

{
  "uuid": "2a0b9f5a-04e8-483e-bb3c-c889822afc67",
  "id": "zrzka-5g",
  "ssid": "Zrzka 5G"
}

... we should provide a helper function for this, so, one can do it with one call. It's possible today, but one has to find all $$eval and evaluate them one by one.

@cyplo WDYT?

Replace error-chain

We should replace error-chain with custom error type allowing us to provide more precise error messages like which part of the expression is wrong, etc.

Add relative -> absolute identifier conversion

We have to provide a public API for users with the ability to normalize identifier. It means conversion from relative identifier to an absolute one (remove this and super keywords).

Stabilise API

Till 0.1, even patch version can break public API. Once all features will be in place, working, API should be stabilised, 0.1 released and then we should follow semantic versioning.

Add benchmarks

We need to add benchmarks, but we have to check with CI guys how stable in terms of performance is our CI, etc. Or we should run them locally on our machines with predictable performance.

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.