|
| 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` |
0 commit comments