-
Notifications
You must be signed in to change notification settings - Fork 835
Streaming repo subscriptions #518
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
Merged
Merged
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
0d36fe8
scaffolding repo subscriptions
dholms 8c3590a
wip
dholms 556a516
remove repo ops
dholms 97668f0
setup notify/listen for db
dholms 458e01f
end pool to fix hanging test
dholms 027753e
small comment in test
dholms a714ded
Merge branch 'db-notify-listen' into subscribe-repos
dholms a31ca30
basic sequencer
dholms 88a1baa
some refactoring
dholms 2f79c3e
switch to event emitter
dholms 12af4f6
reconnect on listener error
dholms 105ec60
rename notifyClient
dholms f2c74fa
remove payload on channels
dholms 8a5539e
pr feedback
dholms 3346ede
Merge branch 'db-notify-listen' into subscribe-repos
dholms ddfa711
subscribeRepo outbox
dholms 05fd0f4
merged
dholms ab5ea66
some cleanup
dholms 7a5291b
wip
dholms fb052b5
wip
dholms 76b3962
merged main
dholms a8c9e2d
bugfixin
dholms f24e1be
only send msgs after tx is committed
dholms 65dffd1
better handle event-emitter -> generator
dholms c094277
max buffer size
dholms 0993210
cleanup
dholms 4e527d8
track sequencedAt & eventType as well
dholms 19b60a1
fix up buffer overloading
dholms 72c4140
clean up evt types
dholms 35bd329
buff up tests
dholms ba683c4
merged main
dholms 89d34a0
missed merge conflict
dholms 7cc7cd0
new schema
dholms 5b3eaee
blobs on subscriptions
dholms 730e2c7
rm genned client subscription methods
dholms efc05ae
backfill limits
dholms e4286e2
testing subscription route & quick outbox bugfix
dholms 550417a
fix up migration
dholms 9ebd589
cascade on delete
dholms 3f94b3a
comments & naming
dholms 5fe34b0
fix dev env
dholms cc6d8a2
delete seqs on account deletion
dholms 8046299
tidy
dholms 10eea8a
fixing things up with db notify system for schemas
dholms 018476c
fix duplicates in outbox
dholms dd412af
tidy
dholms 5ca021d
Merge branch 'xrpc-streams' into subscribe-repos
dholms 335d993
fixing up some timing issues
dholms fdf8557
tidy
dholms e474af0
terminate ws after using
dholms 0cfdb01
bump up timer on async reader
dholms 7f0806e
fixing up NOTIFY in txns
dholms fcc0141
pr feedback
dholms 276376e
pr bugfixes
dholms a89b5fa
make order asc explicit
dholms bf6693e
merged
dholms f967b63
bringing tests up to speed w atpagent
dholms ccedc84
bump up max listeners on sequencer
dholms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,53 @@ | ||
| { | ||
| "lexicon": 1, | ||
| "id": "com.atproto.sync.subscribeAllRepos", | ||
| "defs": { | ||
| "main": { | ||
| "type": "subscription", | ||
| "description": "Subscribe to repo updates", | ||
| "parameters": { | ||
| "type": "params", | ||
| "properties": { | ||
| "backfillFrom": { | ||
| "type": "datetime", | ||
| "description": "The last known event to backfill from. Does not dedupe as there may be an overlap in timestamps." | ||
| } | ||
| } | ||
| }, | ||
| "message": { | ||
| "schema": { | ||
| "type": "union", | ||
| "refs": ["#repoAppend", "#repoRebase"] | ||
| }, | ||
| "codes": { | ||
| "#repoAppend": 0, | ||
| "#repoRebase": 1 | ||
| } | ||
| } | ||
| }, | ||
| "repoAppend": { | ||
| "type": "object", | ||
| "required": ["time", "repo", "commit", "blocks", "blobs"], | ||
| "properties": { | ||
| "time": {"type": "datetime"}, | ||
| "repo": {"type": "string"}, | ||
| "commit": {"type": "string"}, | ||
| "prev": {"type": "string"}, | ||
| "blocks": {"type": "unknown"}, | ||
| "blobs": { | ||
| "type": "array", | ||
| "items": {"type": "string"} | ||
| } | ||
| } | ||
| }, | ||
| "repoRebase": { | ||
| "type": "object", | ||
| "required": ["time", "repo", "commit"], | ||
| "properties": { | ||
| "time": {"type": "datetime"}, | ||
| "repo": {"type": "string"}, | ||
| "commit": {"type": "string"} | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
48 changes: 48 additions & 0 deletions
48
packages/api/src/client/types/com/atproto/sync/subscribeAllRepos.ts
This file contains hidden or 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,48 @@ | ||
| /** | ||
| * GENERATED CODE - DO NOT MODIFY | ||
| */ | ||
| import { Headers, XRPCError } from '@atproto/xrpc' | ||
| import { ValidationResult } from '@atproto/lexicon' | ||
| import { isObj, hasProp } from '../../../../util' | ||
| import { lexicons } from '../../../../lexicons' | ||
|
|
||
| export interface RepoAppend { | ||
| time: string | ||
| repo: string | ||
| commit: string | ||
| prev?: string | ||
| blocks: {} | ||
| blobs: string[] | ||
| [k: string]: unknown | ||
| } | ||
|
|
||
| export function isRepoAppend(v: unknown): v is RepoAppend { | ||
| return ( | ||
| isObj(v) && | ||
| hasProp(v, '$type') && | ||
| v.$type === 'com.atproto.sync.subscribeAllRepos#repoAppend' | ||
| ) | ||
| } | ||
|
|
||
| export function validateRepoAppend(v: unknown): ValidationResult { | ||
| return lexicons.validate('com.atproto.sync.subscribeAllRepos#repoAppend', v) | ||
| } | ||
|
|
||
| export interface RepoRebase { | ||
| time: string | ||
| repo: string | ||
| commit: string | ||
| [k: string]: unknown | ||
| } | ||
|
|
||
| export function isRepoRebase(v: unknown): v is RepoRebase { | ||
| return ( | ||
| isObj(v) && | ||
| hasProp(v, '$type') && | ||
| v.$type === 'com.atproto.sync.subscribeAllRepos#repoRebase' | ||
| ) | ||
| } | ||
|
|
||
| export function validateRepoRebase(v: unknown): ValidationResult { | ||
| return lexicons.validate('com.atproto.sync.subscribeAllRepos#repoRebase', v) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
| export const SECOND = 1000 | ||
| export const MINUTE = SECOND * 60 | ||
| export const HOUR = MINUTE * 60 | ||
| export const DAY = HOUR * 24 |
This file contains hidden or 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,22 @@ | ||
| import { readFromGenerator, wait } from '../src' | ||
|
|
||
| describe('async', () => { | ||
| describe('readFromGenerator', () => { | ||
dholms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async function* waitToYield(time: number) { | ||
| for (let i = 0; i < 5; i++) { | ||
| await wait(time) | ||
| yield true | ||
| } | ||
| } | ||
|
|
||
| it('reads from generator with timeout', async () => { | ||
| const read = await readFromGenerator(waitToYield(100), undefined, 101) | ||
| expect(read).toEqual([true, true, true, true, true]) | ||
| }) | ||
|
|
||
| it('stops reading at timeout', async () => { | ||
| const read = await readFromGenerator(waitToYield(100), undefined, 99) | ||
| expect(read).toEqual([]) | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
bumping this up to 1000 let's all the tests pass when run in the test suite
I think PG just gets a bit bogged down & doesn't deliver notifcations in time