Skip to content

Commit

Permalink
feat: remove worker client, use app.cluster (eggjs#282)
Browse files Browse the repository at this point in the history
Closes eggjs#278
  • Loading branch information
popomore authored and fengmk2 committed Feb 7, 2017
1 parent 66bf7ca commit 0ee4451
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 1,191 deletions.
49 changes: 0 additions & 49 deletions app/extend/application.js

This file was deleted.

12 changes: 0 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ exports.Application = require('./lib/application');
*/
exports.Agent = require('./lib/agent');

/**
* @member {AgentWorkerClient} Egg#AgentWorkerClient
* @since 1.0.0
*/
exports.AgentWorkerClient = require('./lib/core/agent_worker_client');

/**
* @member {AppWorkerClient} Egg#AppWorkerClient
* @since 1.0.0
*/
exports.AppWorkerClient = require('./lib/core/app_worker_client');

/**
* @member {AppWorkerLoader} Egg#AppWorkerLoader
* @since 1.0.0
Expand Down
32 changes: 0 additions & 32 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const path = require('path');
const EggApplication = require('./egg');
const AgentWorkerLoader = require('./loader').AgentWorkerLoader;
const AgentWorkerClient = require('./core/agent_worker_client');

const AGENT_CLIENTS = Symbol('Agent#agentClients');
const EGG_LOADER = Symbol.for('egg#loader');
Expand Down Expand Up @@ -46,37 +45,6 @@ class Agent extends EggApplication {
return this[AGENT_CLIENTS];
}

/**
* 启动一个 agent 任务
* @param {Object} options
* - {String} name 唯一的名字,例如:diamond | configclient
* - {Object} client 任务的客户端
* - {Function} subscribe 提供一个统一注册的方法 `subscribe(info, listener)`
* - {Function} formatKey 提供一个方法:将订阅信息格式化为一个唯一的键值 `formatKey(info)`
* @return {AgentWorkerClient} -
* @example
* ```
* // 实际创建一个 configclient,然后启动 agent 任务
* const client = new Configclient();
* agent.startAgent({
* name: 'configclient',
* client: client,
* subscribe: function(info, listener) {
* client.subscribe(info, listener);
* },
* formatKey: function(info) {
* return info.dataId + '@' + info.groupId;
* },
* })
* ```
*/
startAgent(options) {
options = options || {};
options.agent = this;

return new AgentWorkerClient(options);
}

_uncaughtExceptionHandler(err) {
if (!(err instanceof Error)) {
err = new Error(String(err));
Expand Down
207 changes: 0 additions & 207 deletions lib/core/agent_worker_client.js

This file was deleted.

Loading

0 comments on commit 0ee4451

Please sign in to comment.