Package io.hekate.rpc

Interface RpcClientBuilder<T>

    • Method Detail

      • build

        T build()
        Constructs a new RPC client proxy.

        Note: this operation is relatively expensive and it is highly recommended to cache RPC proxy instances that are produced by this method.

        Returns:
        new RPC client proxy instance.
      • type

        Class<T> type()
        Returns the RPC interface type.
        Returns:
        RPC interface type.
        See Also:
        Rpc
      • withLoadBalancer

        RpcClientBuilder<T> withLoadBalancer​(RpcLoadBalancer balancer)
        Returns a new builder that will apply the specifier load balancer to all clients that it produces.

        Alternatively, the load balancer can be pre-configured via RpcClientConfig.setLoadBalancer(RpcLoadBalancer) method.

        Parameters:
        balancer - Load balancer.
        Returns:
        New builder that will use the specified load balancer and will inherit all other options from this builder.
      • withRetryPolicy

        RpcClientBuilder<T> withRetryPolicy​(GenericRetryConfigurer retry)
        Returns a new builder that will apply the specifier retry policy to all clients that it produces.

        Notice: The specified retry policy will be applied only to those RPC methods that are explicitly marked with the RpcRetry annotation. Options that are defined in the annotation's attributes have higher priority over this policy.

        Parameters:
        retry - Retry policy.
        Returns:
        New builder that will use the specified retry policy and will inherit all other options from this builder.
      • timeout

        long timeout()
        Returns the timeout value in milliseconds (see withTimeout(long, TimeUnit)).
        Returns:
        Timeout in milliseconds or 0, if timeout was not specified.
      • withTimeout

        RpcClientBuilder<T> withTimeout​(long timeout,
                                        TimeUnit unit)
        Returns a new builder that will apply the specifier timeout to all clients that it produces.

        If the RPC operation can not be completed at the specified timeout then such operation will end up an error. Specifying a negative or zero value disables the timeout check.

        Alternatively, the timeout value can be pre-configured via RpcClientConfig.setTimeout(long) method.

        Parameters:
        timeout - Timeout.
        unit - Time unit.
        Returns:
        New builder that will use the specified timeout and will inherit all other options from this builder.
      • cluster

        ClusterView cluster()
        Returns the cluster view of this builder.

        All clients that are produced by this builder will use the same cluster view for RPC requests routing and load balancing.

        Returns:
        Cluster view of this builder.
      • withCluster

        RpcClientBuilder<T> withCluster​(ClusterView cluster)
        Returns a new builder that will use the specified cluster view with all clients that it produces.
        Parameters:
        cluster - Cluster view.
        Returns:
        Channel wrapper.
      • withPartitions

        RpcClientBuilder<T> withPartitions​(int partitions,
                                           int backupNodes)
        Returns a new builder that will apply the specified partitions mapping options to all clients that it produces.
        Parameters:
        partitions - Total amount of partitions that should be managed by the RPC client's partition mapper.
        backupNodes - Amount of backup nodes that should be assigned to each partition by the the RPC client's partition mapper.
        Returns:
        New builder that will apply the specified partitions mapping options to all of the clients that it will produce..
        See Also:
        partitions()