Saturday, April 02, 2011 at 9:18 PM.

feedhoseSuite.client.main

on main (hosename) {
	<<Changes
		<<12/2/10; 3:40:35 AM by DW
			<<Add fldebug flag, and debugging code controlled by it.
		<<9/29/10; 2:27:25 PM by DW
			<<Add hosename parameter.
		<<9/25/10; 8:34:25 PM by DW
			<<Created. 
	local (adrdata = feedHoseSuite.init (), fldebug = true);
	local (adrhose = feedhosesuite.client.inithose (hosename), xstruct);
	system.temp.feedHose.client.threadIDs.[hosename] = thread.getcurrentid ();
	loop {
		if not adrhose^.prefs.enabled { //9/30/10 by DW
			break};
		try {
			local (adrday, path = "?name=" + adrhose^.prefs.serverHoseName, startticks = clock.ticks ());
			if adrhose^.stats.lastSeed != "" {
				path = path + "&seed=" + adrhose^.stats.lastSeed};
			local (xmltext = string.httpResultSplit (tcp.httpClient (server:adrhose^.prefs.server, path:path, flMessages:false, timeOutTicks:60*adrdata^.client.prefs.timeoutSecs)));
			adrday = mainresponder.calendar.getdayaddress (@adrhose^.calendar, clock.now ());
			if fldebug { //12/2/10 by DW
				adrhose^.stats.lastxmltext = xmltext};
			xml.compile (xmltext, @xstruct);
			if fldebug { //12/2/10 by DW
				adrhose^.stats.lastxstruct = xstruct};
			local (adrfeedhose = xml.getaddress (@xstruct, "feedHose"), adr, fltimeout = true);
			local (adrmetadata = xml.getaddress (adrfeedhose, "metadata"));
			try { //might not contain an items table
				local (adritems = xml.getaddress (adrfeedhose, "items"));
				for adr in adritems {
					if nameof (adr^) endswith "item" {
						adrday^.[string.padwithzeros (sizeof (adrday^) + 1, 5)] = adr^;
						feedhoseSuite.client.itemArrived (hosename, adr); //10/5/10 by DW
						adrhose^.stats.flWrite = true;
						adrhose^.stats.ctNewItems++;
						fltimeout = false}}}; //if there's at least one new item it was not a timeout
			if fltimeout {
				adrhose^.stats.ctTimeouts++};
			adrhose^.stats.lastSeed = xml.getvalue (adrmetadata, "seed");
			adrhose^.stats.lastError = "";
			adrhose^.stats.ctLoops++;
			adrhose^.stats.ctticksLastCall = clock.ticks () - startticks} //12/2/10 by DW
		else {
			adrhose^.stats.lastError = tryerror;
			adrhose^.stats.whenLastError = clock.now ()};
		if adrhose^.stats.flWrite {
			feedhoseSuite.client.write (hosename);
			adrhose^.stats.flWrite = false;
			thread.sleepfor (10)}}}; //12/2/10 by DW
bundle { //test code
	main ("nyTimes")}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.