Skip to content

Commit 806e08f

Browse files
committed
Fork of bergundy/nexus-proto-annotations
0 parents  commit 806e08f

7 files changed

Lines changed: 424 additions & 0 deletions

File tree

README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# nexus-proto-annotations
2+
3+
Protobuf annotations for Nexus services and operations.
4+
5+
## Install
6+
7+
### With buf
8+
9+
Add a dependency to your `buf.yaml` file:
10+
11+
```
12+
deps:
13+
- buf.build/nexus-rpc/nexus
14+
```
15+
16+
### Unmanaged
17+
18+
Copy the `nexus` directory from this repository and include it as one of the sources to `protoc`.
19+
20+
## Usage
21+
22+
### Service
23+
24+
#### (nexus.v1.service).name
25+
26+
`string`
27+
28+
Defines the Nexus Service name. Defaults to the proto Service full name.
29+
30+
**Example:**
31+
32+
```protobuf
33+
syntax = "proto3";
34+
35+
package example.v1;
36+
37+
import "nexus/v1/options.proto";
38+
39+
service ExampleService {
40+
option (nexus.v1.service).name = "example.v1.Example";
41+
}
42+
```
43+
44+
#### (nexus.v1.service).tags
45+
46+
`repeated string`
47+
48+
Tags a Nexus Service. Used by code generators for Service inclusion and exclusion.
49+
50+
**Example:**
51+
52+
```protobuf
53+
syntax = "proto3";
54+
55+
package example.v1;
56+
57+
import "nexus/v1/options.proto";
58+
59+
service ExampleService {
60+
option (nexus.v1.service).tags = "tag1";
61+
option (nexus.v1.service).tags = "tag2";
62+
}
63+
```
64+
65+
### Method
66+
67+
#### (nexus.v1.operation).name
68+
69+
`string`
70+
71+
Defines the Nexus Operation name. Defaults to the proto Method name.
72+
73+
**Example:**
74+
75+
```protobuf
76+
syntax = "proto3";
77+
78+
package example.v1;
79+
80+
import "nexus/v1/options.proto";
81+
82+
service ExampleService {
83+
rpc Foo(FooInput) returns (FooResponse) {
84+
option (nexus.v1.operation).name = "foo";
85+
}
86+
}
87+
```
88+
89+
#### (nexus.v1.operation).tags
90+
91+
`repeated string`
92+
93+
Tags a Nexus Service. Used by code generators for Operation inclusion and exclusion.
94+
95+
**Example:**
96+
97+
```protobuf
98+
syntax = "proto3";
99+
100+
package example.v1;
101+
102+
import "nexus/v1/options.proto";
103+
104+
service ExampleService {
105+
rpc Foo(FooInput) returns (FooResponse) {
106+
option (nexus.v1.operation).tags = "tag1";
107+
option (nexus.v1.operation).tags = "tag2";
108+
}
109+
}
110+
```
111+
112+
## Contribute
113+
114+
### Generate Go files
115+
116+
Any change in the proto definitions must be reflected in the associated Go package and commited. Run the following command on change:
117+
118+
`buf generate`
119+
120+
121+
### Push to the buf registy
122+
123+
`buf push`

buf.gen.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: v2
2+
clean: true
3+
managed:
4+
enabled: true
5+
override:
6+
- file_option: go_package_prefix
7+
value: github.com/nexus-rpc/nexus-proto-annotations/go
8+
plugins:
9+
- remote: buf.build/protocolbuffers/go
10+
out: go
11+
opt:
12+
- paths=source_relative

buf.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: v2
2+
modules:
3+
- name: buf.build/nexus-rpc/nexus
4+
path: .
5+
lint:
6+
use:
7+
- BASIC
8+
except:
9+
- FIELD_NOT_REQUIRED
10+
- PACKAGE_NO_IMPORT_CYCLE
11+
breaking:
12+
use:
13+
- FILE
14+
except:
15+
- EXTENSION_NO_DELETE
16+
- FIELD_SAME_DEFAULT

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/nexus-rpc/nexus-proto-annotations
2+
3+
go 1.25.4
4+
5+
require google.golang.org/protobuf v1.36.1

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
2+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
4+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5+
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
6+
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

0 commit comments

Comments
 (0)