Giter Site home page Giter Site logo

tarilabs / jsr223-powerfx Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 27 KB

A JSR-223 implementation for evaluating Power Fx formulas (expression) by making use of a server implemented on F# and .NET platform

License: Apache License 2.0

F# 42.07% Dockerfile 3.79% Java 54.14%
fsharp java powerfx jsr223

jsr223-powerfx's Introduction

This is an Open Source community project.

JSR-223 Power Fx

A JSR-223 implementation for evaluating Power Fx formulas (expression) by making use of a server implemented on F# and .NET platform.

sequenceDiagram
    participant J as Your Java App
    participant I as <<interface>><br/>JDK JSR-223
    participant E as This JSR-223<br/>ScriptEngine
    participant S as This .NET server<br/>(Docker image)
    link I: Guide @ https://docs.oracle.com/en/java/javase/14/scripting/java-scripting-api.html
    link I: JavaDoc @ https://docs.oracle.com/en/java/javase/17/docs/api/java.scripting/javax/script/package-summary.html
    J->>I: 
    I->>E: 
    E->>S: POST /eval<br/>(JSON)
    S-->>E: Power Fx eval result<br/>(JSON)
    E->>I: 
    I->>J: 

How to use

Run docker image with:

docker run -p 80:5000 jsr223-powerfx-server

Include this dependency in your Java project.

Using Maven:

<dependency>
    <groupId>com.matteomortari</groupId>
    <artifactId>jsr223-powerfx</artifactId>
    <version>0.1</version>
    <scope>runtime</scope>
</dependency>

Example usage:

ScriptEngineManager MANAGER = new ScriptEngineManager();
ScriptEngine engine = MANAGER.getEngineByName("powerfx");
Bindings bindings = engine.createBindings();
bindings.put("a", 1);
bindings.put("b", 2);
Object result = engine.eval("a+b", bindings); // result = 3

FAQ

Q: Why F# ?
A: No particular reason, I've always been looking for an excuse to experiment using it; luck is being prepared when the opportunity comes :)

Q: Is it "production-ready"?
A: This is a chabuduo MVP working-PoC

Q: I have a feedback/question?
A: Feel free to contact me!

References

Helpful references I've used while building this experiment

jsr223-powerfx's People

Contributors

tarilabs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.