Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/room-rpc-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"github.com/livekit/protocol": minor
"@livekit/protocol": minor
---

Introduce a participant RPC protobuf registry for well-known LiveKit RPCs.
295 changes: 295 additions & 0 deletions livekit/roomrpc/siprpc/roomrpc_sip_v1.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 32 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ func Proto() error {
"rpc/sip.proto",
}

// mapped proto directory:
// ./protobufs/livekit/roomrpc/<name>rpc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ./protobufs/livekit/roomrpc/<name>rpc
// ./protobufs/roomrpc/<name>rpc

// and generated Go package:
// ./livekit/roomrpc/<name>rpc
roomrpcTypeNames := []string{
"sip",
}

fmt.Println("generating protobuf")
target := "livekit"
const target = "./livekit"
if err := os.MkdirAll(target, 0755); err != nil {
return err
}
Expand Down Expand Up @@ -162,6 +170,29 @@ func Proto() error {
}
}

fmt.Println("generating protobuf (livekit/roomrpc)")
for _, protoName := range roomrpcTypeNames {
pkgName := "roomrpc/" + protoName + "rpc"
protoFiles, err := os.ReadDir(filepath.Join("./protobufs", pkgName))
if err != nil {
return err
}
args := []string{
"--go_out", target,
"--go_opt=paths=source_relative",
"--plugin=go=" + protocGoPath,
"-I=./protobufs",
}
for _, protoFile := range protoFiles {
args = append(args, filepath.Join(pkgName, protoFile.Name()))
}
cmd := exec.Command(protoc, args...)
connectStd(cmd)
if err := cmd.Run(); err != nil {
return err
}
}

fmt.Println("generating grpc protobuf")
args = append([]string{
"--go_out", ".",
Expand Down
25 changes: 25 additions & 0 deletions protobufs/roomrpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# LiveKit participant RPCs registry (roomrpc)

These protos describe a list of well-known [LiveKit participant RPCs](https://docs.livekit.io/transport/data/rpc/)
and corresponding request/response messages.

## Directory structure

Each participant type or API should have its own directory under `roomrpc` with the name `<type>rpc`
to avoid Go package name collisions and isolate types for each API.

## Versioning

Proto files should follow the name convention: `roomrpc_<type>_v<vers>.proto`. Version is a single sequential number, not a semver.
For example: `roomrpc_sip_v1.proto`.

Corresponding `V<vers>` should be added as a suffix to the service definition and the request/response types
(method name should omit the version, as the versioned service name is part of the method path).

```protobuf
service MyServiceV1 {
rpc DoSomething(DoSomethingV1Request) returns (DoSomethingV1Response);
}
message DoSomethingV1Request {}
message DoSomethingV1Response {}
```
Loading
Loading