From the Oracle website -
Oracle Cloud Functions is a serverless platform that lets developers create, run, and scale applications without managing any infrastructure. Functions integrate with Oracle Cloud Infrastructure, platform services and SaaS applications. Because Functions is based on the open source Fn Project, developers can create applications that can be easily ported to other cloud and on-premises environments. Code based on Functions typically runs for short durations, and customers pay only for the resources they use.
These Functions can be written in a variety of languages - Java, Python, Node etc. You write and deploy the code, Oracle takes care of provisioning, scaling etc.
Think of blocks of code that generally do one thing, e.g. applying a discount to an order. These are stored as Docker images in a docker registry. They can be executed via CLI or HTTP request. We will be using the latter in our example.
So how do Functions enhance the OIC experience?
Here's one use case - Say you are porting SOA Composites to OIC and you make use of Java Embedding in your BPEL process. Where shall I put that code in OIC?
So let's implement a simple example -
Here is my Java class -
I realise the above is banal, but we can all extrapolate, correct?
Functions: creating an Application
Here I create an application - So what is an application?
Essentially a bucket for your functions e.g. HCM Functions, ERP Functions etc. It is also a unit at which resources can be allocated and configured. These resources can include subnet(s) allocated, whether logging is enabled etc.
Functions: creating a Function
Launch Cloud Shell -
Note the initial setup cmds - you only need to do this once.
I do a fn list apps command and see my 3 apps, including oic-discount-app.
I now enter a cmd to create a Java function skeleton - fn init --runtime java oicdiscount-java
So what has been generated?
Let's look at the /src directory structure -
Let's look at main -
So here it has generated an example Hello World java -
I make a copy of this file, calling it OICDiscountFunction.java
I vi the result -
I can now delete the HelloWorld function -
So now I have my Java code defined, what about the other directory - /test?
Now back up to the top app directory -
I need to amend both these files, as they reference the HelloWorld demo.