Class DefaultRPCSenderBuilder

java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.sender.DefaultRPCSenderBuilder
All Implemented Interfaces:
RPCProvider.Builder<RPCSender.Builder>, RPCSender.Builder

public final class DefaultRPCSenderBuilder extends Object implements RPCSender.Builder
The default implementation of an RPC sender builder.
Since:
4.0
  • Field Details

  • Constructor Details

    • DefaultRPCSenderBuilder

      public DefaultRPCSenderBuilder(@NonNull @NonNull RPCFactory sourceFactory, @NonNull @NonNull RPCClassMetadata classMetadata, @NonNull @NonNull DataBufFactory dataBufFactory, @NonNull @NonNull ObjectMapper objectMapper)
      Constructs a new builder instance for the target class (given by the class metadata) and the default data buf factory / object mapper from the source RPC factory.
      Parameters:
      sourceFactory - the rpc factory that constructed this object.
      classMetadata - the metadata for the target class.
      dataBufFactory - the default data buf factory of the source RPC factory.
      objectMapper - the default object mapper of the source RPC factory.
      Throws:
      NullPointerException - if the given class meta, data buf factory or object mapper is null.
  • Method Details

    • targetComponent

      @NonNull public 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.
      Specified by:
      targetComponent in interface RPCSender.Builder
      Parameters:
      networkComponent - the network component to use the first channel of during RPC execution.
      Returns:
      this builder, for chaining.
    • targetChannel

      @NonNull public 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.
      Specified by:
      targetChannel in interface RPCSender.Builder
      Parameters:
      channel - the channel to which all RPCs that are using this sender are sent to.
      Returns:
      this builder, for chaining.
    • targetChannel

      @NonNull public 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.
      Specified by:
      targetChannel in interface RPCSender.Builder
      Parameters:
      channelSupplier - the supplier to call to obtain the target channel for RPCs.
      Returns:
      this builder, for chaining.
    • excludeMethod

      @NonNull public 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.
      Specified by:
      excludeMethod in interface RPCSender.Builder
      Parameters:
      name - the name of the method to exclude.
      methodDescriptor - the descriptor of the method to exclude.
      Returns:
      this builder, for chaining.
    • objectMapper

      @NonNull public RPCSender.Builder objectMapper(@NonNull @NonNull ObjectMapper objectMapper)
      Sets the object mapper for serialization of objects during RPC execution related to the final rpc provider.
      Specified by:
      objectMapper in interface RPCProvider.Builder<RPCSender.Builder>
      Parameters:
      objectMapper - the object mapper to use.
      Returns:
      this builder, for chaining.
    • dataBufFactory

      @NonNull public RPCSender.Builder dataBufFactory(@NonNull @NonNull DataBufFactory dataBufFactory)
      Sets the data buf factory to use for everything that is related with data serialization in the final rpc provider.
      Specified by:
      dataBufFactory in interface RPCProvider.Builder<RPCSender.Builder>
      Parameters:
      dataBufFactory - the data buf factory to use.
      Returns:
      this builder, for chaining.
    • build

      @NonNull public @NonNull RPCSender build()
      Validates the options and target class provided to this builder and constructs the final sender instance in case everything checks out.
      Specified by:
      build in interface RPCSender.Builder
      Returns:
      a new sender instance based on the options provided to this builder.