Skip to content

Commit

Permalink
feat(context): make parent public for invocation context
Browse files Browse the repository at this point in the history
Some interceptors such as tracing need to add bindings to the parent,
which is typically the request context.
  • Loading branch information
raymondfeng committed May 26, 2019
1 parent e211a71 commit 19856c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ describe('InvocationContext', () => {
);
});

it('has public access to parent context', () => {
expect(invocationCtxForGreet.parent).to.equal(ctx);
});

it('throws error if method does not exist', () => {
expect(() => invalidInvocationCtx.assertMethodExists()).to.throw(
'Method MyController.prototype.invalid-method not found',
Expand Down
4 changes: 3 additions & 1 deletion packages/context/src/interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export class InvocationContext extends Context {
* @param args - An array of arguments
*/
constructor(
parent: Context,
// Make `parent` public so that the interceptor can add bindings to
// the request context, for example, tracing id
public readonly parent: Context,
public readonly target: object,
public readonly methodName: string,
public readonly args: InvocationArgs,
Expand Down

0 comments on commit 19856c6

Please sign in to comment.