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

es/v2: Port /implementing-services #215

Open
wants to merge 2 commits into
base: es/v2
Choose a base branch
from

Conversation

srikrsna-buf
Copy link
Member

Port /implementing-services section to v2.

Copy link

vercel bot commented Oct 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
connect ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2024 10:42pm


export const eliza: ServiceImpl<typeof ElizaService> = {
// ...
};

export class Eliza implements ServiceImpl<typeof ElizaService> {
async say(req: SayRequest) {
export class Eliza implements Partial<ServiceImpl<typeof ElizaService>> {
Copy link
Member Author

Choose a reason for hiding this comment

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

I used Partial here to avoid the not implemented error, if the user decides to copy the code as is.

Copy link
Member

Choose a reason for hiding this comment

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

This page builds on the previous page "Getting started", where we're defining the service with just this RPC. It's fine to not use Partial here.


export default (router: ConnectRouter) =>
router.service(ElizaService, {
async say(req: SayRequest, context: HandlerContext) {
return new SayResponse({
return create(SayResponseSchema, {
Copy link
Member Author

Choose a reason for hiding this comment

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

With the added type safety of the message init types should we just recommend using the init version?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think we should return the init object here - we do it in pretty much every example and also in clients.

Signed-off-by: Sri Krishna Paritala <skrishna@buf.build>
Signed-off-by: Sri Krishna Paritala <skrishna@buf.build>
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