Skip to content

Package setters on SDK Request classes #587

Description

@gboersma

It should be possible to create an instance of a request class, e.g. the InvokeMethodRequest class, set the parameters on it, and then call <T> Mono<T> invokeMethod(InvokeMethodRequest invokeMethodRequest, TypeRef<T> type); on DaprClient. However, the setters defined on InvokeMethodRequest are package scope, so they cannot be called. The setters should have public scope, or there should be a constructor that allows them to be set.

Same comment applies to PublishEventRequest, InvokeBindingRequest, GetStateRequest, BulkStateRequest, DeleteStateRequest, GetSecretRequest, GetBulkSecretRequest. ExecuteStateTransactionRequest has a constructor that sets the parameters, but could perhaps also benefit from setters.

I do see the Builder pattern is available (e.g. InvokeMethodRequestBuilder), so that can always be used instead. However, this is overkill for just setting parameters for the request. Also, the builder pattern is not quite right- there should be a static method on a builder class to instantiate a new builder, rather than having to instantiate a builder via new- typically, constructors on a builder have package / private access. And rather than setting the name of the service and method in a constructor on the builder, these should be additonal methods on the builder class to make it more explicit what is being set.

Activity

  1. changed the title [-]Package setters on InvokeMethodRequest class[/-] [+]Package setters on SDK Request classes[/+] on Jul 27, 2021
  2. artursouza commented on Jul 28, 2021

    @artursouza
    Contributor

    I agree to make this change and deprecate (not remove) the model builder classes as per the Azure SDK guidelines: https://azure.github.io/azure-sdk/java_introduction.html#java-models-builder

    I will accept a PR addressing this.

  3. added this to the v1.3 milestone on Jul 29, 2021
  4. artursouza commented on Aug 20, 2021

    @artursouza
    Contributor

    Issue to remove Builder classes in 1.5: #601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions