Skip to content
Snippets Groups Projects
Commit 189aa127 authored by Franky Begue's avatar Franky Begue
Browse files

Update README.md

parent 32b23861
No related branches found
No related tags found
No related merge requests found
# Couchbase_Eventing_Script # Couchbase_Eventing_Script
This utility lets you programatically deploy couchbase eventing functions based on your local folder structure. This utility lets you programatically deploy couchbase eventing functions based on your local folder structure.
For now its just a POC but it works! and it gets you out of trying to interact with their web UI which is . . . lacking. For now its just a POC but it works! and it gets you out of trying to interact with their web UI which is . . . lacking.
Basically we're just setting up a folder with some functions in it, where each file corresponds to an eventing function name [like the ones listed here](http://128.146.12.34:8091/ui/index.html#!/eventing/summary)
Then when you want to update one, you make changes to that file and run the importDeploy script with the function (and file) name as an arg. It'll find the new code and post it
to the server and take care of importing/deploying/undeploying for you.
## Quickstart
- fill out the config (./config.js) which for now just uses YOUR login for couchbase
- Run this from the command line with two arguments: function name (or file name without '.js') and operation mode (true = update, false = create):
Example: `node couchbase_eventing getErrors true`
Please check out the `example_function.js` and in general please do not break anything
## Known issues
- UI 'Edit Javascript' stickiness
One of the serveral reasons I made this thing: if you go [here](http://128.146.12.34:8091/ui/index.html#!/eventing/summary) you can sit and watch the UI report 'status' updates
on the eventing/summary page, but even after it finishes (status = deployed) you still need to refresh the page in order to see the new code. Meaning - if you want to double
check that your thing is out there, make sure to refresh the page!
- NO inline n1ql queries!
(For now, see below)
## Todo
- inline n1ql queries
- allow user to specify path to function file in CLI (get rid of assumed folder structure?)
- change login to use some 'system' account not our 'user' logins
## Couchbase Event Scripts
#### eventing api
`https://docs.couchbase.com/server/current/eventing/eventing-api.html`
- although they do not specify, a POST to /import with the content of a function that
already exists will actually UPDATE that function (there is no explicit PUT)
NOT however if it is deployed. must be in undeployed state to work. This is the major function
this project takes advantage of.
- these scripts have the ability to accept inline n1ql queries
But you won't be able to run them locally obviously if you can't parse them.
On the server it does this parsing by detecting these inline statements and turning them into N1QL() calls -
so even though we're not using them yet, best to get in the practice of properly terminating every statement with a
semicolon to help the parser out in the case you do use this inline n1ql language
- interestingly, the documentation specifically says not to use the built in N1QL() function to do the parsing before hand,
although that would be ideal...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment