Skip to content

Instantly share code, notes, and snippets.

@zubairov
Last active October 12, 2017 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zubairov/d8b9f839dde50eb3cf564ca40a0a8997 to your computer and use it in GitHub Desktop.
Save zubairov/d8b9f839dde50eb3cf564ca40a0a8997 to your computer and use it in GitHub Desktop.
package com.acme.comp.actions;
public class CreateCustomerAction extends Component {
@Override
public final void execute(ExecutionParameters parameters) {
logger.info("About to execute create customer action");
// This is an incoming message
final Message message = parameters.getMessage();
// This is outgoing result
final JsonObject body = new JsonObject();
final Message data = new Message.Builder().body(body).build();
// Sending it to the next integration step
parameters.getEventEmitter().emitData(data)
}
}
const request = require('request-promise');
/**
* This method will be called from elastic.io with following parameteers
*
* @param msg incoming message object that contains ``body`` with payload
* @param cfg configuration that is account information and configuration field values
*/
async function process(msg, cfg) {
console.log('You stdout will be safe with us');
const user = await request.get(`https://api.github.com/users/${msg.body.user}?length=${cfg.pageSize}`);
const repos = await request.get(user.repos_url);
console.log(`Fetched ${repos.length} repos`);
return { repos };
}
module.exports.process = process;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment