Why Go Serverless? • Costs nothing when idle • Small application, simple architecture • Bursty usage since it runs from a cron • No real-time requirement • Easily within free tier @lornajane
OfflineFirst Applications This app is OfflineFirst: • Client side JS • Client side copy of DB using PouchDB • Background sync to serverside CouchDB @lornajane
Start with Security Need an API key or user creds for bx wsk tool Web actions: we know how to secure HTTP connections, so do it! • Auth standards e.g. JWT • Security in transmission: use HTTPS @lornajane
Logging Considerations • Standard, configurable logging setup • Use a trace_id to link requests between services • Aggregate logs to a central place, ensure search functionality • Collect metrics (invocations, execution time, error rates) • display metrics on a dashboard • have appropriate, configurable alerting @lornajane
Pipeline Actions Sequence socron • collector makes an API call, passes on data • invoker fires many actions: one for each item Sequence qhandler • storer inserts or updates the record • notifier sends a webhook to slack or a bot @lornajane
Storer 1 function main(message) { 2 var cloudant = require('cloudant')({url: message.cloudantURL, 3 var db = cloudant.db.use(message.dbname); 4 var id = message.question.question_id.toString(); 5 return getDoc(db, id).then(function(data) { 6 if (data === null) { // so insert 7 message.question.tags = message.question.tags.sort(); // 8 var obj = { _id: id, type: 'question', owner: null, statu 9 return db.insert(obj).then(function(data) { 10 return obj; // pass on the new object to the next actio 11 }); 12 } else { ... } 13 }); @lornajane
Deployment • IBM Cloud Deployments or TravisCI • Deploy on commit (optionally just what has changed) • Recreate triggers and rules if appropriate • Use environment variables for secrets • Install bx command to use at deploy time @lornajane