Skip to content

Commit c607a0b

Browse files
authored
[#74]: feat: Connect-RPC service definitions for informer, metrics, resetter, tcp
2 parents 4542a59 + 41847c0 commit c607a0b

5 files changed

Lines changed: 239 additions & 0 deletions

File tree

.github/workflows/buf-lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Buf Lint'
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
lint:
11+
name: 'buf lint'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- name: Set up buf
20+
uses: bufbuild/buf-setup-action@v1
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Lint protofiles
25+
run: buf lint
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
syntax = "proto3";
2+
3+
package informer.v1;
4+
5+
option go_package = "github.com/roadrunner-server/api-go/v6/informer/v1;informerV1";
6+
option php_metadata_namespace = "RoadRunner\\Informer\\DTO\\V1\\GPBMetadata";
7+
option php_namespace = "RoadRunner\\Informer\\DTO\\V1";
8+
9+
// ProcessState mirrors github.com/roadrunner-server/pool/v2/state/process.State —
10+
// one entry per OS-level worker process managed by a plugin. Field widths match
11+
// the existing service.v1.Status convention (int32 pid, float cpu_percent)
12+
// rather than the Go-source int64/float64; PIDs fit in int32 per POSIX, and a
13+
// percentage value comfortably fits in float32.
14+
message ProcessState {
15+
int32 pid = 1;
16+
int64 status = 2;
17+
uint64 num_execs = 3;
18+
int64 created = 4;
19+
uint64 memory_usage = 5;
20+
float cpu_percent = 6;
21+
string command = 7;
22+
string status_str = 8;
23+
}
24+
25+
// JobState mirrors github.com/roadrunner-server/api-plugins/v6/jobs.State —
26+
// one entry per consumer pipeline registered with the jobs plugin.
27+
message JobState {
28+
string pipeline = 1;
29+
string driver = 2;
30+
string queue = 3;
31+
int64 active = 4;
32+
int64 delayed = 5;
33+
int64 reserved = 6;
34+
bool ready = 7;
35+
uint64 priority = 8;
36+
string error_message = 9;
37+
}
38+
39+
message ListPluginsRequest {}
40+
message PluginsList {
41+
repeated string plugins = 1;
42+
}
43+
44+
message GetWorkersRequest {
45+
string plugin = 1;
46+
}
47+
message WorkersList {
48+
repeated ProcessState workers = 1;
49+
}
50+
51+
message GetJobsRequest {
52+
string plugin = 1;
53+
}
54+
message JobsList {
55+
repeated JobState states = 1;
56+
}
57+
58+
message AddWorkerRequest {
59+
string plugin = 1;
60+
}
61+
message RemoveWorkerRequest {
62+
string plugin = 1;
63+
}
64+
65+
message Response {
66+
bool ok = 1;
67+
}
68+
69+
// InformerService exposes introspection RPCs for plugins that manage workers
70+
// (jobs, service, kv, etc.) and lets callers add or remove workers at runtime.
71+
service InformerService {
72+
rpc ListPlugins(ListPluginsRequest) returns (PluginsList) {
73+
option idempotency_level = NO_SIDE_EFFECTS;
74+
}
75+
rpc GetWorkers(GetWorkersRequest) returns (WorkersList) {
76+
option idempotency_level = NO_SIDE_EFFECTS;
77+
}
78+
rpc GetJobs(GetJobsRequest) returns (JobsList) {
79+
option idempotency_level = NO_SIDE_EFFECTS;
80+
}
81+
rpc AddWorker(AddWorkerRequest) returns (Response);
82+
rpc RemoveWorker(RemoveWorkerRequest) returns (Response);
83+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
syntax = "proto3";
2+
3+
package metrics.v1;
4+
5+
option go_package = "github.com/roadrunner-server/api-go/v6/metrics/v1;metricsV1";
6+
option php_metadata_namespace = "RoadRunner\\Metrics\\DTO\\V1\\GPBMetadata";
7+
option php_namespace = "RoadRunner\\Metrics\\DTO\\V1";
8+
9+
// CollectorType enumerates the supported Prometheus collector kinds. The
10+
// numeric values are stable; do not reuse or renumber.
11+
enum CollectorType {
12+
COLLECTOR_TYPE_UNSPECIFIED = 0;
13+
COLLECTOR_TYPE_HISTOGRAM = 1;
14+
COLLECTOR_TYPE_GAUGE = 2;
15+
COLLECTOR_TYPE_COUNTER = 3;
16+
COLLECTOR_TYPE_SUMMARY = 4;
17+
}
18+
19+
// Objective is a single (quantile, error) pair for Prometheus summary
20+
// collectors. proto3 forbids float-keyed maps, so summary objectives are
21+
// modelled as a repeated message rather than `map<double, double>`.
22+
message Objective {
23+
double quantile = 1;
24+
double error = 2;
25+
}
26+
27+
// Collector describes the shape of a single application-defined metric.
28+
// Mirrors github.com/roadrunner-server/metrics/v6.Collector.
29+
message Collector {
30+
string namespace = 1;
31+
string subsystem = 2;
32+
CollectorType type = 3;
33+
string help = 4;
34+
repeated string labels = 5;
35+
repeated double buckets = 6;
36+
repeated Objective objectives = 7;
37+
}
38+
39+
// Metric is a single observation against an already-declared collector.
40+
message Metric {
41+
string name = 1;
42+
double value = 2;
43+
repeated string labels = 3;
44+
}
45+
46+
// NamedCollector wraps a Collector with its registry name; used only by
47+
// Declare to register a new collector under that name.
48+
message NamedCollector {
49+
string name = 1;
50+
Collector collector = 2;
51+
}
52+
53+
message AddRequest { Metric metric = 1; }
54+
message SubRequest { Metric metric = 1; }
55+
message ObserveRequest { Metric metric = 1; }
56+
message SetRequest { Metric metric = 1; }
57+
58+
message DeclareRequest {
59+
NamedCollector collector = 1;
60+
}
61+
62+
message UnregisterRequest {
63+
string name = 1;
64+
}
65+
66+
message Response {
67+
bool ok = 1;
68+
}
69+
70+
// MetricsService exposes runtime metric mutation. All methods are write-side;
71+
// scraping happens on the separate Prometheus HTTP endpoint configured under
72+
// `metrics.address` and is not part of this RPC surface.
73+
service MetricsService {
74+
rpc Add(AddRequest) returns (Response);
75+
rpc Sub(SubRequest) returns (Response);
76+
rpc Observe(ObserveRequest) returns (Response);
77+
rpc Set(SetRequest) returns (Response);
78+
rpc Declare(DeclareRequest) returns (Response);
79+
rpc Unregister(UnregisterRequest) returns (Response);
80+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
syntax = "proto3";
2+
3+
package resetter.v1;
4+
5+
option go_package = "github.com/roadrunner-server/api-go/v6/resetter/v1;resetterV1";
6+
option php_metadata_namespace = "RoadRunner\\Resetter\\DTO\\V1\\GPBMetadata";
7+
option php_namespace = "RoadRunner\\Resetter\\DTO\\V1";
8+
9+
message ListPluginsRequest {}
10+
message PluginsList {
11+
repeated string plugins = 1;
12+
}
13+
14+
message ResetRequest {
15+
string plugin = 1;
16+
}
17+
18+
message Response {
19+
bool ok = 1;
20+
}
21+
22+
// ResetterService exposes the runtime reset surface for plugins that opt into
23+
// the resetter contract (jobs, service, etc.). Listing is read-only; Reset
24+
// triggers a per-plugin lifecycle reset.
25+
service ResetterService {
26+
rpc ListPlugins(ListPluginsRequest) returns (PluginsList) {
27+
option idempotency_level = NO_SIDE_EFFECTS;
28+
}
29+
rpc Reset(ResetRequest) returns (Response);
30+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto3";
2+
3+
package tcp.v1;
4+
5+
option go_package = "github.com/roadrunner-server/api-go/v6/tcp/v1;tcpV1";
6+
option php_metadata_namespace = "RoadRunner\\TCP\\DTO\\V1\\GPBMetadata";
7+
option php_namespace = "RoadRunner\\TCP\\DTO\\V1";
8+
9+
message CloseRequest {
10+
string uuid = 1;
11+
}
12+
13+
message Response {
14+
bool ok = 1;
15+
}
16+
17+
// TCPService exposes runtime control over open TCP connections handled by the
18+
// tcp plugin. Close terminates a single connection identified by its UUID.
19+
service TCPService {
20+
rpc Close(CloseRequest) returns (Response);
21+
}

0 commit comments

Comments
 (0)