-
Notifications
You must be signed in to change notification settings - Fork 97
refactor: externalize singleton accessors from trace writer #694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #694 +/- ##
==========================================
+ Coverage 90.06% 90.15% +0.09%
==========================================
Files 29 29
Lines 1419 1422 +3
Branches 288 287 -1
==========================================
+ Hits 1278 1282 +4
Misses 57 57
+ Partials 84 83 -1
Continue to review full report at Codecov.
|
src/util.ts
Outdated
} | ||
|
||
/** | ||
* An class that provides access to a singleton. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/util.ts
Outdated
export class Singleton<T, Config> { | ||
private singleton: T|null = null; | ||
|
||
constructor(private implementation: ClassOf<T, Config>) {} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
0776eb1
to
79af06b
Compare
src/util.ts
Outdated
* Instances of this type should only be constructed in module scope. | ||
*/ | ||
export class Singleton<T, Config> { | ||
private singleton: T|null = null; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
let singleton: TraceWriter|null = null; | ||
disableTraceWriter(); | ||
export function setTraceWriterEnabled(enabled: boolean) { | ||
traceWriter['implementation'] = enabled ? TraceWriter : TestTraceWriter; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
constructor(private implementation: Constructor<T, Config>) {} | ||
|
||
create(logger: Logger, config: Config&{forceNewAgent_: boolean}): T { | ||
create(logger: Logger, config: Config&{forceNewAgent_?: boolean}): T { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Node 9 CI is failing only because the way it was rebuilt (through Circle workflows) doesn't allow it to correctly detect whether it should run system tests. This should not be reflected on master |
This change adds a class that abstracts the "singleton" concept and uses it for the TraceWriter singleton. This makes singletons (including the future PluginLoader class) easier to mock.
I recommend looking at each commit separately