No description
  • Rust 98.5%
  • JavaScript 1.3%
  • Shell 0.2%
Find a file
faicel 45a353aa7d
All checks were successful
Create tag on dev / rust-crate-checks (push) Successful in 4m27s
Create tag on dev / checks (push) Successful in 0s
Create tag on dev / node-checks (push) Successful in 10s
Create tag on dev / js-checks (push) Successful in 0s
Create tag on dev / tag_prerelease (push) Successful in 7s
Create tag on dev / tag (push) Successful in 0s
Publish release on tag (grpc_server) / rust-crate-checks (push) Successful in 4m49s
Publish release on tag (grpc_server) / checks (push) Successful in 0s
Publish release on tag (grpc_server) / release (push) Successful in 4m31s
Merge pull request 'update db_handler' (#12) from fix/proto-dedup-shared-crate into dev
Reviewed-on: #12
2026-09-22 07:26:09 +00:00
.cargo update workflow 2026-09-06 12:35:22 +02:00
.forgejo perf(ci): mark the generated clients side-effect free and shrink contract re-exports 2026-09-21 13:59:18 +02:00
homeiot-grpc-proto update version 2026-09-21 14:49:20 +02:00
scripts fix(ts-client): export generated service clients from the package barrel 2026-09-20 23:07:49 +02:00
src perf(ci): mark the generated clients side-effect free and shrink contract re-exports 2026-09-21 13:59:18 +02:00
tests fix(proto): deduplicate Empty via google.protobuf.Empty 2026-09-20 22:48:30 +02:00
.gitignore chore(release): prepare the 0.5.0 coordinated release with the shared proto crate 2026-09-20 23:08:40 +02:00
Cargo.lock update db_handler 2026-09-22 09:14:03 +02:00
Cargo.toml update db_handler 2026-09-22 09:14:03 +02:00
CHANGELOG.md update db_handler 2026-09-22 09:14:03 +02:00
config.example.json init 2026-03-07 13:57:13 +01:00
Cross.toml init 2026-03-07 13:57:13 +01:00
deny.toml fix(deny): clarify the proto crate license against the shared custom LICENSE 2026-09-21 09:33:55 +02:00
LICENSE init 2026-03-07 13:57:13 +01:00
package-lock.json update workflow 2026-09-06 12:35:22 +02:00
package.json init 2026-03-07 13:57:13 +01:00
README.md fix(auth): remove the dead sensor consumer class 2026-09-18 23:56:18 +02:00

grpc_server

Important

The canonical repository for this project lives on Forgejo: https://code.bhk-itsolutions.com/homeiot/grpc_server.git. This GitHub repository is only a mirror and is not the primary git remote.

gRPC / gRPC-Web server for the Home IoT project. Exposes installation services (web client, bridge) and event broadcasting.

Prerequisites

  • Rust (edition 2021, stable toolchain)
  • Forgejo registry — This crate depends on db_handler, which is published on a private Forgejo Cargo registry. You need access to that registry to build and run.
  • Configuration file (see below)

Forgejo registry setup

The registry is declared in .cargo/config.toml (sparse index URL). To authenticate:

  1. Obtain a token with read access to the Forgejo package registry (e.g. from your Forgejo instance: User → Settings → Access Tokens, or from the project/package permissions).
  2. Log in to the registry:
    cargo login --registry forgejo <YOUR_TOKEN>
    
    Alternatively, set the token in your environment so it is not stored in the Cargo credentials file:
    export CARGO_REGISTRIES_FORGEJO_TOKEN="<YOUR_TOKEN>"
    
  3. Run cargo build or cargo test as usual; Cargo will use the token to fetch db_handler from the registry.

Without valid credentials, cargo build will fail when resolving the db_handler dependency.

Configuration

Configuration is read by the db_handler crate via the CONFIG_FILE environment variable (path to a JSON file).

  • Copy the example file:
    cp config.example.json config.json
    (or create a config file at the path of your choice.)

  • Adjust the fields (SQLite database URL, InfluxDB, etc.) in that file. The structure is defined by db_handler (e.g. primary_db_url, history_db_url, history_db_org, history_db_token).

  • Run the server or tests with CONFIG_FILE set:

    export CONFIG_FILE=/path/to/config.json
    ./scripts/run.sh
    

A secret-free example is provided in config.example.json.

Server bind (loopback-only plaintext)

The plaintext gRPC listener is loopback-only by design: it binds to 127.0.0.1 (or ::1) and refuses to start on any non-loopback host with an explicit error. Direct exposure of this process to a LAN or the internet is impossible by construction; transport encryption is the responsibility of an identified on-host TLS terminator (nginx) that proxies to the loopback port. frontTs and bridge therefore connect via https://<host> through nginx — never directly to this process.

  • GRPC_PORT — listening port (default 50051).
  • GRPC_HOST — bind host; only 127.0.0.1 (default) or ::1 are accepted, any other value aborts startup.

Build

cargo build
# Release
cargo build --release
# or
./scripts/build.sh

Tests

All tests (unit, integration, doc-tests) are run with:

./scripts/tests.sh

The script uses CONFIG_FILE=config_test.json (relative to the project root). Create it from the example if needed: cp config.example.json config_test.json, then run the script. Or set CONFIG_FILE to another path and run cargo test (or the script) as needed.

For integration test details (timeouts, concurrency, CORS, load), see tests/README.md.

Running

export CONFIG_FILE=/path/to/config.json
./scripts/run.sh
# or for development
./scripts/runDev.sh

Project structure

  • src/ — Source code: main.rs, lib (shared modules)
    • broadcaster/ — Event broadcasting
    • common/ — Errors, response channels, shared types
    • install/ — Installation: web_client (gRPC-Web), bridge
  • proto/ — .proto files (gRPC definitions)
  • tests/ — Integration tests and test documentation
  • scripts/ — Build, test, run, and deploy scripts

License

See LICENSE (Personal Use Only — Non-Commercial).