Beagle gRPC’s platform support is identical to the platform support of Beagle. Note that Beagle gRPC uses gRPC Swift and requires Swift to be version 5.2 or higher.
This class implements the NetworkClient
protocol using gRPC.
When creating your NetworkClientGRPC you have to provide the following parameters:
Parameter | Description | Required |
---|---|---|
grpcAddress | Address of the gRPC server. The host and port specified here will be used to create the gRPC connection channel. The request URL must have this parameter as prefix or the request will be delegated to the customHttpClient. | ✓ |
customHttpClient | A fallback NetworkClient to handle non gRPC requests. | |
defaultCallOptions | Default values to be used in every gRPC request, for instance, set static headers or define request time limit. Check gRPC Swift for all available options. | |
interceptors | A factory providing interceptors for each RPC. Interceptors allow request and response parts to be observed, mutated or dropped as necessary. |
0.0.0.0
at the port 50051
.
Check the Beagle gRPC Backend page for more information on running your server.Add the dependency to your Podfile
pod 'BeagleGRPC'
After adding Beagle gRPC as a dependency in your project, you can create a NetworkClientGRPC
and set it in your Beagle.dependencies.
import Beagle
import BeagleGRPC
let dependencies = BeagleDependencies()
Beagle.dependencies = dependencies
let baseUrl = "http://0.0.0.0:50051"
dependencies.networkClient = NetworkClientGRPC(
grpcAddress: baseUrl,
customHttpClient: nil
)
dependencies.urlBuilder = UrlBuilder(
baseUrl: URL(string: baseUrl)
)
Now you are ready to connect to your gRPC server.
BeagleScreenViewController(.remote(.init(url: "/home")))
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.