<commit_before>var RemoteGlue = require('./glue').RemoteGlue,
	sys = require('sys')
	
exports.plugin = function(mediator, host)
{
	var oldAddChannel = mediator.addChannel, 
	readyPods = [],
	groupId;

	mediator.addChannel = function(path, expr)
	{
		oldAddChannel.apply(mediator, arguments);

		//change here
		// mediator.push('channels', )
	}

	function init()
	{
		mediator.pull('glue/transport', function(transport)
		{
			new RemoteGlue(transport, mediator);
		});
	}

	function onBeanReady(name)
	{
		readyPods.push(name);
	}

	function getGlue()
	{
		var channels = [],
			ch = mediator.channels();

		for(var channel in ch)
		{
			var expr = ch[channel];

			//make sure not to use any networked call
			if(expr.meta.glued || !expr.meta['public']) continue;

			channels.push({ name: channel, lb: expr.meta.lb, multi: expr.meta.multi });
		}


		var info = {
			group: groupId,
			channels: channels
		}
		
		return info;
	}

	function pullGlue(writer)
	{
		writer.end(getGlue());
	}

	function pushGlue()
	{
		mediator.push('glue', getGlue());
	}

	function onAppId(data)
	{
		console.log(data)
	}

	function setAppGroup(data)
	{
		groupId = data;

		pushGlue();
	}

	mediator.on({
		'push init': init,
		'push ready': onBeanReady,
		'pull -public glue': pullGlue,

		//used for grouping apps so they communcate with one another only
		'push set/app/group': setAppGroup,

		'push -pull app/id': onAppId
	});
}<commit_msg>glue.core now handles when modules are ready<commit_after>var RemoteGlue = require('./glue').RemoteGlue,
	sys = require('sys')
	
exports.plugin = function(mediator, host)
{
	var oldAddChannel = mediator.addChannel, 
	readyBeans = {},
	groupId;

	mediator.addChannel = function(path, expr)
	{
		oldAddChannel.apply(mediator, arguments);

		//change here
		// mediator.push('channels', )
	}

	function init()
	{
		mediator.pull('glue/transport', function(transport)
		{
			new RemoteGlue(transport, mediator);
		});
	}

	function onBeanReady(name)
	{
		readyBeans[name] = 1;

		mediator.push(name + '/ready');

		mediator.on('pull -public -rotate '+name+'/ready', function(pull)
		{
			pull.end(true);
		});
	}

	function getGlue()
	{
		var channels = [],
			ch = mediator.channels();

		for(var channel in ch)
		{
			var expr = ch[channel];

			//make sure not to use any networked call
			if(expr.meta.glued || !expr.meta['public']) continue;

			channels.push({ name: channel, rotate: expr.meta.rotate, multi: expr.meta.multi });
		}


		var info = {
			cluster: groupId,
			channels: channels
		}
		
		return info;
	}

	function pullGlue(writer)
	{
		writer.end(getGlue());
	}

	function pushGlue()
	{
		mediator.push('glue', getGlue());
	}

	function onAppId(data)
	{
		console.log(data)
	}

	function setAppGroup(data)
	{
		groupId = data;

		pushGlue();
	}

	function onConnection(data, req)
	{
		// console.log(req.from.channels);

		for(var bean in readyBeans)
		{
			req.from.push(bean + '/ready', true, { ignoreWarning: true });
		}
	}

	mediator.on({
		'push init': init,
		'push ready': onBeanReady,
		'pull -public glue': pullGlue,

		//used for grouping apps so they communcate with one another only
		'push set/app/group': setAppGroup,

		'push glue/connection': onConnection,
	});
}
{'fraction_non_alphanumeric': 0.14998450573287883, 'fraction_numerical': 0.0003098853424233034, 'mean_word_length': 3.4647302904564317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3847374', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1138, 'n_words': 255}