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

Clarify on JSONRPC format #13825

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
Clarify on JSONRPC format
  • Loading branch information
anthony-c-martin committed Apr 8, 2024
commit 230f93b076ba355f766dbb4e2f8013f0efb8c378
21 changes: 16 additions & 5 deletions docs/experimental/jsonrpc-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ The `jsonrpc` command allows you to run the Bicep CLI in a JSONRPC server mode.

This makes it possible to build libraries which interact with Bicep files programatically in non-.NET languages.

## Format
The wire format used to send/recieve input/output is header-delimited, meaning the following format is expected, where `\r` and `\n` refer to carriage return and line feed characters:

`Content-Length: <length>\r\n\r\n<message>\r\n\r\n`

* `<length>` is the length of the `<message>` string, including the trailing `\r\n\r\n`.
* `<message>` is the raw JSON message.

### Example
`Content-Length: 72\r\n\r\n{"jsonrpc": "2.0", "id": 0, "method": "bicep/version", "params": {}}\r\n\r\n`

## Usage (named pipe)
`bicep jsonrpc --pipe <named_pipe>`

Runs the JSONRPC server connected to a named pipe.
Connects to an existing named pipe as a JSONRPC client. See here for some examples: [C#](https://github.com/Azure/bicep/blob/096c32f9d5c42bfb85dff550f72f3fe16f8142c7/src/Bicep.Cli.IntegrationTests/JsonRpcCommandTests.cs#L24-L50) and [node.js](https://github.com/anthony-c-martin/bicep-node/blob/4769e402f2d2c1da8d27df86cb3d62677e7a7456/src/utils/jsonrpc.ts#L117-L151).

### Arguments
`<named_pipe>` A named pipe to connect the JSONRPC server to.
`<named_pipe>` An existing named pipe to connect the JSONRPC client to.

### Examples
#### Connecting to a named pipe (OSX/Linux)
Expand All @@ -23,10 +34,10 @@ Runs the JSONRPC server connected to a named pipe.
## Usage (TCP socket)
`bicep jsonrpc --socket <tcp_socket>`

Runs the JSONRPC server connected to a TCP socket.
Connects to an existing TCP socket as a JSONRPC client.

### Arguments
`<tcp_socket>` A socket number to connect the JSONRPC server to.
`<tcp_socket>` A socket number to connect the JSONRPC client to.

### Examples
#### Connecting to a TCP socket
Expand Down Expand Up @@ -200,4 +211,4 @@ See [`jsonrpc.test.ts`](../../src/Bicep.Cli.E2eTests/src/jsonrpc.test.ts) for an
```

## Raising bugs or feature requests
Please raise bug reports or feature requests under [Bicep Issues](https://github.com/Azure/bicep/issues) as usual.
Please raise bug reports or feature requests under [Bicep Issues](https://github.com/Azure/bicep/issues) as usual.
Loading