Package io.dapr.client

# Class DaprClientBuilder

java.lang.Object
io.dapr.client.DaprClientBuilder

public class DaprClientBuilder extends Object
A builder for the DaprClient, Currently only gRPC and HTTP Client will be supported.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DaprClientBuilder()`
  Creates a constructor for DaprClient.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DaprClient`
  `build()`
  Build an instance of the Client based on the provided setup.
  `DaprPreviewClient`
  `buildPreviewClient()`
  Build an instance of the Client based on the provided setup.
  `DaprClientBuilder`
  `withObjectSerializer(DaprObjectSerializer objectSerializer)`
  Sets the serializer for objects to be sent and received from Dapr.
  `DaprClientBuilder`
  `withPropertyOverride(Property<?> property, String value)`
  Allow to set up properties override for static properties.
  `DaprClientBuilder`
  `withPropertyOverrides(Map<Property<?>,String> overrides)`
  Allow to set up properties override for static properties.
  `DaprClientBuilder`
  `withResiliencyOptions(ResiliencyOptions options)`
  Sets the resiliency options for DaprClient.
  `DaprClientBuilder`
  `withStateSerializer(DaprObjectSerializer stateSerializer)`
  Sets the serializer for objects to be persisted.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DaprClientBuilder

    public DaprClientBuilder()
    Creates a constructor for DaprClient. `DefaultObjectSerializer` is used for object and state serializers by default but is not recommended for production scenarios.

- ## Method Details

  - ### withObjectSerializer

    public DaprClientBuilder withObjectSerializer(DaprObjectSerializer objectSerializer)
    Sets the serializer for objects to be sent and received from Dapr. See `DefaultObjectSerializer` as possible serializer for non-production scenarios.
    Parameters:
      `objectSerializer` - Serializer for objects to be sent and received from Dapr.
    Returns:
      This instance.

  - ### withStateSerializer

    public DaprClientBuilder withStateSerializer(DaprObjectSerializer stateSerializer)
    Sets the serializer for objects to be persisted. See `DefaultObjectSerializer` as possible serializer for non-production scenarios.
    Parameters:
      `stateSerializer` - Serializer for objects to be persisted.
    Returns:
      This instance.

  - ### withResiliencyOptions

    public DaprClientBuilder withResiliencyOptions(ResiliencyOptions options)
    Sets the resiliency options for DaprClient.
    Parameters:
      `options` - Serializer for objects to be persisted.
    Returns:
      This instance.

  - ### withPropertyOverride

    public DaprClientBuilder withPropertyOverride(Property<?> property, String value)
    Allow to set up properties override for static properties.
    Parameters:
      `property` - that we want to override
      `value` - the value of such property
    Returns:
      an instance of the setup Client

  - ### withPropertyOverrides

    public DaprClientBuilder withPropertyOverrides(Map<Property<?>,String> overrides)
    Allow to set up properties override for static properties.
    Parameters:
      `overrides` - properties to override
    Returns:
      an instance of the setup Client

  - ### build

    public DaprClient build()
    Build an instance of the Client based on the provided setup.
    Returns:
      an instance of the setup Client
    Throws:
      `IllegalStateException` - if any required field is missing

  - ### buildPreviewClient

    public DaprPreviewClient buildPreviewClient()
    Build an instance of the Client based on the provided setup.
    Returns:
      an instance of the setup Client
    Throws:
      `IllegalStateException` - if any required field is missing