or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

channel-building.mdindex.mdserver-building.mdssl-tls.mdtransport-providers.md

index.mddocs/

0

# gRPC Netty Shaded

1

2

gRPC Netty Shaded provides a shaded version of the Netty transport implementation for gRPC-Java, designed to avoid dependency conflicts by relocating all Netty classes and resources under the `io.grpc.netty.shaded` namespace. This library includes the complete Netty transport functionality with relocated dependencies, native library support for multiple platforms, and specialized resource transformations to ensure proper shading of Netty's META-INF resources.

3

4

## Package Information

5

6

- **Package Name**: grpc-netty-shaded

7

- **Package Type**: maven

8

- **Language**: Java

9

- **Installation**: `implementation 'io.grpc:grpc-netty-shaded:1.73.0'`

10

- **Group ID**: io.grpc

11

- **Artifact ID**: grpc-netty-shaded

12

13

## Core Imports

14

15

```java

16

import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;

17

import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;

18

import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;

19

import io.grpc.netty.shaded.io.grpc.netty.NettySslContextChannelCredentials;

20

```

21

22

Shaded Netty classes:

23

```java

24

import io.grpc.netty.shaded.io.netty.channel.EventLoopGroup;

25

import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;

26

import io.grpc.netty.shaded.io.netty.channel.ChannelOption;

27

```

28

29

## Basic Usage

30

31

```java

32

import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;

33

import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;

34

import io.grpc.InsecureChannelCredentials;

35

import io.grpc.InsecureServerCredentials;

36

import io.grpc.ManagedChannel;

37

import io.grpc.Server;

38

39

// Create a client channel

40

ManagedChannel channel = NettyChannelBuilder

41

.forAddress("localhost", 9090)

42

.usePlaintext()

43

.build();

44

45

// Create a server

46

Server server = NettyServerBuilder

47

.forPort(9090)

48

.addService(new MyServiceImpl())

49

.build()

50

.start();

51

52

// Cleanup

53

channel.shutdown();

54

server.shutdown();

55

```

56

57

## Architecture

58

59

gRPC Netty Shaded is built around several key components:

60

61

- **Builder Pattern**: `NettyChannelBuilder` and `NettyServerBuilder` provide fluent APIs for configuration

62

- **Shaded Dependencies**: All Netty classes are relocated from `io.netty.*` to `io.grpc.netty.shaded.io.netty.*`

63

- **Transport Providers**: Automatic discovery and registration of Netty transport via ServiceLoader

64

- **SSL/TLS Integration**: Deep integration with Netty's SSL contexts and gRPC's security model

65

- **Platform Support**: Native library support for Linux, macOS, and Windows across multiple architectures

66

67

## Capabilities

68

69

### Channel Building

70

71

Core client-side channel creation and configuration using Netty transport. Provides comprehensive options for connection tuning, security, and advanced Netty features.

72

73

```java { .api }

74

public static NettyChannelBuilder forAddress(String host, int port);

75

public static NettyChannelBuilder forAddress(SocketAddress serverAddress);

76

public static NettyChannelBuilder forTarget(String target);

77

```

78

79

Key configuration methods:

80

```java { .api }

81

public NettyChannelBuilder channelType(Class<? extends Channel> channelType);

82

public NettyChannelBuilder eventLoopGroup(EventLoopGroup eventLoopGroup);

83

public NettyChannelBuilder initialFlowControlWindow(int initialFlowControlWindow);

84

public NettyChannelBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit);

85

```

86

87

[Channel Building](./channel-building.md)

88

89

### Server Building

90

91

Server-side gRPC server creation and configuration using Netty transport. Includes advanced connection management, SSL/TLS setup, and performance tuning options.

92

93

```java { .api }

94

public static NettyServerBuilder forPort(int port);

95

public static NettyServerBuilder forAddress(SocketAddress address);

96

```

97

98

Key configuration methods:

99

```java { .api }

100

public NettyServerBuilder channelType(Class<? extends ServerChannel> channelType);

101

public NettyServerBuilder bossEventLoopGroup(EventLoopGroup group);

102

public NettyServerBuilder workerEventLoopGroup(EventLoopGroup group);

103

public NettyServerBuilder maxConcurrentCallsPerConnection(int maxCalls);

104

```

105

106

[Server Building](./server-building.md)

107

108

### SSL/TLS Configuration

109

110

Comprehensive SSL/TLS support with Netty SSL contexts, optimized for gRPC with proper ALPN negotiation and certificate management.

111

112

```java { .api }

113

public static SslContextBuilder forClient();

114

public static SslContextBuilder forServer(File keyCertChainFile, File keyFile);

115

public static ChannelCredentials create(SslContext sslContext);

116

public static ServerCredentials create(SslContext sslContext);

117

```

118

119

[SSL/TLS Configuration](./ssl-tls.md)

120

121

### Transport Providers

122

123

Automatic discovery and registration of Netty transport providers, including Unix Domain Socket support and internal configuration APIs.

124

125

```java { .api }

126

public boolean isAvailable();

127

public int priority();

128

public NettyChannelBuilder builderForAddress(String name, int port);

129

public NettyServerBuilder builderForPort(int port);

130

```

131

132

[Transport Providers](./transport-providers.md)

133

134

## Types

135

136

```java { .api }

137

public enum NegotiationType {

138

TLS, // TLS ALPN/NPN negotiation for SSL connections

139

PLAINTEXT_UPGRADE, // HTTP UPGRADE from HTTP/1.1 to HTTP/2

140

PLAINTEXT // Direct HTTP/2 plaintext connection

141

}

142

143

public static class LocalSocketPicker {

144

public SocketAddress createSocketAddress(

145

SocketAddress remoteAddress,

146

Attributes attrs);

147

}

148

```