Skip to content

Commit fdf0a81

Browse files
authored
Allow binding to a socket address via server builder (#1686)
Motivation: Users can bind to a socket address if they use the server config but not the builder. Modifications: - Add API to connect to a socket address or bind target via the server builder API Result: More convenient APIs
1 parent ef5a0fe commit fdf0a81

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sources/GRPC/ServerBuilder.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,23 @@ extension Server {
6262
return Server.start(configuration: self.configuration)
6363
}
6464

65+
public func bind(to socketAddress: SocketAddress) -> EventLoopFuture<Server> {
66+
self.configuration.target = .socketAddress(socketAddress)
67+
self.configuration.tlsConfiguration = self.maybeTLS
68+
return Server.start(configuration: self.configuration)
69+
}
70+
6571
public func bind(vsockAddress: VsockAddress) -> EventLoopFuture<Server> {
6672
self.configuration.target = .vsockAddress(vsockAddress)
6773
self.configuration.tlsConfiguration = self.maybeTLS
6874
return Server.start(configuration: self.configuration)
6975
}
76+
77+
public func bind(to target: BindTarget) -> EventLoopFuture<Server> {
78+
self.configuration.target = target
79+
self.configuration.tlsConfiguration = self.maybeTLS
80+
return Server.start(configuration: self.configuration)
81+
}
7082
}
7183
}
7284

0 commit comments

Comments
 (0)