Skip to content

Latest commit

 

History

History
172 lines (124 loc) · 4.08 KB

README.md

File metadata and controls

172 lines (124 loc) · 4.08 KB

Community Extension Compatible with: Camunda Platform 8

FEEL-Scala Playground API

This repository contains the API for the FEEL-Scala Playground: https://camunda.github.io/feel-scala/docs/playground/

curl --header "Content-Type: application/json" \
-X POST \
-d '{"expression":"x + y", "context":{"x": 2, "y": 3}, "metadata": {"source": "test"}}' \
API_URL/api/v1/feel/evaluate  

Usage

The API has the following endpoints:

Evaluate expression

  • Type: POST
  • Path: /api/v1/feel/evaluate
  • Properties:
    • expression - (String) required
    • context - (JSON object) required
    • metadata - (JSON object) optional - used for tracking purposes

Request:

{
  "expression": "x * y",
  "context": {
    "x": 2,
    "y": 3
  },
  "metadata": {
    "source": "test"
  }
}

Response:

{
  "result": 6,
  "error": null,
  "warnings": []
}

Evaluate unary-tests

  • Type: POST
  • Path: /api/v1/feel-unary-tests/evaluate
  • Properties:
    • expression - (String) required
    • inputValue - (JSON value) required
    • context - (JSON object) required
    • metadata - (JSON object) optional - used for tracking purposes

Request:

{
  "expression": "< x",
  "inputValue": 3,
  "context": {
    "x": 5
  },
  "metadata": {
    "source": "test"
  }
}

Response:

{
  "result": true,
  "error": null,
  "warnings": []
}

Version

  • Type: GET
  • Path: /api/v1/version

Response:

{
  "feelEngineVersion": "1.16.0"
}

Install

The following notes describe how to deploy to Google Cloud Kubernetes Cluster

First, do some setup (this should only be needed as a "one time" setup)

cd k8s

kubectl create namespace feel

kubectl apply -f service.yaml -n feel

To deploy the secrets, edit secret.yaml and set mixpanel_project_token to your Mixpanel project token. Then run the following:

kubectl apply -f secret.yaml -n feel

To deploy the rest api, edit deployment.yaml and set spec.template.spec.containers[0].img to point to the latest docker image. Then run the following:

kubectl apply -f deployment.yaml -n feel

At this point, you should be able to port forward to the service. Run this:

kubectl port-forward svc/feel-scala-playground-service 8080:8080 -n feel

To setup load balancing, we need a static ip address. Here's the gcloud command to create an ip address.

First, check if the ip address already exists:

gcloud compute addresses describe feel-scala-playground-ip --global
# 34.111.164.116

If needed, create a new static ip like so:

gcloud compute addresses create feel-scala-playground-ip --global

To setup ssl, first edit managedCert.yaml and update the domain names you'd like to use, then create a managed certificate object by running this:

kubectl apply -f managedCert.yaml -n feel

Finally, create the ingress. The ingress is configured to use the static ip and managed certificate.

kubectl apply -f ingress.yaml -n feel

Note: currently the app responds with a 404 at the root url /. Google Load balancer will think the app is not responding. So, after the ingress starts, go to the google console, search for "Load Balancers", and click on the load balancer for this feel-tutorial. Click on the Health Check and edit the path to be /actuator/health.

Check on status of ingress and ssl certificate:

kubectl describe ingress feel-scala-playground-ingress -n feel
kubectl describe managedcertificate feel-service-managed-cert -n feel

Clean up

To delete the pod (before redeploy):

kubectl delete pod feel-scala-playground-pod -n feel

To completely clear out all kubernetes objects related to feel:

kubectl delete namespace feel