Skip to content

Intrest in support for rpc types? #450

@vstreame

Description

@vstreame

I was wondering if typical is interest in adding a third top level type (in addition to struct and choice), rpc. That way one can model their APIs in typical along side their data models. For example:

struct User {
  id: String = 0
  username: String = 1
}

struct CreateUserInput {
  user: User = 0
}

choice CreateUserOutput {
  success = 0
  error: String = 1
}

rpc UserService {
  createUser(CreateUserInput): CreateUserOutput
}

I can imagine asymmetric also being useful for rpc as a way to deprecate API endpoints. Where the server must implement it, but the clients must handle the case where it is gone.

rpc UserService {
  # Deprecated: Use createUserV2 instead
  asymmetric createUser(CreateUserInput): CreateUserOutput
  createUserV2(CreateUserInputV2): CreateUserOutput
}

Or does RPC just open up a whole can of worms that typical doesn't want to deal with? My thinking is that Typical wouldn't handle the actual doing of the rpc, but the code generation would provide hooks for userland to fill in. That way the rpc could be through any user-defined protocol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions