@marleena/trb-proto 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -54
- package/gen/js-ts/README.md +72 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,75 +1,43 @@
|
|
|
1
1
|
# TrB proto
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Protobuf/gRPC-контракты сервисов TrB и сгенерированный код для нескольких языков.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
| Язык | Артефакт | Документация |
|
|
6
|
+
|------|----------|--------------|
|
|
7
|
+
| Go | модуль `github.com/Mar1eena/trb_proto` | [gen/go/README.md](gen/go/README.md) |
|
|
8
|
+
| JavaScript / TypeScript | npm [`@marleena/trb-proto`](https://www.npmjs.com/package/@marleena/trb-proto) | [gen/js-ts/README.md](gen/js-ts/README.md) |
|
|
9
|
+
| Python | PyPI [`trb-proto`](https://pypi.org/project/trb-proto/) | [gen/python/README.md](gen/python/README.md) |
|
|
8
10
|
|
|
9
11
|
## Генерация
|
|
10
12
|
|
|
11
|
-
Нужны `protoc` и плагины: `protoc-gen-go`, `protoc-gen-go-grpc`, `protoc-gen-grpc-gateway`, `protoc-gen-js`, `protoc-gen-grpc-web
|
|
13
|
+
Нужны `protoc` и плагины: `protoc-gen-go`, `protoc-gen-go-grpc`, `protoc-gen-grpc-gateway`, `protoc-gen-js`, `protoc-gen-grpc-web`, `grpc_tools` (Python).
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
16
|
make gene
|
|
15
17
|
```
|
|
16
18
|
|
|
17
|
-
Собирает Go, JS/TS и descriptor set. Google API-аннотации для JS генерируются отдельно, чтобы не попасть в `gen/go`.
|
|
19
|
+
Собирает Go, JS/TS, Python (indicators) и descriptor set (`gen/desc/trb_protos.pb`). Google API-аннотации для JS генерируются отдельно, чтобы не попасть в `gen/go`.
|
|
18
20
|
|
|
19
21
|
Другие цели: `make desc`, `make buf`.
|
|
20
22
|
|
|
21
|
-
##
|
|
23
|
+
## Сервисы
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
npm install @marleena/trb-proto
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { MessageRequest } from '@marleena/trb-proto/example/Example_pb';
|
|
29
|
-
import { exampleClient } from '@marleena/trb-proto/example/ExampleServiceClientPb';
|
|
30
|
-
|
|
31
|
-
const client = new exampleClient('https://api.example.com');
|
|
32
|
-
const req = new MessageRequest();
|
|
33
|
-
req.setText('hello');
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Python
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
pip install trb-proto
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
```python
|
|
43
|
-
from indicators import indicators_pb2 as pb
|
|
44
|
-
from indicators import indicators_pb2_grpc
|
|
45
|
-
|
|
46
|
-
stub = indicators_pb2_grpc.IndicatorsStub(channel)
|
|
47
|
-
stub.ListSupported(pb.ListSupportedRequest())
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Сервисы:
|
|
25
|
+
Исходники proto — в `services/`.
|
|
51
26
|
|
|
52
|
-
|
|
27
|
+
**Внешние контракты** (`services/api/`): `api/tinvest` — зеркало T-Invest API.
|
|
53
28
|
|
|
54
|
-
|
|
29
|
+
**Свои сервисы:**
|
|
55
30
|
|
|
56
|
-
|
|
31
|
+
| Каталог | gRPC-сервисы |
|
|
32
|
+
|---------|--------------|
|
|
33
|
+
| `clickhouse` | `ClickHouse_Admin`, `ClickHouse` |
|
|
34
|
+
| `postgresql` | `PostgreSQL_Admin`, `PostgreSQL` |
|
|
35
|
+
| `nats` | `Nats_Admin` |
|
|
36
|
+
| `indicators` | `Indicators` |
|
|
37
|
+
| `test` | `Test` |
|
|
57
38
|
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
`postgresql` (`trb.postgresql.v1.PostgreSQL`) — цели планировщика: `ListSchedulerTargets`, `SyncSchedulerTargets`.
|
|
61
|
-
|
|
62
|
-
`PostgreSQL_Admin` — DDL, мониторинг и произвольные запросы: базы, схемы, таблицы, колонки, индексы, VACUUM/ANALYZE, процессы, блокировки.
|
|
63
|
-
|
|
64
|
-
`nats` (`trb.nats.v1.Nats`) — управление JetStream.
|
|
65
|
-
|
|
66
|
-
`test` (`trb.test.v1.Test`) — тестовый оркестратор.
|
|
67
|
-
|
|
68
|
-
## CI/CD
|
|
69
|
-
|
|
70
|
-
[Release](.github/workflows/release.yml) на коммит `v1.2.3` в `main`: npm (если версии ещё нет), PyPI `trb-proto` и `POST /fetch/...` на [pkg.go.dev](https://pkg.go.dev/github.com/Mar1eena/trb_proto).
|
|
71
|
-
|
|
72
|
-
Trusted Publisher: npm — GitHub `Mar1eena` / `TrB_proto` / `release.yml`; PyPI — trusted publisher для `trb-proto` (GitHub Actions OIDC).
|
|
39
|
+
`clickhouse` — `admin.proto` и `clickhouse.proto`.
|
|
40
|
+
`postgresql` — `admin.proto` (DDL, мониторинг) и `postgresql.proto` (планировщик: `ListSchedulerTargets`, `SyncSchedulerTargets`).
|
|
73
41
|
|
|
74
42
|
## Релиз
|
|
75
43
|
|
|
@@ -77,8 +45,18 @@ Trusted Publisher: npm — GitHub `Mar1eena` / `TrB_proto` / `release.yml`; PyPI
|
|
|
77
45
|
make rel
|
|
78
46
|
```
|
|
79
47
|
|
|
80
|
-
Собирает proto, поднимает patch
|
|
48
|
+
Собирает proto, поднимает patch-версию в `package.json` / `pyproject.toml`, коммитит с сообщением `v1.2.3` и пушит в `main`.
|
|
81
49
|
|
|
82
50
|
Другой шаг версии: `make rel PART=minor` или `PART=major`.
|
|
83
51
|
|
|
84
52
|
Для коммита нужны `user.name` и `user.email` в Git.
|
|
53
|
+
|
|
54
|
+
## CI/CD
|
|
55
|
+
|
|
56
|
+
[Release](.github/workflows/release.yml) на коммит `v1.2.3` в `main`:
|
|
57
|
+
|
|
58
|
+
- npm — `@marleena/trb-proto` (если версии ещё нет)
|
|
59
|
+
- PyPI — `trb-proto`
|
|
60
|
+
- Go — обновление [pkg.go.dev](https://pkg.go.dev/github.com/Mar1eena/trb_proto)
|
|
61
|
+
|
|
62
|
+
Подробности публикации — в README соответствующего языка.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# TrB proto — JavaScript / TypeScript
|
|
2
|
+
|
|
3
|
+
Сгенерированные protobuf-сообщения и gRPC-Web клиенты.
|
|
4
|
+
|
|
5
|
+
## Установка
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @marleena/trb-proto
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Пакет публикуется на npm при релизе (`make rel` → GitHub Actions → `@marleena/trb-proto@x.y.z`).
|
|
12
|
+
|
|
13
|
+
## Импорты
|
|
14
|
+
|
|
15
|
+
Пути соответствуют каталогам в `gen/js-ts/`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { ListCandlesRequest } from '@marleena/trb-proto/clickhouse/clickhouse_pb';
|
|
19
|
+
import { ClickhouseServiceClient } from '@marleena/trb-proto/clickhouse/ClickhouseServiceClientPb';
|
|
20
|
+
|
|
21
|
+
import { ComputeRequest } from '@marleena/trb-proto/indicators/indicators_pb';
|
|
22
|
+
import { IndicatorsServiceClient } from '@marleena/trb-proto/indicators/IndicatorsServiceClientPb';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
T-Invest API:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { SharesResponse } from '@marleena/trb-proto/api/tinvest/instruments_pb';
|
|
29
|
+
import { InstrumentsServiceClient } from '@marleena/trb-proto/api/tinvest/InstrumentsServiceClientPb';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Пример: gRPC-Web
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { ClickhouseServiceClient } from '@marleena/trb-proto/clickhouse/ClickhouseServiceClientPb';
|
|
36
|
+
import { ListCandlesRequest } from '@marleena/trb-proto/clickhouse/clickhouse_pb';
|
|
37
|
+
|
|
38
|
+
const client = new ClickhouseServiceClient('http://localhost:8081');
|
|
39
|
+
|
|
40
|
+
const req = new ListCandlesRequest();
|
|
41
|
+
req.setUid('…');
|
|
42
|
+
req.setInterval(5);
|
|
43
|
+
|
|
44
|
+
client.listCandles(req, {}, (err, resp) => {
|
|
45
|
+
if (err) throw err;
|
|
46
|
+
console.log(resp.getCandlesList());
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Envoy на `:8081` транскодирует HTTP/JSON ↔ gRPC (см. `TrB_backend/configs/envoy/envoy.yaml`).
|
|
51
|
+
|
|
52
|
+
## Зависимости пакета
|
|
53
|
+
|
|
54
|
+
- `google-protobuf`
|
|
55
|
+
- `grpc-web`
|
|
56
|
+
|
|
57
|
+
## Локальная разработка
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# в TrB_proto
|
|
61
|
+
make gene
|
|
62
|
+
npm link
|
|
63
|
+
|
|
64
|
+
# во frontend-проекте
|
|
65
|
+
npm link @marleena/trb-proto
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Trusted Publisher (npm)
|
|
69
|
+
|
|
70
|
+
GitHub `Mar1eena` / `TrB_proto` / workflow `release.yml`.
|
|
71
|
+
|
|
72
|
+
[← Корневой README](../../README.md)
|