Fixups for twitter streaming daemon

This commit is contained in:
Brion Vibber 2010-10-29 13:41:15 -07:00
parent 47eada3a95
commit d743539cf7
2 changed files with 17 additions and 16 deletions

View File

@ -201,8 +201,14 @@ class TwitterBridgePlugin extends Plugin
case 'TwitterOAuthClient': case 'TwitterOAuthClient':
case 'TwitterQueueHandler': case 'TwitterQueueHandler':
case 'TwitterImport': case 'TwitterImport':
case 'JsonStreamReader':
case 'TwitterStreamReader':
include_once $dir . '/' . strtolower($cls) . '.php'; include_once $dir . '/' . strtolower($cls) . '.php';
return false; return false;
case 'TwitterSiteStream':
case 'TwitterUserStream':
include_once $dir . '/twitterstreamreader.php';
return false;
case 'Notice_to_status': case 'Notice_to_status':
case 'Twitter_synch_status': case 'Twitter_synch_status':
include_once $dir . '/' . $cls . '.php'; include_once $dir . '/' . $cls . '.php';

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
$shortoptions = 'fi::a'; $shortoptions = 'fi::a';
$longoptions = array('id::', 'foreground', 'all'); $longoptions = array('id::', 'foreground', 'all');
@ -82,13 +82,11 @@ class TwitterMaster extends IoMaster
*/ */
function initManagers() function initManagers()
{ {
if (common_config('twitter', 'enabled')) { $qm = QueueManager::get();
$qm = QueueManager::get(); $qm->setActiveGroup('twitter');
$qm->setActiveGroup('twitter'); $this->instantiate($qm);
$this->instantiate($qm); $this->instantiate(new TwitterManager());
$this->instantiate(TwitterManager::get()); $this->instantiate($this->processManager);
$this->instantiate($this->processManager);
}
} }
} }
@ -103,10 +101,6 @@ class TwitterManager extends IoManager
protected $twitterStreams; protected $twitterStreams;
protected $twitterUsers; protected $twitterUsers;
function __construct()
{
}
/** /**
* Pull the site's active Twitter-importing users and start spawning * Pull the site's active Twitter-importing users and start spawning
* some data streams for them! * some data streams for them!
@ -116,6 +110,7 @@ class TwitterManager extends IoManager
*/ */
protected function initStreams() protected function initStreams()
{ {
common_log(LOG_INFO, 'init...');
// Pull Twitter user IDs for all users we want to pull data for // Pull Twitter user IDs for all users we want to pull data for
$flink = new Foreign_link(); $flink = new Foreign_link();
$flink->service = TWITTER_SERVICE; $flink->service = TWITTER_SERVICE;
@ -144,9 +139,9 @@ class TwitterManager extends IoManager
* Prepare a Site Stream connection for the given chunk of users. * Prepare a Site Stream connection for the given chunk of users.
* The actual connection will be opened later. * The actual connection will be opened later.
* *
* @param $users array of Twitter-side user IDs * @param $userIds array of Twitter-side user IDs
*/ */
protected function spawnStream($users) protected function spawnStream($userIds)
{ {
$stream = $this->initSiteStream(); $stream = $this->initSiteStream();
$stream->followUsers($userIds); $stream->followUsers($userIds);
@ -213,7 +208,7 @@ class TwitterManager extends IoManager
$sockets[] = $socket; $sockets[] = $socket;
} }
} }
return $streams; return $sockets;
} }
/** /**
@ -272,7 +267,7 @@ class TwitterManager extends IoManager
* *
* @fixme add more event types as we add handling for them * @fixme add more event types as we add handling for them
*/ */
protected function setupEvents(TwitterStream $stream) protected function setupEvents(TwitterStreamReader $stream)
{ {
$handlers = array( $handlers = array(
'status', 'status',