mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 03:29:42 +01:00
Make withServer provide the actual port (#29)
* Make withServer provide the actual port Again, useful to make a server listen on any available port by giving it port zero (for testing). * Re-introduce check on server port * Add port field to Server * Style: Remove unneeded newline * Revert changes in tests
This commit is contained in:
parent
ab8ec43d17
commit
e0c567ec55
1 changed files with 4 additions and 2 deletions
|
@ -52,6 +52,7 @@ import qualified Network.GRPC.Unsafe.Security as C
|
|||
data Server = Server
|
||||
{ serverGRPC :: GRPC
|
||||
, unsafeServer :: C.Server
|
||||
, listeningPort :: Port
|
||||
, serverCQ :: CompletionQueue
|
||||
-- ^ CQ used for receiving new calls.
|
||||
, serverCallCQ :: CompletionQueue
|
||||
|
@ -160,7 +161,7 @@ startServer grpc conf@ServerConfig{..} =
|
|||
let e = serverEndpoint conf
|
||||
server <- C.grpcServerCreate args C.reserved
|
||||
actualPort <- addPort server conf
|
||||
when (actualPort /= unPort port) $
|
||||
when (unPort port > 0 && actualPort /= unPort port) $
|
||||
error $ "Unable to bind port: " ++ show port
|
||||
cq <- createCompletionQueue grpc
|
||||
grpcDebug $ "startServer: server CQ: " ++ show cq
|
||||
|
@ -182,7 +183,8 @@ startServer grpc conf@ServerConfig{..} =
|
|||
forks <- newTVarIO S.empty
|
||||
shutdown <- newTVarIO False
|
||||
ccq <- createCompletionQueue grpc
|
||||
return $ Server grpc server cq ccq ns ss cs bs conf forks shutdown
|
||||
return $ Server grpc server (Port actualPort) cq ccq ns ss cs bs conf forks
|
||||
shutdown
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue