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
refactor: pre-generate protobuf modules to remove protoc build-time dep
Downstream consumers no longer need protoc installed to compile the
SDK. lib/longbridge/_protos.ex now ships the pre-compiled output of
mix protox.generate (run via the new mix gen_protos alias).
- pre-generate Longbridge.{Control,Quote,Trade}.V1.* into _protos.ex
- drop protos/ from the Hex package files list (not needed by users)
- exclude _protos.ex from mix format and ex_dna (generated code)
- add mix gen_protos alias for regenerating after a .proto change
- remove protoc build-time requirement from README install docs
- document the new workflow in AGENTS.md
|`Longbridge.Protos`|Pre-generated protobuf modules (`lib/longbridge/_protos.ex`) for `Longbridge.{Control,Quote,Trade}.V1.*` structs. Regenerate with `mix gen_protos` (requires `protoc`, dev-only). |
30
30
|`Longbridge.QuoteContext`| Public API for the quote endpoint — 20+ typed methods. |
31
31
|`Longbridge.SharelistContext`| Community sharelist management. HTTP-only. |
32
32
|`Longbridge.ScreenerContext`| Stock-screener strategies, indicator search, AI recommendations. HTTP-only. Mirrors `ScreenerContext` in `longbridge/openapi-go` and `longbridge/openapi`. |
@@ -61,7 +61,7 @@ mix format # auto-format
61
61
mix docs # generate ExDoc HTML
62
62
```
63
63
64
-
`protoc`must be on `$PATH` (Elixir `protox` shells out to it). On macOS: `brew install protobuf`.
64
+
`protoc`is **only** required when regenerating protobuf modules (`mix gen_protos`), not for normal `mix compile`/`mix test`. On macOS: `brew install protobuf`. The generated modules ship pre-compiled in `lib/longbridge/_protos.ex`; downstream consumers never need `protoc`.
65
65
66
66
## Architecture invariants
67
67
@@ -83,7 +83,7 @@ mix docs # generate ExDoc HTML
83
83
-**No `IO.puts` / `IO.inspect` in library code.** Use `Logger` (the connection module already requires it). This includes temporary debugging — use `Logger.debug` and remove before committing.
84
84
-**Specs for public functions.**`@spec` for every public function. Prefer concrete types (`non_neg_integer()`, `:atom | binary()`) over generic ones (`term()`, `any()`).
85
85
-**Match on the struct shape, not just the variable.** When a function expects a `Header.t()`, pattern-match `def f(%Header{} = h, ...)` so Dialyzer can prove the type and you get a clear error if a caller passes the wrong shape.
86
-
-**One `use Protox` only.**The `use Protox, files: [...], paths: [...]` macro call lives **exclusively** in `lib/longbridge/_protos.ex`. The macro generates `Longbridge.{Control,Quote,Trade}.V1.*` modules and the file's name (and `defmodule Longbridge.Protos`) are load-bearing for the generated module names — renaming either one will require updating the `Q.`, `T.`, and `Ctrl.` aliases in `quote_context.ex`, `trade_context.ex`, and `connection.ex`.
86
+
-**Protobuf modules are pre-generated.**`lib/longbridge/_protos.ex` contains the pre-compiled output of `mix protox.generate` (run via the `mix gen_protos` alias). It generates `Longbridge.{Control,Quote,Trade}.V1.*` modules. Do **not** switch back to `use Protox, files: [...]` — that would reintroduce the `protoc` build-time dependency for downstream consumers. The file's name and `defmodule Longbridge.Protos` are load-bearing for the generated module names — renaming either one will require updating the `Q.`, `T.`, and `Ctrl.` aliases in `quote_context.ex`, `trade_context.ex`, and `connection.ex`. To regenerate after a `.proto` change: `mix gen_protos` (requires `protoc`).
# 4. regenerate the pre-compiled modules (requires protoc)
634
+
mix gen_protos
635
+
# 5. mix compile && mix test
640
636
```
641
637
638
+
The protobuf Elixir modules are **pre-generated** into `lib/longbridge/_protos.ex` (via `mix protox.generate`), so downstream consumers do **not** need `protoc` installed. `protoc` is only required for maintainers regenerating the modules after a proto change. Run `mix gen_protos` to regenerate.
639
+
642
640
Don't hand-edit files under `protos/` — the next sync will clobber your changes.
0 commit comments