-
Notifications
You must be signed in to change notification settings - Fork 618
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
Integrate lex changes into subscribeRepos route #703
Conversation
2d42d4d
to
6e96a31
Compare
{ msg }, | ||
'unexpected message on repo subscription stream', | ||
) | ||
continue |
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.
Arguably we should move the cursor forward in this situation. But not terribly worried about it, since this area will get more attention soon.
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.
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' } |
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.
What should the behavior be for this? I imagine it might end-up in the header discriminated as #done
.
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.
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' }
.
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.
yup that's right^^
altho this seemed strange since it was not in the schema 🤔
I'm down to add something back in tho
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.
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.
$type: | ||
i % 2 === 0 ? 'io.example.stream2#even' : 'io.example.stream2#odd', | ||
$type: i % 2 === 0 ? '#even' : '#odd', |
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.
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!
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.
yup yup you're right. I fixed this up 👍
const body = message.body | ||
if (body && t !== undefined) { | ||
body['$type'] = t.startsWith('#') ? this.opts.method + t : t | ||
} |
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.
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.
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.
Ah, I guess it doesn't really matter since the message itself gets tossed!
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.
yeah probably not a huge worry but pushed up a change here so that we don't mutate body 👍
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.
Had a few tiny thoughts, but this is lookin real nice! I think the wire protocol will be much more legible this way 💎
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