-
-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathmodule-info.java
More file actions
73 lines (70 loc) · 2.21 KB
/
module-info.java
File metadata and controls
73 lines (70 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
import org.slf4j.bridge.SLF4JBridgeHandler;
/**
* Native gRPC extension for Jooby.
*
* <p>This module allows you to run strictly-typed gRPC services alongside standard Jooby HTTP
* routes on the exact same port. It completely bypasses standard HTTP/1.1 pipelines in favor of a
* highly optimized, reactive, native interceptor tailored for HTTP/2 multiplexing and trailing
* headers.
*
* <h3>Usage</h3>
*
* <p>gRPC requires HTTP/2. Ensure your Jooby application is configured to use a supported server
* with HTTP/2 enabled.
*
* <pre>{@code
* import io.jooby.Jooby;
* import io.jooby.ServerOptions;
* import io.jooby.grpc.GrpcModule;
* * public class App extends Jooby {
* {
* setServerOptions(new ServerOptions().setHttp2(true).setSecurePort(8443));
* * // Install the extension and register your services
* install(new GrpcModule(new GreeterService()));
* }
* }
* }</pre>
*
* <h3>Dependency Injection</h3>
*
* <p>If your gRPC services require external dependencies (like repositories or configuration), you
* can register the service classes instead of instances. The module will automatically provision
* them using Jooby's DI registry (e.g., Guice, Spring) during the application startup phase.
*
* <pre>{@code
* public class App extends Jooby {
* {
* install(new GuiceModule());
* * // Pass the class reference. Guice will instantiate it!
* install(new GrpcModule(GreeterService.class));
* }
* }
* }</pre>
*
* *
*
* <p><strong>Note:</strong> gRPC services are inherently registered as Singletons. Ensure your
* service implementations are thread-safe and do not hold request-scoped state in instance
* variables.
*
* <h3>Logging</h3>
*
* <p>gRPC internally uses {@code java.util.logging}. This module automatically installs the {@link
* SLF4JBridgeHandler} to redirect all internal gRPC logs to your configured SLF4J backend.
*/
module io.jooby.grpc {
exports io.jooby.grpc;
requires io.jooby;
requires static org.jspecify;
requires typesafe.config;
requires org.slf4j;
requires jul.to.slf4j;
requires io.grpc;
requires io.grpc.inprocess;
requires io.grpc.stub;
}