-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
176 additions
and
188 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BaseHookClass } from './lib/core/base_hook_class.js'; | ||
|
||
export class EggAgentHook extends BaseHookClass { | ||
configDidLoad() { | ||
this.agent._wrapMessenger(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
import assert from 'node:assert'; | ||
import type { ILifecycleBoot } from '@eggjs/core'; | ||
import type { Application, Agent } from '../../index.js'; | ||
|
||
const INSTANCE = Symbol('BaseHookClass#instance'); | ||
export class BaseHookClass implements ILifecycleBoot { | ||
fullPath?: string; | ||
#instance: Application | Agent; | ||
|
||
export class BaseHookClass { | ||
|
||
|
||
constructor(instance) { | ||
this[INSTANCE] = instance; | ||
constructor(instance: Application | Agent) { | ||
this.#instance = instance; | ||
} | ||
|
||
get logger() { | ||
return this[INSTANCE].logger; | ||
return this.#instance.logger; | ||
} | ||
|
||
get config() { | ||
return this[INSTANCE].config; | ||
return this.#instance.config; | ||
} | ||
|
||
get app() { | ||
assert(this[INSTANCE].type === 'application', 'agent boot should not use app instance'); | ||
return this[INSTANCE]; | ||
assert(this.#instance.type === 'application', 'agent boot should not use app instance'); | ||
return this.#instance as Application; | ||
} | ||
|
||
get agent() { | ||
assert(this[INSTANCE].type === 'agent', 'app boot should not use agent instance'); | ||
return this[INSTANCE]; | ||
assert(this.#instance.type === 'agent', 'app boot should not use agent instance'); | ||
return this.#instance as Agent; | ||
} | ||
} |
Oops, something went wrong.