Skip to content

Commit

Permalink
Allow binding to a socket address via server builder (#1686)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
glbrntt committed Oct 25, 2023
1 parent ef5a0fe commit fdf0a81
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/GRPC/ServerBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,23 @@ extension Server {
return Server.start(configuration: self.configuration)
}

public func bind(to socketAddress: SocketAddress) -> EventLoopFuture<Server> {
self.configuration.target = .socketAddress(socketAddress)
self.configuration.tlsConfiguration = self.maybeTLS
return Server.start(configuration: self.configuration)
}

public func bind(vsockAddress: VsockAddress) -> EventLoopFuture<Server> {
self.configuration.target = .vsockAddress(vsockAddress)
self.configuration.tlsConfiguration = self.maybeTLS
return Server.start(configuration: self.configuration)
}

public func bind(to target: BindTarget) -> EventLoopFuture<Server> {
self.configuration.target = target
self.configuration.tlsConfiguration = self.maybeTLS
return Server.start(configuration: self.configuration)
}
}
}

Expand Down

0 comments on commit fdf0a81

Please sign in to comment.