I am using https://github.com/grpc/grpc-swift for inter-process communication. I have a GRPC server written in Go that listens on a unix domain socket, and a macOS app written in Swift that communicates with it over the socket.
Let's say the Go server process is not running and I make an RPC call from my Swift program. The default timeout before the call will fail is 20 seconds, but I would like to shorten it to 1 second. I am trying to do something like this:
let callOptions = CallOptions(timeLimit: .seconds(1)) // <-- Does not compile
This fails with compile error Type 'TimeLimit' has no member 'seconds'.
What is the correct way to decrease the timeout interval for Swift GRPC calls?
As mentioned in the error
TimeLimitdon't have a memberseconds. Thissecondsfunction that you are trying to access is insideTimeAmount. So if you want to use a deadline, you will need to use:here the
.nowis insideNIODeadlineand it as a+operator defined for adding withTimeLimit(check here).and for a timeout:
Note that I'm not an expert in Swift, but I checked in TimeLimitTests.swift and that seems to be the idea.