Interface RPCSender.Builder
- All Superinterfaces:
RPCProvider.Builder<RPCSender.Builder>
- Enclosing interface:
RPCSender
A builder for an RPC sender which can be obtained from an RPC factory.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Validates the options and target class provided to this builder and constructs the final sender instance in case everything checks out.excludeMethod(@NonNull String name, @NonNull TypeDescriptor methodDescriptor) Excludes the method in the target class that has the given name and method descriptor from being discovered for RPC execution.targetChannel(@NonNull NetworkChannel channel) Sets the singleton channel that will be used to send all RPCs that are using this sender to.targetChannel(@NonNull Supplier<NetworkChannel> channelSupplier) Sets the supplier to use to resolve the network channel to which RPCs using this sender should be sent.targetComponent(@NonNull NetworkComponent networkComponent) Sets the network component to use for obtaining the network channel to send RPCs using this sender to.Methods inherited from interface eu.cloudnetservice.driver.network.rpc.RPCProvider.Builder
dataBufFactory, objectMapper
-
Method Details
-
targetComponent
@NonNull @Contract("_ -> this") @NonNull RPCSender.Builder targetComponent(@NonNull @NonNull NetworkComponent networkComponent) Sets the network component to use for obtaining the network channel to send RPCs using this sender to. For that purpose the first channel of the given component is always used. An exception during RPC execution will be thrown if the first channel of the component every becomes null or closed.- Parameters:
networkComponent- the network component to use the first channel of during RPC execution.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given network component is null.
-
targetChannel
@NonNull @Contract("_ -> this") @NonNull RPCSender.Builder targetChannel(@NonNull @NonNull NetworkChannel channel) Sets the singleton channel that will be used to send all RPCs that are using this sender to. The target channel should not be closed while this sender is in use.- Parameters:
channel- the channel to which all RPCs that are using this sender are sent to.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given channel is null.IllegalArgumentException- if the given channel is closed.
-
targetChannel
@NonNull @Contract("_ -> this") @NonNull RPCSender.Builder targetChannel(@NonNull @NonNull Supplier<NetworkChannel> channelSupplier) Sets the supplier to use to resolve the network channel to which RPCs using this sender should be sent. The given supplier is called every time the channel is needed, and is allowed to change over time. An exception during RPC execution will be thrown if this supplier ever returns null or a channel that is closed.- Parameters:
channelSupplier- the supplier to call to obtain the target channel for RPCs.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given supplier is null.
-
excludeMethod
@NonNull @Contract("_, _ -> this") @NonNull RPCSender.Builder excludeMethod(@NonNull @NonNull String name, @NonNull @NonNull TypeDescriptor methodDescriptor) Excludes the method in the target class that has the given name and method descriptor from being discovered for RPC execution. The method will not be callable using the sender and will not be introspected during build.- Parameters:
name- the name of the method to exclude.methodDescriptor- the descriptor of the method to exclude.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given name or method descriptor is null.
-
build
Validates the options and target class provided to this builder and constructs the final sender instance in case everything checks out.- Returns:
- a new sender instance based on the options provided to this builder.
- Throws:
IllegalArgumentException- if an option provided to this builder does not match.
-