git clone https://github.com/abhirockzz/fn-oracledb-golang
- run
seed-db.sql
to create the table in your DB - replace
config
sectionfunc.yaml
with DB connectivity details for your specific environment
fn start
Configure Docker
docker login
(use your docker registry credentials)export FN_REGISTRY=<name of your docker repository>
your function docker image name will end up being -
<docker repo name>/<function name in func.yaml>:<version in func.yaml>
Moving on....
cd fn-oracledb-golang
fn -v deploy --all
(-v
will activate verbose mode)
adding
--local
to above command will build & push docker images locally (and run it from there). Remove it if you want use a dedicated/external Docker registry
All your functions (create, read, update, delete) should now be deployed. Check it using fn inspect app fn-oradb-go-app
and fn list routes fn-oradb-go-app
Custom Docker images have been used for build_image
and run_image
(see func.yaml
) - this Docker image pre-packages a Go Oracle driver. You can also build you own image
DB connection is not closed at end of every function invocation - this is to leverage hot functions. If the function is called before the idle_timeout
(default is 30 seconds and can be configured via func.yaml
), the call will be routed to a hot function (already used) DB connection will not be repeated again
Bare minimum config file which defines the name of the app i.e. fn-oradb-go-app
... with Fn CLI using fn call
echo -n '{"emp_email": "a@b.com","emp_name": "abhishek","emp_dept": "Product Divison"}' | fn call fn-oradb-go-app /create
Create as many as you want
fn call fn-oradb-go-app /read
(to fetch all employees)echo -n 'a@b.com' | fn call fn-oradb-go-app /read
(to fetch employee with emaila@b.com
)
It is possible to update the department of an employee
echo -n '{"emp_email": "a@b.com", "emp_dept": "Support Operations"}' | fn call fn-oradb-go-app /update
check to make sure -
echo a@b.com | fn call fn-oradb-go-app /read
Use employee email to specify which employee record you want to delete
echo -n 'a@b.com' | fn call fn-oradb-go-app /delete
check to make sure -
echo -n 'a@b.com' | fn call fn-oradb-go-app /read