You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5,7 +5,235 @@ The `transport-grpc` module initializes a new client/server transport implementi
5
5
6
6
**Note:** As a module, transport-grpc is included by default with all OpenSearch installations. However, it remains opt-in and must be explicitly enabled via configuration settings.
7
7
8
-
## GRPC Settings
8
+
## Table of Contents
9
+
10
+
-[transport-grpc](#transport-grpc)
11
+
-[Table of Contents](#table-of-contents)
12
+
-[Contributing to gRPC APIs](#contributing-to-grpc-apis)
13
+
-[Overview](#overview)
14
+
-[Workflow](#workflow)
15
+
-[Step-by-Step Guide](#step-by-step-guide)
16
+
-[Step 0: Submit Fixes to Related Repositories (If Needed)](#step-0-submit-fixes-to-related-repositories-if-needed)
17
+
-[Step 1: Generate Protobuf Definitions from OpenAPI Spec](#step-1-generate-protobuf-definitions-from-openapi-spec)
18
+
-[Step 2: Generate and Package Local Protobuf JAR](#step-2-generate-and-package-local-protobuf-jar)
19
+
-[Step 3: Set Up OpenSearch Repository with Local Protobuf JAR](#step-3-set-up-opensearch-repository-with-local-protobuf-jar)
20
+
-[Step 4: Implement Your Core Contribution](#step-4-implement-your-core-contribution)
21
+
-[A. Adding a Core Query Converter](#a-adding-a-core-query-converter)
22
+
-[B. Extending a gRPC Service](#b-extending-a-grpc-service)
23
+
-[C. Building a Custom Core Interceptor](#c-building-a-custom-core-interceptor)
24
+
-[Step 5: Test Your Implementation](#step-5-test-your-implementation)
-[Thread Pool Monitoring](#thread-pool-monitoring)
33
+
-[Testing](#testing)
34
+
-[Unit Tests](#unit-tests)
35
+
-[Integration Tests](#integration-tests)
36
+
-[Running OpenSearch with gRPC Enabled](#running-opensearch-with-grpc-enabled)
37
+
38
+
## Contributing to gRPC APIs
39
+
40
+
This section is for contributors who want to add new gRPC functionality directly to OpenSearch core (not as an external plugin). This includes adding new query converters, extending gRPC services, or building custom interceptors that will be part of the core distribution.
41
+
42
+
### Overview
43
+
44
+
Contributing to core gRPC may involve working with up to four repositories:
45
+
1.**opensearch-api-specification**: Fix API spec errors (if any are found)
46
+
2.**opensearch-protobufs**: Generate protobuf schemas from the API spec
47
+
3.**OpenSearch**: Implement Java code that uses the protobufs (query converters, services, interceptors)
48
+
4.**documentation-website**: Update public documentation for your gRPC APIs
49
+
50
+
**Note:** If you're only building interceptors (without protobuf changes), you can skip Steps 1-2 and start directly at Step 3.
#### Step 0: Submit Fixes to Related Repositories (If Needed)
80
+
81
+
**Before generating protobufs**, if you discover errors while working with the API:
82
+
83
+
-**API Specification fixes:** If you find errors in the OpenSearch API spec, submit a PR to [opensearch-api-specification](https://github.com/opensearch-project/opensearch-api-specification). After the spec fix is merged, regenerate protobufs to incorporate the corrections.
84
+
-**Documentation fixes:** If you find errors in public documentation, submit a PR to [documentation-website](https://github.com/opensearch-project/documentation-website)
85
+
-**Remember:** The server code (`toXContent`/`fromXContent` methods for REST APIs) is the source of truth. If there's a discrepancy between the API spec and server code, the server is correct.
86
+
87
+
#### Step 1: Generate Protobuf Definitions from OpenAPI Spec
88
+
89
+
**Skip this step if you're only building interceptors without protobuf changes.**
90
+
91
+
Clone the opensearch-protobufs repository and follow the [Protobuf Local Convert Guide](https://github.com/opensearch-project/opensearch-protobufs/blob/main/DEVELOPER_GUIDE.md#protobuf-local-convert-guide) to generate protobufs from the OpenSearch API specification.
#### Step 2: Generate and Package Local Protobuf JAR
99
+
100
+
**Skip this step if you're only building interceptors without protobuf changes.**
101
+
102
+
**Follow the complete guide:**[Generate Java Code and Packaging as a Maven/Gradle Dependency](https://github.com/opensearch-project/opensearch-protobufs/blob/main/DEVELOPER_GUIDE.md#generate-java-code-and-packaging-as-a-mavengradle-dependency)
103
+
104
+
**Summary:**
105
+
1. Build the Java protobuf code with Bazel
106
+
2. Run `./tools/java/package_proto_jar.sh` to create and install the JAR to your local Maven repository
107
+
3. Note the version from `version.properties` (e.g., `1.1.0-SNAPSHOT`)
108
+
109
+
The JAR will be installed to `~/.m2/repository/org/opensearch/protobufs/opensearch-protobufs/`
110
+
111
+
#### Step 3: Set Up OpenSearch Repository with Local Protobuf JAR
112
+
113
+
1.**Clone OpenSearch repository (if not already cloned):**
The dedicated thread pool used for gRPC request processing is registered as a standard OpenSearch thread pool named `grpc`, controlled by the `grpc.netty.executor_count` setting.
65
292
@@ -69,21 +296,21 @@ The gRPC thread pool stats can be monitored using:
69
296
curl -X GET "localhost:9200/_nodes/stats/thread_pool?filter_path=nodes.*.thread_pool.grpc"
Copy file name to clipboardExpand all lines: modules/transport-grpc/spi/README.md
+36-1Lines changed: 36 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,37 @@
2
2
3
3
Service Provider Interface (SPI) for the OpenSearch gRPC transport module. This module provides interfaces and utilities that allow external plugins to extend the gRPC transport functionality.
-[Duplicate Order Values](#duplicate-order-values)
33
+
-[GrpcServiceFactory](#grpcservicefactory-1)
34
+
-[1. Implement Custom Service Factory](#1-implement-custom-service-factory)
35
+
5
36
## Overview
6
37
7
38
The `transport-grpc-spi` module enables plugin developers to:
@@ -11,6 +42,10 @@ The `transport-grpc-spi` module enables plugin developers to:
11
42
- Register gRPC interceptors with explicit ordering
12
43
- Register `BindableService` implementation to the gRPC transport
13
44
45
+
**For contributing to OpenSearch gRPC APIs, see the [Contributing to gRPC APIs](../README.md#contributing-to-grpc-apis) guide in the transport-grpc module.**
46
+
47
+
---
48
+
14
49
## Key Components
15
50
16
51
### QueryBuilderProtoConverter
@@ -400,7 +435,7 @@ Each interceptor must have a unique order value.
400
435
401
436
## GrpcServiceFactory
402
437
403
-
### 1. Implement Custom Query Converter
438
+
### 1. Implement Custom Service Factory
404
439
405
440
Several node resources are exposed to a `GrpcServiceFactory` for use within services such as client, settings, and thread pools.
406
441
A plugin's `GrpcServiceFactory` implementation will be discovered through the SPI registration file and registered on the gRPC transport.
0 commit comments