Skip to content

Commit

Permalink
refactor JK to function as killswitch for easier scalability
Browse files Browse the repository at this point in the history
Summary:
Simple refactor - so JK lives in `updateFromVC` which will limit the usage of having to wrap
```
    if (JustKnobs::eval('meta_cp/www:enable_user_id_ctx_prop'))
```

in the instrumentation points

Reviewed By: aknott

Differential Revision: D69260239

fbshipit-source-id: ba134564e6bc221f792e22b12b0a88cd82915b0f
  • Loading branch information
Mahmudul Rapi authored and facebook-github-bot committed Feb 6, 2025
1 parent baaa12c commit d19208e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public static function initFromString(?string $s)[defaults]: void {
}

public static function updateFromVC(?IViewerContextBase $vc): void {
if ($vc is null) {
return;
}

if (!JustKnobs::eval('meta_cp/www:enable_user_id_ctx_prop')) {
return;
}

if ($vc is IFBViewerContext) {
self::updateFBUserIdFromVC($vc);
} else if ($vc is IIGViewerContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function testInitialization()[defaults]: void {
}

public async function testInitializationWithVC()[defaults]: Awaitable<void> {
MockJustKnobs::setBool('meta_cp/www:enable_user_id_ctx_prop', true);
$tfm = ThriftFrameworkMetadata::withDefaultValues();
$tfm->baggage = ContextProp\Baggage::withDefaultValues();
$tfm->baggage->user_ids = ContextProp\UserIds::fromShape(
Expand Down Expand Up @@ -175,6 +176,7 @@ public function testInitialization()[defaults]: void {

public async function testInitializationWithBothTFMandVC(
)[defaults]: Awaitable<void> {
MockJustKnobs::setBool('meta_cp/www:enable_user_id_ctx_prop', true);
$tfm = ThriftFrameworkMetadata::withDefaultValues();
$tfm->baggage = ContextProp\Baggage::withDefaultValues();
$tfm->baggage->user_ids = ContextProp\UserIds::fromShape(
Expand All @@ -201,6 +203,7 @@ public function testInitialization()[defaults]: void {

public async function testInitializationUserIdsNotOverwritten(
)[defaults]: Awaitable<void> {
MockJustKnobs::setBool('meta_cp/www:enable_user_id_ctx_prop', true);
$tfm = ThriftFrameworkMetadata::withDefaultValues();
$tfm->baggage = ContextProp\Baggage::withDefaultValues();
$tfm->baggage->user_ids = ContextProp\UserIds::fromShape(
Expand Down

0 comments on commit d19208e

Please sign in to comment.