Last active
October 12, 2017 15:55
-
-
Save zubairov/d8b9f839dde50eb3cf564ca40a0a8997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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