You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/engine-plugins.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ sql:
63
63
| Field | Description |
64
64
|-------|-------------|
65
65
| `name` | Engine name used in `sql[].engine` |
66
-
| `process.cmd` | Command to run: executable path and optional arguments (e.g. `sqlc-engine-external-db --dont-open-wildcard-star`). First token is the executable; remaining tokens are passed as arguments before the RPC method. |
66
+
| `process.cmd` | Command to run: executable path and optional arguments (e.g. `sqlc-engine-external-db --dont-open-wildcard-star`). First token is the executable; remaining tokens are passed as arguments **before** the full RPC method name `/engine.EngineService/Parse`. |
67
67
| `env` | Environment variable names passed to the plugin |
68
68
69
69
Each engine must define either `process` (with `cmd`) or `wasm` (with `url` and `sha256`). See [Configuration reference](../reference/config.md) for the full `engines` schema.
@@ -72,7 +72,7 @@ Each engine must define either `process` (with `cmd`) or `wasm` (with `url` and
72
72
73
73
For an engine with `process.cmd`, sqlc resolves and runs the plugin as follows:
74
74
75
-
1. **Command parsing** — `process.cmd` is split on whitespace. The first token is the executable; any further tokens are passed as arguments, and sqlc appends the RPC method name (`parse`) when invoking the plugin.
75
+
1. **Command parsing** — `process.cmd` is split on whitespace. The first token is the executable; any further tokens are passed as arguments, and sqlc appends the **gRPC full method name** for Parse — the same pattern as for [codegen plugins](plugins.md): `/engine.EngineService/Parse`(the generated client passes this string as the last argv token to the child process).
76
76
77
77
2. **Executable lookup** — The first token is resolved the same way as in the shell:
78
78
- If it contains a path separator (e.g. `/usr/bin/sqlc-engine-external-db` or `./bin/sqlc-engine-external-db`), it is treated as a path. Absolute paths are used as-is; relative paths are taken relative to the **current working directory of the process running sqlc**.
@@ -178,19 +178,22 @@ go build -o sqlc-engine-external-db .
178
178
179
179
## Protocol
180
180
181
-
Process plugins use Protocol Buffers on stdin/stdout:
181
+
Process plugins use Protocol Buffers on stdin/stdout — **no TCP gRPC**, but the same **unary RPC shape** as codegen plugins: sqlc uses the generated `EngineServiceClient` with `process.Runner` implementing `grpc.ClientConnInterface`, so the child receives the **full gRPC method path** as the last command-line argument (like `/plugin.CodegenService/Generate` for codegen).
The definition lives in `protos/engine/engine.proto` (generated Go in `pkg/engine`). After editing the proto, run `make proto-engine-plugin` to regenerate the Go code.
194
+
The Go SDK `engine.Run` dispatches **Parse** when `os.Args[1]` is `/engine.EngineService/Parse` or the legacy shorthand `parse` (for older tooling).
195
+
196
+
The definition lives in `protos/engine/engine.proto` (messages **and** `service EngineService`; generated Go in `pkg/engine`, including `engine_grpc.pb.go` for the client stub). After editing the proto, run `make proto-engine-plugin` to regenerate the Go code.
194
197
195
198
## Example
196
199
@@ -210,7 +213,7 @@ For each `sql[]` block, `sqlc generate` branches on the configured engine: built
0 commit comments