Jira (PUP-9072) Use repeated_param UX for Deferred()

5 views
Skip to first unread message

Reid Vandewiele (JIRA)

unread,
Aug 16, 2018, 1:14:03 PM8/16/18
to puppe...@googlegroups.com
Reid Vandewiele created an issue
 
Puppet / Improvement PUP-9072
Use repeated_param UX for Deferred()
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2018/08/16 10:13 AM
Priority: Normal Normal
Reporter: Reid Vandewiele

Currently, Deferred() types are created using two arguments, a function name and an argument list which is necessarily an Array.

 

Deferred('join', [[1,2,3], ':'])

This UX does not match existing patterns for calling functions found elsewhere in the Puppet ecosystem, such as when invoking other functions: call_function(name, *args, &block).

When creating a Deferred type, we should use the repeated param UX, same as we do for call_function().

Deferred('join', [1,2,3], ':')

The extra explicitness of putting the argument list in an array doesn't help our users and doesn't match existing patterns. If it is technically possible, we should use the repeated param UX instead.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Reid Vandewiele (JIRA)

unread,
Aug 16, 2018, 1:27:03 PM8/16/18
to puppe...@googlegroups.com
Reid Vandewiele commented on Improvement PUP-9072
 
Re: Use repeated_param UX for Deferred()

Henrik Lindberg is this something that we can do, or is a repeated param pattern currently not possible when initializing types?

Reid Vandewiele (JIRA)

unread,
Aug 17, 2018, 11:47:03 AM8/17/18
to puppe...@googlegroups.com

HipChat Sensitive Data room, Friday August 17, 2018

[7:41 AM] Henrik Lindberg:
@turbodog @TonyVu There was a question in the demo about the use of an array for the arguments. This was kind of a design choice.

[7:42 AM] Henrik Lindberg:
It has to do with calling "new" on a type, and creating a serializeable object. That simply maps each given value to an attribute, and arguments is an array, so it must be one in the call.

[7:44 AM] Henrik Lindberg:
That can probably be changed if we so desire. What it prevents though is to give Deferred additional arguments in the future. That could for instance be a return type check, or something that prevents a Deferred from being automatically resolved (i.e. you want it to be sent all the way to a resource provider and that the provider resolves the value (i.e. makes the call).

[7:46 AM] Henrik Lindberg:
For those reasons I thought we could just as well keep the arguments as an array.

[7:52 AM] Lindsey Smith:
@ReidVandewiele ^^^

[8:43 AM] Reid Vandewiele:
I filed PUP-9072 with my thoughts on the UX. I understand how an explicit array is technically more powerful in that it "leaves the door open" to potential future extensions. It's not free though; requiring an Array argument costs UX consistency and simplicity.

[8:43 AM] Reid Vandewiele:
Barring a known future use case we believe would be adopted >20% of the time, I would make the UX choice to close that door in favor of simplifying how the majority of our customers will write and use Deferred.

[8:44 AM] Reid Vandewiele:
...Especially if we have the option of using a different signature, e.g. Deferred( Hash ), to account for yet-unknown complex use cases in the future.

Reid Vandewiele (JIRA)

unread,
Aug 27, 2018, 2:53:03 PM8/27/18
to puppe...@googlegroups.com

Henrik Lindberg technical question, do we even have the option of more than one signature here? E.g. can we have a Deferred(String, ...) way to create a Deferred type as the way most people would use it, AND a Deferred(Hash) way for advanced implementation, or do we have to pick just one?

Henrik Lindberg (JIRA)

unread,
Aug 28, 2018, 7:14:02 AM8/28/18
to puppe...@googlegroups.com

Thomas Hallgren How hard would it be to get a custom `new` function for the `Deferred`?
It is defined like this:

    add_object_type('Deferred', <<-PUPPET, loader)
      {
        attributes => {
          # Fully qualified name of the function
          name  => { type => Pattern[/\\A[$]?[a-z][a-z0-9_]*(?:::[a-z][a-z0-9_]*)*\\z/] },
          arguments => { type => Optional[Array[Any]], value => undef},
        }
      }
    PUPPET

(There is no custom implementation of the data type - the above is all there is except for the resolution on the agent side)

Clearly it must have an array with the arguments, but how would I add the custom constructor that would take
String, *args?

Jorie Tappa (JIRA)

unread,
Sep 10, 2018, 5:03:02 PM9/10/18
to puppe...@googlegroups.com
Jorie Tappa updated an issue
 
Change By: Jorie Tappa
Sub-team: Language

Jorie Tappa (JIRA)

unread,
Oct 8, 2018, 5:06:05 PM10/8/18
to puppe...@googlegroups.com
Jorie Tappa updated an issue
Change By: Jorie Tappa
Team: Server

Cas Donoghue (Jira)

unread,
Dec 8, 2020, 6:56:03 PM12/8/20
to puppe...@googlegroups.com
Cas Donoghue commented on Improvement PUP-9072
 
Re: Use repeated_param UX for Deferred()

Reid Vandewiele Is this still something you are interested in?

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Reid Vandewiele (Jira)

unread,
Dec 8, 2020, 7:51:03 PM12/8/20
to puppe...@googlegroups.com

Interested? Totally. Nothing has changed about the UX considerations. Only thing different now is what year it is. I think it would have been best to ship this with the preferred UX on day 1 so there's some diminishment to the value from the non-preferred way having been out there and being learned by people for awhile.

It sounded to me like where this got left was an open question about whether it was technically possible to define a constructor that takes String, *args. If the answer is "yes, and it's easy", I think we should totally do it.

Josh Cooper (Jira)

unread,
Feb 8, 2022, 2:16:03 AM2/8/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Team: Froyo
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages