This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial test integration with the new activity service
This service is used to count active visitors within contexts. This initial implementation allows us to shadow-write and shadow-read depending on a set of feature flags.
- Loading branch information
Showing
8 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
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
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,56 @@ | ||
include "baseplate.thrift" | ||
|
||
/** A unique identifier for a given "context". | ||
A context is an area of the service which a user may be active within, such as | ||
a subreddit or live thread. | ||
*/ | ||
typedef string ContextID | ||
|
||
/** A unique identifier for a given visitor. | ||
A visitor may be a logged-in user's ID or a logged-out user's LOID value. The | ||
value is not actually stored, but only used to update the internal counters. | ||
*/ | ||
typedef string VisitorID | ||
|
||
|
||
/** A count of visitors active within a context. | ||
If the count is low enough, some fuzzing is applied to the number. If this | ||
kicks in, the `is_fuzzed` attribute will be True. | ||
*/ | ||
struct ActivityInfo { | ||
1: optional i32 count; | ||
2: optional bool is_fuzzed; | ||
} | ||
|
||
/** A specified context ID was invalid */ | ||
exception InvalidContextIDException { | ||
} | ||
|
||
service ActivityService extends baseplate.BaseplateService { | ||
/** Register a visitor's activity within a given context. | ||
The visitor's activity will be recorded but will expire over time. If the | ||
user continues to be active within the context, this endpoint should be | ||
called occasionally to ensure they continue to be counted. | ||
This method is `oneway`; no indication of success or failure is returned. | ||
*/ | ||
oneway void record_activity(1: ContextID context_id, 2: VisitorID visitor_id), | ||
|
||
/** Count how many visitors are currently active in a given context. | ||
The results of this call are cached for a period of time to ensure that if | ||
the count is fuzzed, the fuzzing is stable. This prevents repeated requests | ||
from revealing the range of fuzzing and therefore the true value. | ||
*/ | ||
ActivityInfo count_activity(1: ContextID context_id) | ||
throws (1: InvalidContextIDException invalid_context_id), | ||
} |
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
c88036c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: Are the automatically generated
r2/lib/contrib/activity_thrift
folder supposed to be in the.gitignore
? I just noticed it because I wanted togit add -A
and I saw a whole bunch of stuff I didn't even write.