Skip to content
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

Integrate lex changes into subscribeRepos route #703

Merged
merged 5 commits into from
Mar 22, 2023

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Mar 22, 2023

This integrates the lex changes from #698 into the subscribeRepos route

Namely work around removing InfoFrames & using the union ref on message to discriminate MessageFrames

@dholms dholms force-pushed the subscribe-repos-lex branch from 2d42d4d to 6e96a31 Compare March 22, 2023 02:57
@dholms dholms changed the title fixin gup lex + xrpc server Integrate lex changes into subscribeRepos route Mar 22, 2023
{ msg },
'unexpected message on repo subscription stream',
)
continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably we should move the cursor forward in this situation. But not terribly worried about it, since this area will get more attention soon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you're right that we should ideally. but I think I'll hold off on it until we start actually sending/processing those messages. there's not any way for this to currently get into a bad state

count: i,
}
}
yield { $type: 'io.example.stream2#done' }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should the behavior be for this? I imagine it might end-up in the header discriminated as #done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if the $type isn't in the same namespace as the current method, the whole thing might become the discriminator. E.g. if you yield { $type: 'app.bsky.feed.post' } then the header would look like { op: 1, t: 'app.bsky.feed.post' }.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup that's right^^

altho this seemed strange since it was not in the schema 🤔

I'm down to add something back in tho

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, the same case doesn't really happen now that codes is gone. I think it was a test of what happens when you yield a message with a type that doesn't have a matching code.

Comment on lines 102 to 98
$type:
i % 2 === 0 ? 'io.example.stream2#even' : 'io.example.stream2#odd',
$type: i % 2 === 0 ? '#even' : '#odd',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in a perfect world you can yield { $type: 'io.example.stream2#even' }, and #even get's placed as the discriminator in the header. I saw the compaction of the $type as being sort of an implementation detail of the wire protocol, and the application having the ability to deal with lex unions just as it normally would. Interested to hear your thinking on it!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup yup you're right. I fixed this up 👍

Comment on lines 58 to 61
const body = message.body
if (body && t !== undefined) {
body['$type'] = t.startsWith('#') ? this.opts.method + t : t
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutates message— I'm pretty much good with it, just want to make sure it was intended. I suppose there could be a way to tag the message frame with the opts.method, and then make the the processed message.body a getter, or something like that.

Copy link
Collaborator

@devinivy devinivy Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess it doesn't really matter since the message itself gets tossed!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah probably not a huge worry but pushed up a change here so that we don't mutate body 👍

Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a few tiny thoughts, but this is lookin real nice! I think the wire protocol will be much more legible this way 💎

@dholms dholms mentioned this pull request Mar 22, 2023
Base automatically changed from subscribe-repos-lex to feature/subscription-revamp March 22, 2023 21:40
@dholms dholms merged commit 53ffc0e into feature/subscription-revamp Mar 22, 2023
@dholms dholms deleted the subscribe-repos-route-rework branch March 22, 2023 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants